public function testWebArchiving() { if (self::isMysqli() && self::isTravisCI()) { $this->markTestSkipped('Skipping on Mysqli as it randomly fails.'); } $host = Fixture::getRootUrl(); $token = Fixture::getTokenAuth(); $urlTmp = Option::get('piwikUrl'); Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php'); $url = $host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token; $output = Http::sendHttpRequest($url, 600); // ignore random build issues if (empty($output) || strpos($output, \Piwik\CronArchive::NO_ERROR) === false) { $message = "This test has failed. Because it sometimes randomly fails, we skip the test, and ignore this failure.\n"; $message .= "If you see this message often, or in every build, please investigate as this should only be a random and rare occurence!\n"; $message .= "\n\narchive web failed: " . $output . "\n\nurl used: {$url}"; $this->markTestSkipped($message); } if (!empty($urlTmp)) { Option::set('piwikUrl', $urlTmp); } else { Option::delete('piwikUrl'); } $this->assertContains('Starting Piwik reports archiving...', $output); $this->assertContains('Archived website id = 1', $output); $this->assertContains('Done archiving!', $output); $this->compareArchivePhpOutputAgainstExpected($output); }
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; }
public function test_trackingApiWithBulkRequests_viaCurl_withCorrectTokenAuth() { $token_auth = Fixture::getTokenAuth(); \Piwik\Filesystem::deleteAllCacheOnUpdate(); $this->issueBulkTrackingRequest($token_auth, $expectTrackingToSucceed = true); }
protected static function _addLogData() { // tracks visits on the following days: // - 2012-01-09 // - 2012-01-14 // - 2012-01-19 // - 2012-01-24 <--- everything before this date is to be purged // - 2012-01-29 // - 2012-02-03 // - 2012-02-08 // - 2012-02-13 // - 2012-02-18 // - 2012-02-23 // - 2012-02-28 // 6 visits in feb, 5 in jan // following actions are created: // - 'First page view' // - 'Second page view' // - 'SKU2' // - 'Canon SLR' // - 'Electronics & Cameras' // - for every visit (11 visits total): // - http://whatever.com/_{$daysSinceLastVisit} // - http://whatever.com/42/{$daysSinceLastVisit} $start = Date::factory(self::$dateTime); self::$idSite = Fixture::createWebsite('2012-01-01', $ecommerce = 1); APIGoals::getInstance()->addGoal(self::$idSite, 'match all', 'url', 'http', 'contains'); $t = Fixture::getTracker(self::$idSite, $start, $defaultInit = true); $t->enableBulkTracking(); $t->setTokenAuth(Fixture::getTokenAuth()); for ($daysAgo = self::$daysAgoStart; $daysAgo >= 0; $daysAgo -= 5) { $dateTime = $start->subDay($daysAgo)->toString(); $t->setForceVisitDateTime($dateTime); $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)'); // use $daysAgo to make sure new actions are created for every day and aren't used again. // when deleting visits, some of these actions will no longer be referenced in the DB. $t->setUrl("http://whatever.com/_{$daysAgo}"); $t->doTrackPageView('First page view'); $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.05)); $t->setUrl("http://whatever.com/42/{$daysAgo}"); $t->doTrackPageView('Second page view'); $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.1)); $t->setUrl("http://whatever.com/event"); $t->doTrackEvent('Event action', 'event cat', 'daysAgo=' . $daysAgo, 1000); $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2)); $t->addEcommerceItem($sku = 'SKU2', $name = 'Canon SLR', $category = 'Electronics & Cameras', $price = 1500, $quantity = 1); $t->doTrackEcommerceOrder($orderId = '937nsjusu ' . $dateTime, $grandTotal = 1111.11, $subTotal = 1000, $tax = 111, $shipping = 0.11, $discount = 666); } Fixture::checkBulkTrackingResponse($t->doBulkTrack()); }