Skip to content
Extraits de code Groupes Projets
Valider 0cd6734c rédigé par mattab's avatar mattab
Parcourir les fichiers

Fix bug (missing getInstance()). Exception was not shown because tests were...

Fix bug (missing getInstance()). Exception was not shown because tests were not rethrowing the exception
parent 11b63564
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -168,7 +168,7 @@ class API extends \Piwik\Plugin\API
" AND idsite IN (" . implode(",", $idSites) . ")";
Db::query($query, $bind);
}
\Piwik\Plugins\SitesManager\API::updateSiteCreatedTime($idSites, $minDate);
\Piwik\Plugins\SitesManager\API::getInstance()->updateSiteCreatedTime($idSites, $minDate);
// Force to re-process data for these websites in the next archive.php cron run
$invalidatedIdSites = self::getWebsiteIdsToInvalidate();
......
......@@ -308,7 +308,8 @@ class AnnotationsTest extends IntegrationTestCase
}
} else {
$request = new Request($request);
$request->process();
$response = $request->process();
$this->checkRequestResponse($response);
}
}
}
......
......@@ -82,6 +82,7 @@ class Test_Piwik_Integration_AutoSuggestAPITest extends IntegrationTestCase
. '&format=php&serialize=0'
);
$response = $request->process();
$this->checkRequestResponse($response);
$topSegmentValue = @$response[0];
if ($topSegmentValue !== false && !is_null($topSegmentValue)) {
......
......@@ -69,16 +69,30 @@ class Test_Piwik_Integration_VisitsInPast_InvalidateOldReports extends Integrati
// 1) Invalidate old reports for the 2 websites
// Test invalidate 1 date only
$r = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=4,5,6,55,-1,s',1&dates=2010-01-03");
($r->process());
$this->checkRequestResponse($r->process());
// Test invalidate comma separated dates
$r = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSite . "," . $idSite2 . "&dates=2010-01-06,2009-10-30");
($r->process());
$this->checkRequestResponse($r->process());
// test invalidate date in the past
$r = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSite2 . "&dates=2009-06-29");
($r->process());
// Format=original will re-throw exception
$r = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSite2 . "&dates=2009-06-29&format=original");
$this->checkRequestResponse( json_encode( $r->process() ) );
// invalidate a date more recent to check the date is only updated when it's earlier than current
$r = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSite2 . "&dates=2010-03-03");
($r->process());
$this->checkRequestResponse($r->process());
// Make an invalid call
$idSiteNoAccess = 777;
try {
$request = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSiteNoAccess . "&dates=2010-03-03&format=original");
$request->process();
$this->fail();
} catch(Exception $e) {
}
// 2) Call API again, with an older date, which should now return data
$this->runApiTests($api, $params);
......
......@@ -549,6 +549,8 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
// find first row w/ subtable
$content = $request->process();
$this->checkRequestResponse($content);
foreach ($content as $row) {
if (isset($row['idsubdatatable'])) {
$parametersToSet['idSubtable'] = $row['idsubdatatable'];
......@@ -717,6 +719,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
// with format=original, objects or php arrays can be returned.
// we also hide errors to prevent the 'headers already sent' in the ResponseBuilder (which sends Excel headers multiple times eg.)
$response = (string)$request->process();
$this->checkRequestResponse($response);
if ($isLiveMustDeleteDates) {
$response = $this->removeAllLiveDatesFromXml($response);
......@@ -820,6 +823,12 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
}
}
protected function checkRequestResponse($response)
{
$this->assertTrue(stripos($response, 'error') === false);
$this->assertTrue(stripos($response, 'exception') === false);
}
protected function removeAllLiveDatesFromXml($input)
{
$toRemove = array(
......
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