public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // note: not sure why I have to manually install plugin
     \Piwik\Plugin\Manager::getInstance()->loadPlugin('CustomAlerts')->install();
     $result = Fixture::updateDatabase();
     if ($result === false) {
         throw new \Exception("Failed to update pre-2.0 database (nothing to update).");
     }
     // truncate log tables so old data won't be re-archived
     foreach (array('log_visit', 'log_link_visit_action', 'log_conversion', 'log_conversion_item') as $table) {
         Db::query("TRUNCATE TABLE " . Common::prefixTable($table));
     }
     // add two visits from same visitor on dec. 29
     $t = Fixture::getTracker(1, '2012-12-29 01:01:30', $defaultInit = true);
     $t->setUrl('http://site.com/index.htm');
     $t->setIp('136.5.3.2');
     Fixture::checkResponse($t->doTrackPageView('incredible title!'));
     $t->setForceVisitDateTime('2012-12-29 03:01:30');
     $t->setUrl('http://site.com/other/index.htm');
     $t->DEBUG_APPEND_URL = '&_idvc=2';
     // make sure visit is marked as returning
     Fixture::checkResponse($t->doTrackPageView('other incredible title!'));
     // launch archiving
     VisitFrequencyApi::getInstance()->get(1, 'year', '2012-12-29');
 }
예제 #2
0
파일: APITest.php 프로젝트: a4tunado/piwik
 public function setUp()
 {
     parent::setUp();
     $this->api = API::getInstance();
     $this->setSuperUser();
     $this->createSite();
 }
예제 #3
0
 public function setUp()
 {
     parent::setUp();
     $application = new Console();
     $application->setAutoExit(false);
     $this->applicationTester = new ApplicationTester($application);
     Config::unsetInstance();
 }
예제 #4
0
 public function setUp()
 {
     parent::setUp();
     $this->cliMulti = new CliMulti();
     $this->authToken = Fixture::getTokenAuth();
     $this->urls = array('getAnswerToLife' => $this->completeUrl('?module=API&method=ExampleAPI.getAnswerToLife&format=JSON'), 'getPiwikVersion' => $this->completeUrl('?module=API&method=API.getPiwikVersion&format=JSON'));
     $this->responses = array('getAnswerToLife' => '{"value":42}', 'getPiwikVersion' => '{"value":"' . Version::VERSION . '"}');
     \Piwik\Common::$isCliMode = true;
 }
예제 #5
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $extraSite = Fixture::createWebsite(self::$fixture->dateTime, $ecommerce = 1, "the site");
     Piwik::addAction("ArchiveProcessor.Parameters.getIdSites", function (&$sites, $period) use($extraSite) {
         if (reset($sites) == $extraSite) {
             $sites = array(1, 2, 3);
         }
     });
     Config::getInstance()->General['enable_processing_unique_visitors_multiple_sites'] = 1;
 }
예제 #6
0
 protected function tearDown()
 {
     parent::tearDown();
 }
예제 #7
0
 public function test_getSettingsForCurrentUser_shouldReturnAllSettingsIfEnoughPermissionsAndSortThemBySettingOrder()
 {
     if (\Piwik\Tests\IntegrationTestCase::isPhpVersion53()) {
         $this->markTestSkipped('does not pass on PHP 5.3.3');
     }
     $this->setSuperUser();
     $this->addSystemSetting('mysystemsetting1', 'mytitle1');
     $this->addSystemSetting('mysystemsetting2', 'mytitle2');
     $this->addUserSetting('myusersetting2', 'mytitle6');
     $this->addSystemSetting('mysystemsetting3', 'mytitle3');
     $this->addSystemSetting('mysystemsetting4', 'mytitle4');
     $this->addUserSetting('myusersetting1', 'mytitle5');
     $expected = array('myusersetting2', 'myusersetting1', 'mysystemsetting1', 'mysystemsetting2', 'mysystemsetting3', 'mysystemsetting4');
     $this->assertEquals($expected, array_keys($this->settings->getSettingsForCurrentUser()));
 }
예제 #8
0
 private function normalizeEncodingPhp533($apiResponse)
 {
     if (!IntegrationTestCase::isPhpVersion53() || strpos($apiResponse, '<result') === false) {
         return $apiResponse;
     }
     return str_replace('&amp;#039;', "'", $apiResponse);
 }
예제 #9
0
파일: ApiTest.php 프로젝트: a4tunado/piwik
 public function setUp()
 {
     parent::setUp();
     $this->api = API::getInstance();
 }
예제 #10
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     Config::getInstance()->General['pivot_by_filter_enable_fetch_by_segment'] = 1;
 }
예제 #11
0
 public function tearDown()
 {
     parent::tearDown();
     Manager::getInstance()->deleteAll();
     Option::clearCache();
     Site::clearCache();
     Cache::deleteTrackerCache();
     ArchiveTableCreator::clear();
     $tempTableName = Common::prefixTable(LogDataPurger::TEMP_TABLE_NAME);
     Db::query("DROP TABLE IF EXISTS " . $tempTableName);
 }
예제 #12
0
 /**
  * Given a list of default parameters to set, returns the URLs of APIs to call
  * If any API was specified in $this->apiNotToCall we ensure only these are tested.
  * If any API is set as excluded (see list below) then it will be ignored.
  *
  * @param array $parametersToSet Parameters to set in api call
  * @param array $formats         Array of 'format' to fetch from API
  * @param array $periods         Array of 'period' to query API
  * @param bool  $supertableApi
  * @param bool  $setDateLastN    If set to true, the 'date' parameter will be rewritten to query instead a range of dates, rather than one period only.
  * @param bool|string $language        2 letter language code, defaults to default piwik language
  * @param bool|string $fileExtension
  *
  * @throws Exception
  *
  * @return array of API URLs query strings
  */
 protected function generateApiUrlPermutations($parametersToSet)
 {
     $formats = array($this->testConfig->format);
     $originalDate = $parametersToSet['date'];
     $requestUrls = array();
     $apiMetadata = new DocumentationGenerator();
     // Get the URLs to query against the API for all functions starting with get*
     foreach ($this->getAllApiMethods() as $apiMethodInfo) {
         list($class, $moduleName, $methodName) = $apiMethodInfo;
         $apiId = $moduleName . '.' . $methodName;
         foreach ($this->testConfig->periods as $period) {
             $parametersToSet['period'] = $period;
             // If date must be a date range, we process this date range by adding 6 periods to it
             if ($this->testConfig->setDateLastN) {
                 if (!isset($parametersToSet['dateRewriteBackup'])) {
                     $parametersToSet['dateRewriteBackup'] = $parametersToSet['date'];
                 }
                 $lastCount = $this->testConfig->setDateLastN;
                 $secondDate = date('Y-m-d', strtotime("+{$lastCount} " . $period . "s", strtotime($originalDate)));
                 $parametersToSet['date'] = $originalDate . ',' . $secondDate;
             }
             // Set response language
             if ($this->testConfig->language !== false) {
                 $parametersToSet['language'] = $this->testConfig->language;
             }
             // set idSubtable if subtable API is set
             if ($this->testConfig->supertableApi !== false) {
                 $request = new Request(array('module' => 'API', 'method' => $this->testConfig->supertableApi, 'idSite' => $parametersToSet['idSite'], 'period' => $parametersToSet['period'], 'date' => $parametersToSet['date'], 'format' => 'php', 'serialize' => 0));
                 $content = $request->process();
                 IntegrationTestCase::assertApiResponseHasNoError($content);
                 // find first row w/ subtable
                 foreach ($content as $row) {
                     if (isset($row['idsubdatatable'])) {
                         $parametersToSet['idSubtable'] = $row['idsubdatatable'];
                         break;
                     }
                 }
                 // if no subtable found, throw
                 if (!isset($parametersToSet['idSubtable'])) {
                     throw new Exception("Cannot find subtable to load for {$apiId} in {$this->testConfig->supertableApi}.");
                 }
             }
             // Generate for each specified format
             foreach ($formats as $format) {
                 $parametersToSet['format'] = $format;
                 $parametersToSet['hideIdSubDatable'] = 1;
                 $parametersToSet['serialize'] = 1;
                 $exampleUrl = $apiMetadata->getExampleUrl($class, $methodName, $parametersToSet);
                 if ($exampleUrl === false) {
                     continue;
                 }
                 // Remove the first ? in the query string
                 $exampleUrl = substr($exampleUrl, 1);
                 $apiRequestId = $apiId;
                 if (strpos($exampleUrl, 'period=') !== false) {
                     $apiRequestId .= '_' . $period;
                 }
                 $apiRequestId .= '.' . $format;
                 if ($this->testConfig->fileExtension) {
                     $apiRequestId .= '.' . $this->testConfig->fileExtension;
                 }
                 $requestUrls[$apiRequestId] = UrlHelper::getArrayFromQueryString($exampleUrl);
             }
         }
     }
     return $requestUrls;
 }
예제 #13
0
 public function setUp()
 {
     parent::setUp();
     $this->model = new Model();
 }
예제 #14
0
 public static function setUpBeforeClass()
 {
     self::setUpConfigOptions();
     parent::setUpBeforeClass();
 }
예제 #15
0
 public function tearDown()
 {
     parent::tearDown();
     // reset that value after the test
     Proxy::getInstance()->setHideIgnoredFunctions(true);
 }
예제 #16
0
파일: Fixture.php 프로젝트: igorclark/piwik
 /**
  * @return string
  */
 protected static function getPythonBinary()
 {
     if (\Piwik\SettingsServer::isWindows()) {
         return "C:\\Python27\\python.exe";
     }
     if (IntegrationTestCase::isTravisCI()) {
         return 'python2.6';
     }
     return 'python';
 }
 public static function setUpBeforeClass()
 {
     self::$fixture->dateTime = Date::factory('today')->getDateTime();
     parent::setUpBeforeClass();
 }
예제 #18
0
 public function tearDown()
 {
     parent::tearDownAfterClass();
 }