FOSSology  4.4.0
Open Source License Compliance by Open Source Software
test_common_dir.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2011 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
13 require_once(dirname(__FILE__) . '/../common-dir.php');
14 
18 class test_common_dir extends \PHPUnit\Framework\TestCase
19 {
20  /* initialization */
21  protected function setUp() : void
22  {
23  // print "Starting unit test for common-dir.php\n";
24  print('.');
25  }
26 
30  protected function tearDown() : void
31  {
32  //print "Ending unit test for common-dir.php\n";
33  }
34 
38  function test_Is()
39  {
40  print "Starting unit test for common-dir.php\n";
41  print "test function Isdir()\n";
42  $mode = 536888320;
43  $result = Isdir($mode);
44  $this->assertEquals(true, $result);
45  $mode = 33188;
46  $result = Isdir($mode);
47  $this->assertEquals(false, $result);
48  print "test function Isartifact()\n";
49  $mode = 536888320;
50  $result = Isartifact($mode);
51  $this->assertEquals(false, $result);
52  $mode = 805323776;
53  $result = Isartifact($mode);
54  $this->assertEquals(true, $result);
55  print "test function Iscontainer()\n";
56  $mode = 536888320;
57  $result = Iscontainer($mode);
58  $this->assertEquals(true, $result);
59  $mode = 805323776;
60  $result = Iscontainer($mode);
61  $this->assertEquals(true, $result);
62 
63  print "test function DirMode2String()\n";
64  $result = DirMode2String($mode);
65  $this->assertEquals("a-d-----S---", $result);
66  //print "Ending unit test for common-dir.php\n";
67  }
71  public function test_GetFileExt()
72  {
73  $this->assertEquals(GetFileExt('autodestroy.exe.bak'),'bak');
74  }
75 
79  public function test_DirMode2String()
80  {
81  // print "test function DirMode2String()\n";
82  $result = DirMode2String(805323776);
83  $this->assertEquals("a-d-----S---", $result);
84  $result = DirMode2String(0644);
85  $this->assertEquals("---rw-r--r--", $result);
86  }
87 }
test_GetFileExt()
test of ExtensionGetter
test_DirMode2String()
test for DirMode2String
tearDown()
clean the env
test_Is()
test for Isdir Isartifact Iscontainer
Isdir($mode)
Definition: common-dir.php:20
Isartifact($mode)
Definition: common-dir.php:29
DirMode2String($Mode)
Convert a file mode to string values.
Definition: common-dir.php:50
Iscontainer($mode)
Definition: common-dir.php:38
GetFileExt($fname)
Get File Extension (text after last period)
Definition: common-ui.php:142