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

Allow integration tests to specify XML nodes to remove before comparison.

parent 2607314a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -537,7 +537,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -537,7 +537,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
} }
} }
protected function _testApiUrl($testName, $apiId, $requestUrl, $compareAgainst) protected function _testApiUrl($testName, $apiId, $requestUrl, $compareAgainst, $xmlFieldsToRemove = array())
{ {
$isTestLogImportReverseChronological = strpos($testName, 'ImportedInRandomOrderTest') === false; $isTestLogImportReverseChronological = strpos($testName, 'ImportedInRandomOrderTest') === false;
$isLiveMustDeleteDates = (strpos($requestUrl, 'Live.getLastVisits') !== false $isLiveMustDeleteDates = (strpos($requestUrl, 'Live.getLastVisits') !== false
...@@ -561,6 +561,10 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -561,6 +561,10 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
} }
$response = $this->normalizePdfContent($response); $response = $this->normalizePdfContent($response);
if (!empty($xmlFieldsToRemove)) {
$response = $this->removeXmlFields($response, $xmlFieldsToRemove);
}
$expected = $this->loadExpectedFile($expectedFilePath); $expected = $this->loadExpectedFile($expectedFilePath);
$expectedContent = $expected; $expectedContent = $expected;
$expected = $this->normalizePdfContent($expected); $expected = $this->normalizePdfContent($expected);
...@@ -675,6 +679,11 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -675,6 +679,11 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
'prettyDate', 'prettyDate',
'serverDateTimePrettyFirstAction' 'serverDateTimePrettyFirstAction'
); );
return $this->removeXmlFields($input, $toRemove);
}
protected function removeXmlFields($input, $toRemove)
{
foreach ($toRemove as $xml) { foreach ($toRemove as $xml) {
$input = $this->removeXmlElement($input, $xml); $input = $this->removeXmlElement($input, $xml);
} }
...@@ -860,6 +869,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -860,6 +869,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
isset($params['fileExtension']) ? $params['fileExtension'] : false); isset($params['fileExtension']) ? $params['fileExtension'] : false);
$compareAgainst = isset($params['compareAgainst']) ? ('test_' . $params['compareAgainst']) : false; $compareAgainst = isset($params['compareAgainst']) ? ('test_' . $params['compareAgainst']) : false;
$xmlFieldsToRemove = @$params['xmlFieldsToRemove'];
foreach ($requestUrls as $apiId => $requestUrl) { foreach ($requestUrls as $apiId => $requestUrl) {
// this is a hack // this is a hack
...@@ -869,7 +879,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -869,7 +879,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
} }
} }
$this->_testApiUrl($testName . $testSuffix, $apiId, $requestUrl, $compareAgainst); $this->_testApiUrl($testName . $testSuffix, $apiId, $requestUrl, $compareAgainst, $xmlFieldsToRemove);
} }
// Restore normal purge behavior // Restore normal purge behavior
......
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