Example #1
0
 /**
  * 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 = new Collection($api, $testConfig, $api);
     foreach ($testRequests->getRequestUrls() as $apiId => $requestUrl) {
         $this->_testApiUrl($testName . $testConfig->testSuffix, $apiId, $requestUrl, $testConfig->compareAgainst, $testConfig->xmlFieldsToRemove, $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;
 }