/** * NOTE: This test must be last since the new sites that get added are added in * random order. */ public function testDynamicResolverSitesCreated() { self::$fixture->logVisitsWithDynamicResolver(); // reload access so new sites are viewable Access::getInstance()->setSuperUserAccess(true); // make sure sites aren't created twice $piwikDotNet = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net'); $this->assertEquals(1, count($piwikDotNet)); $anothersiteDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://anothersite.com'); $this->assertEquals(1, count($anothersiteDotCom)); $whateverDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://whatever.com'); $this->assertEquals(1, count($whateverDotCom)); }
public function getApiForTesting() { $results = array(); foreach (self::$fixture->getDefaultSegments() as $segmentName => $info) { $results[] = array('VisitsSummary.get', array('idSite' => 'all', 'date' => '2012-08-09', 'periods' => array('day', 'week', 'month', 'year'), 'segment' => $info['definition'], 'testSuffix' => '_' . $segmentName)); } // API Call Without segments $results[] = array('VisitsSummary.get', array('idSite' => 'all', 'date' => '2012-08-09', 'periods' => array('day', 'month', 'year', 'week'))); $results[] = array('VisitsSummary.get', array('idSite' => 'all', 'date' => '2012-08-09', 'periods' => array('day', 'week', 'month', 'year'), 'segment' => 'browserCode==EP', 'testSuffix' => '_nonPreArchivedSegment')); $segments = array(ManySitesImportedLogs::SEGMENT_PRE_ARCHIVED, ManySitesImportedLogs::SEGMENT_PRE_ARCHIVED_CONTAINS_ENCODED); foreach ($segments as $segment) { // Test with a pre-processed segment $results[] = array(array('VisitsSummary.get', 'Live.getLastVisitsDetails', 'VisitFrequency.get'), array('idSite' => '1', 'date' => '2012-08-09', 'periods' => array('day', 'year'), 'segment' => $segment, 'testSuffix' => '_preArchivedSegment', 'otherRequestParameters' => array('hideColumns' => 'latitude,longitude'))); } return $results; }
public function setUp() { parent::setUp(); $this->trackVisitsForRealtimeMap(Date::factory('2012-08-11 11:22:33'), $createSeperateVisitors = false); $this->addAnnotations(); $this->trackVisitsForRealtimeMap($this->now); }
/** * NOTE: This test must be last since the new sites that get added are added in * random order. * NOTE: This test combines two tests in order to avoid executing the log importer another time. * If the log importer were refactored, the invalid requests test could be a unit test in * python. */ public function test_LogImporter_CreatesSitesWhenDynamicResolverUsed_AndReportsOnInvalidRequests() { $this->simulateInvalidTrackerRequest(); $output = self::$fixture->logVisitsWithDynamicResolver($maxPayloadSize = 3); // reload access so new sites are viewable Access::getInstance()->setSuperUserAccess(true); // make sure sites aren't created twice $piwikDotNet = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net'); $this->assertEquals(1, count($piwikDotNet)); $anothersiteDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://anothersite.com'); $this->assertEquals(1, count($anothersiteDotCom)); $whateverDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://whatever.com'); $this->assertEquals(1, count($whateverDotCom)); // make sure invalid requests are reported correctly $this->assertContains('The Piwik tracker identified 2 invalid requests on lines: 10, 11', $output); $this->assertContains("The following lines were not tracked by Piwik, either due to a malformed tracker request or error in the tracker:\n\n10, 11", $output); }