diff --git a/plugins/CoreAdminHome/API.php b/plugins/CoreAdminHome/API.php index 5db05880719b99c0158962de6649607e69675008..f1e0058768ba0a80cada689bb488235779b12c55 100644 --- a/plugins/CoreAdminHome/API.php +++ b/plugins/CoreAdminHome/API.php @@ -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(); diff --git a/tests/PHPUnit/Integration/AnnotationsTest.php b/tests/PHPUnit/Integration/AnnotationsTest.php index 1692c269028eca9e54d55d30ca8962fec5ed7de0..478fca650481fba668714848e72db27bd1a6f09a 100755 --- a/tests/PHPUnit/Integration/AnnotationsTest.php +++ b/tests/PHPUnit/Integration/AnnotationsTest.php @@ -308,7 +308,8 @@ class AnnotationsTest extends IntegrationTestCase } } else { $request = new Request($request); - $request->process(); + $response = $request->process(); + $this->checkRequestResponse($response); } } } diff --git a/tests/PHPUnit/Integration/AutoSuggestAPITest.php b/tests/PHPUnit/Integration/AutoSuggestAPITest.php index 612198140f84a6d72fd4f1bd38752ef2cb225cc6..e940980e66809307fe0f1cde55a76722d89b8743 100644 --- a/tests/PHPUnit/Integration/AutoSuggestAPITest.php +++ b/tests/PHPUnit/Integration/AutoSuggestAPITest.php @@ -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)) { diff --git a/tests/PHPUnit/Integration/VisitsInPast_InvalidateOldReportsTest.php b/tests/PHPUnit/Integration/VisitsInPast_InvalidateOldReportsTest.php index 7a64f6212cf778392818da5f889a58e96b4d8fe1..511b638ea0ac156f39ccc094e5df5fca8fa8fc98 100644 --- a/tests/PHPUnit/Integration/VisitsInPast_InvalidateOldReportsTest.php +++ b/tests/PHPUnit/Integration/VisitsInPast_InvalidateOldReportsTest.php @@ -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); diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php index aee48153ade838165a37dcda412ce2d0cca053dd..2c2a3c9c418cf1990de14401551c2ecda9fd96c1 100755 --- a/tests/PHPUnit/IntegrationTestCase.php +++ b/tests/PHPUnit/IntegrationTestCase.php @@ -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(