/** * 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)); }
/** * 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); }