summaryrefslogtreecommitdiff
path: root/tests/TestBaseApi.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2011-03-26 17:04:00 +0100
committerChristian Weiske <cweiske@cweiske.de>2011-03-26 17:04:00 +0100
commita756799ef4df0449244d41c2ecc7133c3fb8ce70 (patch)
treecec5679b67a6997da37bd1593903fe29891ffc78 /tests/TestBaseApi.php
parent361c18469af5f6782e622420797c4acd5fa70b97 (diff)
downloadsemanticscuttle-a756799ef4df0449244d41c2ecc7133c3fb8ce70.tar.gz
semanticscuttle-a756799ef4df0449244d41c2ecc7133c3fb8ce70.tar.bz2
move setUnittestConfig to TestBaseApi since it makes only sense to use it there
Diffstat (limited to 'tests/TestBaseApi.php')
-rw-r--r--tests/TestBaseApi.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php
index 2af228a..2341ea1 100644
--- a/tests/TestBaseApi.php
+++ b/tests/TestBaseApi.php
@@ -58,6 +58,18 @@ class TestBaseApi extends TestBase
/**
+ * Clean up after test
+ */
+ public function tearDown()
+ {
+ if (file_exists($GLOBALS['datadir'] . '/config.unittest.php')) {
+ unlink($GLOBALS['datadir'] . '/config.unittest.php');
+ }
+ }
+
+
+
+ /**
* Gets a HTTP request object.
* Uses $this->url plus $urlSuffix as request URL.
*
@@ -158,5 +170,37 @@ class TestBaseApi extends TestBase
return array($req, $uid);
}
+
+
+ /**
+ * Writes a special unittest configuration file.
+ * The unittest config file is read when a GET request with unittestMode=1
+ * is sent, and the user allowed unittestmode in config.php.
+ *
+ * @param array $arConfig Array with config names as key and their value as
+ * value
+ *
+ * @return void
+ */
+ protected function setUnittestConfig($arConfig)
+ {
+ $str = '<' . "?php\r\n";
+ foreach ($arConfig as $name => $value) {
+ $str .= '$' . $name . ' = '
+ . var_export($value, true) . ";\n";
+ }
+
+ if (!is_dir($GLOBALS['datadir'])) {
+ $this->fail(
+ 'datadir not set or not a directory: ' . $GLOBALS['datadir']
+ );
+ }
+
+ $this->assertInternalType(
+ 'integer',
+ file_put_contents($GLOBALS['datadir'] . '/config.unittest.php', $str),
+ 'Writing config.unittest.php failed'
+ );
+ }
}
?> \ No newline at end of file