Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2014-09-14 02:58:44 +0400
committerdiosmosis <benaka@piwik.pro>2014-09-14 02:58:44 +0400
commit9408f5f42dfad3d73b54b1924810a3ccea683ae7 (patch)
tree5bccc167ce899ec9e53eef3dd3f791cb44ee19fa
parentebc376c4cfca7e030477ee1381e131bb4076e997 (diff)
In IntegrationTestCase, create processed dir if it does not exist, add assertion to test individual API calls.
-rwxr-xr-xtests/PHPUnit/IntegrationTestCase.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php
index bb371d8c48..59160c7c30 100755
--- a/tests/PHPUnit/IntegrationTestCase.php
+++ b/tests/PHPUnit/IntegrationTestCase.php
@@ -317,6 +317,10 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
$path = static::getPathToTestDirectory();
$processedPath = $path . '/processed/';
+ if (!is_dir($processedPath)) {
+ mkdir($processedPath, $mode = 0777, $recursive = true);
+ }
+
if (!is_writable($processedPath)) {
self::fail('To run the tests, you need to give write permissions to the following directory (create it if '
. 'it doesn\'t exist).<code><br/>mkdir ' . $processedPath . '<br/>chmod 777 ' . $processedPath
@@ -379,6 +383,24 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
}
/**
+ * Assert that the response of an API method call is the same as the contents in an
+ * expected file.
+ *
+ * @param string $api ie, `"UserSettings.getBrowser"`
+ * @param array $queryParams Query parameters to send to the API.
+ */
+ public function assertApiResponseEqualsExpected($apiMethod, $queryParams)
+ {
+ $this->runApiTests($apiMethod, array(
+ 'idSite' => $queryParams['idSite'],
+ 'date' => $queryParams['date'],
+ 'periods' => $queryParams['period'],
+ 'testSuffix' => '_' . $this->getName(), // TODO: instead of using a test suffix, the whole file name should just be the test method
+ 'otherRequestParameters' => $queryParams
+ ));
+ }
+
+ /**
* Runs API tests.
*/
protected function runApiTests($api, $params)