コード例 #1
0
 /**
  * @group        Benchmarks
  */
 public function testArchivingProcess()
 {
     if ($this->archivingLaunched) {
         echo "NOTE: Had to archive data, memory results will not be accurate. Run again for better results.";
     }
     Rules::$archivingDisabledByTests = true;
     APIMultiSites::getInstance()->getAll(self::$fixture->period, self::$fixture->date);
 }
コード例 #2
0
 /**
  * @group        Benchmarks
  */
 public function testArchivingProcess()
 {
     if ($this->archivingLaunched) {
         echo "NOTE: Had to archive data, memory results will not be accurate. Run again for better results.";
     }
     Rules::$archivingDisabledByTests = true;
     $period = Period\Factory::build(self::$fixture->period, Date::factory(self::$fixture->date));
     $dateRange = $period->getDateStart() . ',' . $period->getDateEnd();
     API::getInstance()->get(self::$fixture->idSite, 'day', $dateRange);
 }
コード例 #3
0
ファイル: IntegrationTestCase.php プロジェクト: Abine/piwik
 /**
  * Runs API tests.
  */
 protected function runApiTests($api, $params)
 {
     $testConfig = new ApiTestConfig($params);
     // make sure that the reports we process here are not directly deleted in ArchiveProcessor/PluginsArchiver
     // (because we process reports in the past, they would sometimes be invalid, and would have been deleted)
     \Piwik\ArchiveProcessor\Rules::disablePurgeOutdatedArchives();
     $testName = 'test_' . static::getOutputPrefix();
     $this->missingExpectedFiles = array();
     $this->comparisonFailures = array();
     if ($testConfig->disableArchiving) {
         Rules::$archivingDisabledByTests = true;
         Config::getInstance()->General['browser_archiving_disabled_enforce'] = 1;
     } else {
         Rules::$archivingDisabledByTests = false;
         Config::getInstance()->General['browser_archiving_disabled_enforce'] = 0;
     }
     if ($testConfig->language) {
         $this->changeLanguage($testConfig->language);
     }
     $testRequests = new TestRequestCollection($api, $testConfig, $api);
     foreach ($testRequests->getRequestUrls() as $apiId => $requestUrl) {
         $this->_testApiUrl($testName . $testConfig->testSuffix, $apiId, $requestUrl, $testConfig->compareAgainst, $testConfig->xmlFieldsToRemove, $params);
     }
     // Restore normal purge behavior
     \Piwik\ArchiveProcessor\Rules::enablePurgeOutdatedArchives();
     // change the language back to en
     if ($this->lastLanguage != 'en') {
         $this->changeLanguage('en');
     }
     if (!empty($this->missingExpectedFiles)) {
         $expectedDir = dirname(reset($this->missingExpectedFiles));
         $this->fail(" ERROR: Could not find expected API output '" . implode("', '", $this->missingExpectedFiles) . "'. 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 ");
     }
     // Display as one error all sub-failures
     if (!empty($this->comparisonFailures)) {
         $this->printComparisonFailures();
         throw reset($this->comparisonFailures);
     }
     return count($this->comparisonFailures) == 0;
 }
コード例 #4
0
ファイル: SystemTestCase.php プロジェクト: mgou-net/piwik
 /**
  * Runs API tests.
  */
 protected function runApiTests($api, $params)
 {
     $testConfig = new ApiTestConfig($params);
     $testName = 'test_' . static::getOutputPrefix();
     $this->missingExpectedFiles = array();
     $this->comparisonFailures = array();
     if ($testConfig->disableArchiving) {
         Rules::$archivingDisabledByTests = true;
         Config::getInstance()->General['browser_archiving_disabled_enforce'] = 1;
     } else {
         Rules::$archivingDisabledByTests = false;
         Config::getInstance()->General['browser_archiving_disabled_enforce'] = 0;
     }
     if ($testConfig->language) {
         $this->changeLanguage($testConfig->language);
     }
     $testRequests = $this->getTestRequestsCollection($api, $testConfig, $api);
     foreach ($testRequests->getRequestUrls() as $apiId => $requestUrl) {
         $this->_testApiUrl($testName . $testConfig->testSuffix, $apiId, $requestUrl, $testConfig->compareAgainst, $params);
     }
     // change the language back to en
     if ($this->lastLanguage != 'en') {
         $this->changeLanguage('en');
     }
     if (!empty($this->missingExpectedFiles)) {
         $expectedDir = dirname(reset($this->missingExpectedFiles));
         $this->fail(" ERROR: Could not find expected API output '" . implode("', '", $this->missingExpectedFiles) . "'. 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 ");
     }
     // Display as one error all sub-failures
     if (!empty($this->comparisonFailures)) {
         $this->printComparisonFailures();
         throw reset($this->comparisonFailures);
     }
     return count($this->comparisonFailures) == 0;
 }
コード例 #5
0
ファイル: SystemTestCase.php プロジェクト: JoeHorn/piwik
 /**
  * Runs API tests.
  */
 protected function runApiTests($api, $params)
 {
     $testConfig = new ApiTestConfig($params);
     $testName = 'test_' . static::getOutputPrefix();
     $this->missingExpectedFiles = array();
     $this->comparisonFailures = array();
     if ($testConfig->disableArchiving) {
         Rules::$archivingDisabledByTests = true;
         Config::getInstance()->General['browser_archiving_disabled_enforce'] = 1;
     } else {
         Rules::$archivingDisabledByTests = false;
         Config::getInstance()->General['browser_archiving_disabled_enforce'] = 0;
     }
     if ($testConfig->language) {
         $this->changeLanguage($testConfig->language);
     }
     $testRequests = $this->getTestRequestsCollection($api, $testConfig, $api);
     foreach ($testRequests->getRequestUrls() as $apiId => $requestUrl) {
         $this->_testApiUrl($testName . $testConfig->testSuffix, $apiId, $requestUrl, $testConfig->compareAgainst, $params);
     }
     // change the language back to en
     if ($this->lastLanguage != 'en') {
         $this->changeLanguage('en');
     }
     $this->printApiTestFailures();
     return count($this->comparisonFailures) == 0;
 }
コード例 #6
0
 /**
  * Runs API tests.
  */
 protected function runApiTests($api, $params)
 {
     // make sure that the reports we process here are not directly deleted in ArchiveProcessor/PluginsArchiver
     // (because we process reports in the past, they would sometimes be invalid, and would have been deleted)
     Rules::$purgeDisabledByTests = true;
     $testName = 'test_' . static::getOutputPrefix();
     $this->missingExpectedFiles = array();
     $this->comparisonFailures = array();
     $this->_setCallableApi($api);
     if (isset($params['disableArchiving']) && $params['disableArchiving'] === true) {
         Rules::$archivingDisabledByTests = true;
         Config::getInstance()->General['browser_archiving_disabled_enforce'] = 1;
     } else {
         Rules::$archivingDisabledByTests = false;
         Config::getInstance()->General['browser_archiving_disabled_enforce'] = 0;
     }
     if (!empty($params['hackDeleteRangeArchivesBefore'])) {
         Db::query('delete from ' . Common::prefixTable('archive_numeric_2009_12') . ' where period = 5');
         Db::query('delete from ' . Common::prefixTable('archive_blob_2009_12') . ' where period = 5');
     }
     if (isset($params['language'])) {
         $this->changeLanguage($params['language']);
     }
     $testSuffix = isset($params['testSuffix']) ? $params['testSuffix'] : '';
     $requestUrls = $this->_generateApiUrls(isset($params['format']) ? $params['format'] : 'xml', isset($params['idSite']) ? $params['idSite'] : false, isset($params['date']) ? $params['date'] : false, isset($params['periods']) ? $params['periods'] : (isset($params['period']) ? $params['period'] : false), isset($params['setDateLastN']) ? $params['setDateLastN'] : false, isset($params['language']) ? $params['language'] : false, isset($params['segment']) ? $params['segment'] : false, isset($params['visitorId']) ? $params['visitorId'] : false, isset($params['abandonedCarts']) ? $params['abandonedCarts'] : false, isset($params['idGoal']) ? $params['idGoal'] : false, isset($params['apiModule']) ? $params['apiModule'] : false, isset($params['apiAction']) ? $params['apiAction'] : false, isset($params['otherRequestParameters']) ? $params['otherRequestParameters'] : array(), isset($params['supertableApi']) ? $params['supertableApi'] : false, isset($params['fileExtension']) ? $params['fileExtension'] : false);
     $compareAgainst = isset($params['compareAgainst']) ? 'test_' . $params['compareAgainst'] : false;
     foreach ($requestUrls as $apiId => $requestUrl) {
         // this is a hack
         if (isset($params['skipGetPageTitles'])) {
             if ($apiId == 'Actions.getPageTitles_day.xml') {
                 continue;
             }
         }
         $this->_testApiUrl($testName . $testSuffix, $apiId, $requestUrl, $compareAgainst);
     }
     // Restore normal purge behavior
     Rules::$purgeDisabledByTests = false;
     // change the language back to en
     if ($this->lastLanguage != 'en') {
         $this->changeLanguage('en');
     }
     if (!empty($this->missingExpectedFiles)) {
         $expectedDir = dirname(reset($this->missingExpectedFiles));
         $this->fail(" ERROR: Could not find expected API output '" . implode("', '", $this->missingExpectedFiles) . "'. 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 ");
     }
     // Display as one error all sub-failures
     if (!empty($this->comparisonFailures)) {
         $messages = '';
         $i = 1;
         foreach ($this->comparisonFailures as $failure) {
             $msg = $failure->getMessage();
             $msg = strtok($msg, "\n");
             $messages .= "\n#" . $i++ . ": " . $msg;
         }
         $messages .= " \n ";
         print $messages;
         $first = reset($this->comparisonFailures);
         throw $first;
     }
     return count($this->comparisonFailures) == 0;
 }