FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
test_common_dir.php
Go to the documentation of this file.
1 <?php
2 /*
3  Copyright (C) 2011 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
24 require_once(dirname(__FILE__) . '/../common-dir.php');
25 
29 class test_common_dir extends \PHPUnit\Framework\TestCase
30 {
31  /* initialization */
32  protected function setUp()
33  {
34  // print "Starting unit test for common-dir.php\n";
35  print('.');
36  }
37 
41  protected function tearDown()
42  {
43  //print "Ending unit test for common-dir.php\n";
44  }
45 
49  function test_Is()
50  {
51  print "Starting unit test for common-dir.php\n";
52  print "test function Isdir()\n";
53  $mode = 536888320;
54  $result = Isdir($mode);
55  $this->assertEquals(true, $result);
56  $mode = 33188;
57  $result = Isdir($mode);
58  $this->assertEquals(false, $result);
59  print "test function Isartifact()\n";
60  $mode = 536888320;
61  $result = Isartifact($mode);
62  $this->assertEquals(false, $result);
63  $mode = 805323776;
64  $result = Isartifact($mode);
65  $this->assertEquals(true, $result);
66  print "test function Iscontainer()\n";
67  $mode = 536888320;
68  $result = Iscontainer($mode);
69  $this->assertEquals(true, $result);
70  $mode = 805323776;
71  $result = Iscontainer($mode);
72  $this->assertEquals(true, $result);
73 
74  print "test function DirMode2String()\n";
75  $result = DirMode2String($mode);
76  $this->assertEquals("a-d-----S---", $result);
77  //print "Ending unit test for common-dir.php\n";
78  }
82  public function test_GetFileExt()
83  {
84  $this->assertEquals(GetFileExt('autodestroy.exe.bak'),'bak');
85  }
86 
90  public function test_DirMode2String()
91  {
92  // print "test function DirMode2String()\n";
93  $result = DirMode2String(805323776);
94  $this->assertEquals("a-d-----S---", $result);
95  $result = DirMode2String(0644);
96  $this->assertEquals("---rw-r--r--", $result);
97  }
98 }
DirMode2String($Mode)
Convert a file mode to string values.
Definition: common-dir.php:61
Iscontainer($mode)
Definition: common-dir.php:49
test_GetFileExt()
test of ExtensionGetter
test_DirMode2String()
test for DirMode2String
test_Is()
test for Isdir Isartifact Iscontainer
tearDown()
clean the env
GetFileExt($fname)
Get File Extension (text after last period)
Definition: common-ui.php:127
Isdir($mode)
Definition: common-dir.php:31
Isartifact($mode)
Definition: common-dir.php:40