FOSSology  4.7.1
Open Source License Compliance by Open Source Software
test_common_multicompare.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2026 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 require_once(dirname(__FILE__) . '/../common-dir.php');
9 require_once(dirname(__FILE__) . '/../common-multicompare.php');
10 
11 class test_common_multicompare extends \PHPUnit\Framework\TestCase
12 {
13  public function testNormalizesSoleDirectoryChild(): void
14  {
15  $children = [[
16  'uploadtree_pk' => 42,
17  'ufile_mode' => (1 << 18) | (1 << 29),
18  ]];
19 
20  $this->assertSame(42, NormalizeMultiCompareRoot(10, $children));
21  }
22 
23  public function testKeepsRootWithMultipleChildren(): void
24  {
25  $children = [
26  ['uploadtree_pk' => 42, 'ufile_mode' => (1 << 18) | (1 << 29)],
27  ['uploadtree_pk' => 43, 'ufile_mode' => 0100644],
28  ];
29 
30  $this->assertSame(10, NormalizeMultiCompareRoot(10, $children));
31  }
32 
33  public function testKeepsRootWithSoleFileChild(): void
34  {
35  $children = [[
36  'uploadtree_pk' => 42,
37  'ufile_mode' => 0100644,
38  ]];
39 
40  $this->assertSame(10, NormalizeMultiCompareRoot(10, $children));
41  }
42 
43  public function testKeepsRootWithoutChildren(): void
44  {
45  $this->assertSame(10, NormalizeMultiCompareRoot(10, []));
46  }
47 }
NormalizeMultiCompareRoot(int $selectedItem, array $children)
Select the effective comparison root for a tree item.