setMockNow(); } public function getApiForTesting() { self::$fixture->setMockNow(); $testcases = []; foreach (['all' => '', '1' => '_ast', '2' => '_utc'] as $idSite => $appendix) { if ($idSite !== 'all') { // Note: Querying idSites=all will always use default timezone (UTC), so this is not relevant for timezone testing $testcases[] = [ 'Live.getLastVisitsDetails', [ 'idSite' => $idSite, 'date' => 'yesterday', 'period' => 'day', 'otherRequestParameters' => [ 'filter_limit' => 100, 'doNotFetchActions' => 1, ], 'xmlFieldsToRemove' => [ 'idVisit', ], 'testSuffix' => '_yesterday' . $appendix, ], ]; $testcases[] = [ 'Live.getLastVisitsDetails', [ 'idSite' => $idSite, 'date' => 'today', 'period' => 'day', 'otherRequestParameters' => [ 'filter_limit' => 100, 'doNotFetchActions' => 1, ], 'xmlFieldsToRemove' => [ 'idVisit', ], 'testSuffix' => '_today' . $appendix, ], ]; $testcases[] = [ 'Live.getLastVisitsDetails', [ 'idSite' => $idSite, 'date' => Date::yesterday() . ',' . Date::today(), 'period' => 'range', 'otherRequestParameters' => [ 'filter_limit' => 100, 'doNotFetchActions' => 1, ], 'xmlFieldsToRemove' => [ 'idVisit', ], 'testSuffix' => '_range' . $appendix, ], ]; $testcases[] = [ 'Live.getLastVisitsDetails', [ 'idSite' => $idSite, 'date' => Date::yesterday() . ',' . Date::today(), 'period' => 'range', 'otherRequestParameters' => [ 'filter_limit' => 100, 'doNotFetchActions' => 1, ], 'segment' => 'pageUrl=@example.org;pageUrl=@index', 'xmlFieldsToRemove' => [ 'idVisit', ], 'testSuffix' => '_range' . $appendix, // using same suffix as results are the same ], ]; $testcases[] = [ 'Live.getLastVisitsDetails', [ 'idSite' => $idSite, 'date' => Date::yesterday() . ',' . Date::today(), 'period' => 'range', 'otherRequestParameters' => [ 'filter_limit' => 100, 'doNotFetchActions' => 1, ], 'segment' => 'pageUrl=@example.org;pageUrl!@index', 'xmlFieldsToRemove' => [ 'idVisit', ], 'testSuffix' => '_range_nomatch' . $appendix, // this segment should match nothing ], ]; // Testing Transitions explicitly, as it builds the sql query itself, and doesn't use archiving $testcases[] = [ 'Transitions.getTransitionsForAction', [ 'idSite' => $idSite, 'date' => 'today', 'period' => 'day', 'otherRequestParameters' => [ 'actionName' => 'http://example.org/index.htm', 'actionType' => 'url', ], 'segment' => 'pageUrl=@example.org;pageUrl!@index', 'testSuffix' => '_today_nomatch' . $appendix, // this segment should match nothing 'xmlFieldsToRemove' => [ 'date', ], ], ]; $testcases[] = [ 'Transitions.getTransitionsForAction', [ 'idSite' => $idSite, 'date' => 'today', 'period' => 'day', 'otherRequestParameters' => [ 'actionName' => 'http://example.org/index.htm', 'actionType' => 'url', ], 'testSuffix' => '_today' . $appendix, // this segment should match nothing 'xmlFieldsToRemove' => [ 'date', ], ], ]; } $testcases[] = [ 'VisitsSummary.get', [ 'idSite' => $idSite, 'date' => 'yesterday', 'period' => 'day', 'testSuffix' => '_yesterday' . $appendix, ], ]; $testcases[] = [ 'VisitsSummary.get', [ 'idSite' => $idSite, 'date' => 'yesterday', 'period' => 'day', 'segment' => 'pageUrl=@example.org;pageUrl=@index', 'testSuffix' => '_yesterday' . $appendix, // using same suffix as results are the same ], ]; $testcases[] = [ 'VisitsSummary.get', [ 'idSite' => $idSite, 'date' => 'yesterday', 'period' => 'day', 'segment' => 'pageUrl=@example.org;pageUrl!@index', 'testSuffix' => '_yesterday_nomatch' . $appendix, // this segment should match nothing ], ]; $testcases[] = [ 'VisitsSummary.get', [ 'idSite' => $idSite, 'date' => 'today', 'period' => 'day', 'testSuffix' => '_today' . $appendix, ], ]; $testcases[] = [ 'VisitsSummary.get', [ 'idSite' => $idSite, 'date' => 'today', 'period' => 'day', 'segment' => 'pageUrl=@example.org;pageUrl=@index', 'testSuffix' => '_today' . $appendix, // using same suffix as results are the same ], ]; $testcases[] = [ 'VisitsSummary.get', [ 'idSite' => $idSite, 'date' => 'today', 'period' => 'day', 'segment' => 'pageUrl=@example.org;pageUrl!@index', 'testSuffix' => '_today_nomatch' . $appendix, // this segment should match nothing ], ]; } Date::$now = null; return $testcases; } /** * @dataProvider getApiForTesting */ public function testApi($api, $params) { $this->runApiTests($api, $params); } } TimezonesTest::$fixture = new VisitsInDifferentTimezones();