21
21
class KWUtilsTest extends ControllerTestCase
22
22
{
23
23
24
- /**
25
- * helper function to return Midas configured temp directory
26
- * @return midas temp dir
27
- */
28
- protected function getTempDirectory ()
29
- {
30
- include_once BASE_PATH .'/core/GlobalController.php ' ;
31
- $ controller = new MIDAS_GlobalController ($ this ->request , $ this ->response );
32
- return $ controller ->getTempDirectory ();
33
- }
34
-
35
24
/** tests mkDir function */
36
25
public function testMkDir ()
37
26
{
38
- $ tmpDir = $ this ->getTempDirectory () . '/KWUtilsTest ' ;
39
- $ this ->assertTrue (KWUtils::mkDir ($ tmpDir ));
27
+ $ tmpDir = KWUtils::getTempDirectory ();
28
+ $ testDir = $ tmpDir . '/ ' . 'KWUtilsTest ' ;
29
+ $ this ->assertTrue (KWUtils::mkDir ($ testDir ));
40
30
// now clean up
41
- KWUtils::recursiveRemoveDirectory ($ tmpDir );
31
+ KWUtils::recursiveRemoveDirectory ($ testDir );
42
32
}
43
33
44
34
/** tests createSubDirectories function */
@@ -47,7 +37,7 @@ public function testCreateSubDirectories()
47
37
// test creating directories, do this in the tmp dir
48
38
//
49
39
// create a nested set of directories
50
- $ tmpDir = $ this -> getTempDirectory () . '/ ' ;
40
+ $ tmpDir = KWUtils:: getTempDirectory () . '/ ' ;
51
41
$ subDirs = array ("KWUtilsTest " , "1 " , "2 " , "3 " );
52
42
$ outDir = KWUtils::createSubDirectories ($ tmpDir , $ subDirs );
53
43
@@ -66,7 +56,7 @@ public function testCreateSubDirectories()
66
56
$ this ->assertTrue (is_dir ($ currDir ));
67
57
}
68
58
69
- $ topDir = $ this -> getTempDirectory () . '/KWUtilsTest ' ;
59
+ $ topDir = KWUtils:: getTempDirectory () . '/KWUtilsTest ' ;
70
60
KWUtils::recursiveRemoveDirectory ($ topDir );
71
61
}
72
62
@@ -78,7 +68,7 @@ public function testExec()
78
68
// the value of pwd in it
79
69
80
70
// create a tmp dir for this test
81
- $ execDir = $ this -> getTempDirectory () . '/KWUtilsTest ' ;
71
+ $ execDir = KWUtils:: getTempDirectory () . '/KWUtilsTest ' ;
82
72
mkdir ($ execDir );
83
73
$ cmd = 'pwd ' ;
84
74
$ chdir = $ execDir ;
@@ -162,9 +152,9 @@ public function testRecursiveRemoveDirectory()
162
152
$ this ->assertFalse (KWUtils::recursiveRemoveDirectory ('thisstringisunlikelytobeadirectory ' ));
163
153
164
154
// create a two-level directory
165
- $ testParentDir = $ this -> getTempDirectory () . '/KWUtilsParentDir ' ;
155
+ $ testParentDir = KWUtils:: getTempDirectory () . '/KWUtilsParentDir ' ;
166
156
mkdir ($ testParentDir );
167
- $ testChildDir = $ this -> getTempDirectory () . '/KWUtilsParentDir/ChildDir ' ;
157
+ $ testChildDir = KWUtils:: getTempDirectory () . '/KWUtilsParentDir/ChildDir ' ;
168
158
mkdir ($ testChildDir );
169
159
copy (BASE_PATH .'/tests/testfiles/search.png ' , $ testChildDir .'/testContent.png ' );
170
160
$ this ->assertTrue (file_exists ($ testChildDir .'/testContent.png ' ));
0 commit comments