diff options
author | Mark Pemberton <mpemberton5@gmail.com> | 2011-05-21 21:38:25 -0400 |
---|---|---|
committer | Mark Pemberton <mpemberton5@gmail.com> | 2011-05-21 21:38:25 -0400 |
commit | b105867e75f103ae2b0c54edfaa9ce6467a8a258 (patch) | |
tree | 299bd99f271a55a98de88e8b27e457ea8401d2f1 /tests/TestBaseApi.php | |
parent | e0149e24e2b5fac3b875fda468b18fbe2b6b1218 (diff) | |
parent | 97bba97049eeed2ecec022caa641b50ca507cb72 (diff) | |
download | semanticscuttle-b105867e75f103ae2b0c54edfaa9ce6467a8a258.tar.gz semanticscuttle-b105867e75f103ae2b0c54edfaa9ce6467a8a258.tar.bz2 |
Merge branch 'master' into privatekey2
Diffstat (limited to 'tests/TestBaseApi.php')
-rw-r--r-- | tests/TestBaseApi.php | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index 2caa701..20574f3 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -50,8 +50,9 @@ class TestBaseApi extends TestBase $this->url = $GLOBALS['unittestUrl'] . $this->urlPart; //clean up before test - if (file_exists($GLOBALS['datadir'] . '/config.unittest.php')) { - unlink($GLOBALS['datadir'] . '/config.unittest.php'); + $configFile = $GLOBALS['datadir'] . '/config.testing-tmp.php'; + if (file_exists($configFile)) { + unlink($configFile); } $this->us = SemanticScuttle_Service_Factory::get('User'); @@ -71,19 +72,36 @@ class TestBaseApi extends TestBase * @param string $urlSuffix Suffix for the URL * * @return HTTP_Request2 HTTP request object - * - * @uses $url */ protected function getRequest($urlSuffix = null) { - $req = new HTTP_Request2( - $this->url . $urlSuffix, - HTTP_Request2::METHOD_GET - ); + $url = $this->getTestUrl($urlSuffix); + $req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET); return $req; } + /** + * Creates an URL from $this->url plus $urlSuffix and an appended + * unittestMode=1 parameter. + * + * @param string $urlSuffix Suffix for the URL + * + * @return string URL + * + * @uses $url + */ + protected function getTestUrl($urlSuffix = null) + { + $url = $this->url . $urlSuffix; + if (strpos($urlSuffix, '?') !== false) { + $url .= '&unittestMode=1'; + } else { + $url .= '?unittestMode=1'; + } + return $url; + } + /** * Completes an URL that's missing the protocol. @@ -165,7 +183,7 @@ class TestBaseApi extends TestBase $uid = $this->addUser($username, $password); $req = new HTTP_Request2( - $GLOBALS['unittestUrl'] . '/login.php', + $GLOBALS['unittestUrl'] . '/login.php?unittestMode=1', HTTP_Request2::METHOD_POST ); $cookies = $req->setCookieJar()->getCookieJar(); @@ -230,7 +248,7 @@ class TestBaseApi extends TestBase $this->assertInternalType( 'integer', - file_put_contents($GLOBALS['datadir'] . '/config.unittest.php', $str), + file_put_contents($GLOBALS['datadir'] . '/config.testing-tmp.php', $str), 'Writing config.unittest.php failed' ); } |