Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit d9c01c6

Browse files
author
Michael Grauer
committed
BUG: Refs #212. Rewrite of KWUtilsTest.php to use Midas temp dir.
This had been breaking the dashboard on Yellowstone, hopefully this fixes it.
1 parent c1d3c8c commit d9c01c6

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

tests/library/KWUtilsTest.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,30 @@
1616
/**
1717
* KWUtils tests
1818
*/
19+
20+
1921
class KWUtilsTest extends ControllerTestCase
2022
{
2123

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+
}
2234

2335
/** tests mkDir function */
2436
public function testMkDir()
2537
{
26-
$tmpDir = '/tmp';
38+
$tmpDir = $this->getTempDirectory() . '/';
2739
// try creating one that exists
2840
// we can ignore any errors
2941
$this->assertFalse(KWUtils::mkDir($tmpDir));
30-
$tmpDir .= "/KWUtilsTest";
42+
$tmpDir .= "KWUtilsTest";
3143
$this->assertTrue(KWUtils::mkDir($tmpDir));
3244
// now clean up
3345
rmdir($tmpDir);
@@ -39,7 +51,7 @@ public function testCreateSubDirectories()
3951
// test creating directories, do this in the tmp dir
4052
//
4153
// create a nested set of directories
42-
$tmpDir = BASE_PATH . 'tmp/';
54+
$tmpDir = $this->getTempDirectory() . '/';
4355
$subDirs = array("KWUtilsTest", "1", "2", "3");
4456
$outDir = KWUtils::createSubDirectories($tmpDir, $subDirs);
4557

@@ -77,7 +89,7 @@ public function testExec()
7789
// the value of pwd in it
7890

7991
// create a tmp dir for this test
80-
$execDir = BASE_PATH . 'tmp/KWUtilsTest';
92+
$execDir = $this->getTempDirectory() . '/KWUtilsTest';
8193
mkdir($execDir);
8294
$cmd = 'pwd';
8395
$chdir = $execDir;
@@ -86,9 +98,13 @@ public function testExec()
8698

8799
// yuck, need to do a bit of munging to get around tests/.. in BASE_PATH
88100
$execDir = str_replace('tests/../', '', $execDir);
101+
// and now replace any // with /,
102+
// the // doesn't affect functionality on the
103+
// filesystem, but will cause string inequality
104+
$execDir = str_replace('//', '/', $execDir);
89105

90106
$this->assertEquals($execDir, $output[0]);
91-
// return_val should be 0
107+
// returnVal should be 0
92108
$this->assertEquals($returnVal, 0);
93109
// now clean up the tmp dir
94110
rmdir($execDir);

0 commit comments

Comments
 (0)