Skip to content
Extraits de code Groupes Projets
Valider 9408f5f4 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

In IntegrationTestCase, create processed dir if it does not exist, add...

In IntegrationTestCase, create processed dir if it does not exist, add assertion to test individual API calls.
parent ebc376c4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -317,6 +317,10 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -317,6 +317,10 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
$path = static::getPathToTestDirectory(); $path = static::getPathToTestDirectory();
$processedPath = $path . '/processed/'; $processedPath = $path . '/processed/';
if (!is_dir($processedPath)) {
mkdir($processedPath, $mode = 0777, $recursive = true);
}
if (!is_writable($processedPath)) { if (!is_writable($processedPath)) {
self::fail('To run the tests, you need to give write permissions to the following directory (create it if ' 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 . 'it doesn\'t exist).<code><br/>mkdir ' . $processedPath . '<br/>chmod 777 ' . $processedPath
...@@ -378,6 +382,24 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -378,6 +382,24 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
return $result; return $result;
} }
/**
* 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. * Runs API tests.
*/ */
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter