Skip to content
Extraits de code Groupes Projets
Valider 4ce53c0b rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

refs #3227 integration tests: check file length before trying to check if the...

refs #3227 integration tests: check file length before trying to check if the string is equal for non xml output; that prevents some outofmemory exceptions for longer files
mark test as incomplete if an expected output file is missing

git-svn-id: http://dev.piwik.org/svn/trunk@6897 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 1577e972
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -505,7 +505,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -505,7 +505,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
{ {
$parametersToSet['language'] = $language; $parametersToSet['language'] = $language;
} }
// set idSubtable if subtable API is set // set idSubtable if subtable API is set
if ($supertableApi !== false) if ($supertableApi !== false)
{ {
...@@ -518,7 +518,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -518,7 +518,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
'format' => 'php', 'format' => 'php',
'serialize' => 0, 'serialize' => 0,
)); ));
// find first row w/ subtable // find first row w/ subtable
foreach ($request->process() as $row) foreach ($request->process() as $row)
{ {
...@@ -528,7 +528,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -528,7 +528,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
break; break;
} }
} }
// if no subtable found, throw // if no subtable found, throw
if (!isset($parametersToSet['idSubtable'])) if (!isset($parametersToSet['idSubtable']))
{ {
...@@ -536,7 +536,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -536,7 +536,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
"Cannot find subtable to load for $apiId in $supertableApi."); "Cannot find subtable to load for $apiId in $supertableApi.");
} }
} }
// Generate for each specified format // Generate for each specified format
foreach($formats as $format) foreach($formats as $format)
{ {
...@@ -590,8 +590,8 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -590,8 +590,8 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
* @param bool $apiModule * @param bool $apiModule
* @param bool $apiAction * @param bool $apiAction
* @param array $otherRequestParameters * @param array $otherRequestParameters
* @param array $supertableApi * @param array|bool $supertableApi
* @param array $fileExtension * @param array|bool $fileExtension
* *
* @return array * @return array
*/ */
...@@ -723,7 +723,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -723,7 +723,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
$expected = $this->removeXmlElement($expected, 'imageGraphUrl'); $expected = $this->removeXmlElement($expected, 'imageGraphUrl');
$response = $this->removeXmlElement($response, 'imageGraphUrl'); $response = $this->removeXmlElement($response, 'imageGraphUrl');
} }
// if idSubtable is in request URL, make sure idSubtable values are not in any urls // if idSubtable is in request URL, make sure idSubtable values are not in any urls
if (strpos($requestUrl, 'idSubtable=') !== false) if (strpos($requestUrl, 'idSubtable=') !== false)
{ {
...@@ -745,9 +745,10 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -745,9 +745,10 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
} }
if (strpos($requestUrl, 'format=xml') !== false) { if (strpos($requestUrl, 'format=xml') !== false) {
$this->assertXmlStringEqualsXmlString($expected, $response, "Differences with expected in: $processedFilePath %s "); $this->assertXmlStringEqualsXmlString($expected, $response, "Differences with expected in: $processedFilePath");
} else { } else {
$this->assertEquals($expected, $response, "Differences with expected in: $processedFilePath %s "); $this->assertEquals(strlen($expected), strlen($response), "Differences with expected in: $processedFilePath");
$this->assertEquals($expected, $response, "Differences with expected in: $processedFilePath");
} }
if (trim($response) == trim($expected)) { if (trim($response) == trim($expected)) {
file_put_contents($processedFilePath, $response); file_put_contents($processedFilePath, $response);
...@@ -817,7 +818,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -817,7 +818,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
if(empty($result)) if(empty($result))
{ {
$expectedDir = dirname($filePath); $expectedDir = dirname($filePath);
$this->fail(" ERROR: Could not find expected API output '$filePath'. For new tests, to pass the test, you can copy files from the processed/ directory into $expectedDir after checking that the output is valid. %s "); $this->markTestIncomplete(" ERROR: Could not find expected API output '$filePath'. For new tests, to pass the test, you can copy files from the processed/ directory into $expectedDir after checking that the output is valid. %s ");
return null; return null;
} }
return $result; return $result;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter