Skip to content
Extraits de code Groupes Projets
TwoVisitorsTwoWebsitesDifferentDaysTest.php 4,25 ko
Newer Older
  • Learn to ignore specific revisions
  •  * Piwik - free/libre analytics platform
    
     *
     * @link    http://piwik.org
     * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
     */
    
    use Piwik\Tests\SystemTestCase;
    
    use Piwik\Tests\Fixtures\TwoSitesTwoVisitorsDifferentDays;
    
    
    /**
     * tests Tracker several websites, different days.
     * tests API for period=day/week/month/year, requesting data for both websites,
     * and requesting data for last N periods.
     * Also tests a visit that spans over 2 days.
     * And testing empty URL and empty Page name request
     * Also testing a click on a mailto counted as outlink
     * Also testing metadata API for multiple periods
    
     *
     * @group TwoVisitorsTwoWebsitesDifferentDaysTest
     * @group Integration
    
    class TwoVisitorsTwoWebsitesDifferentDaysTest extends SystemTestCase
    
        public static $fixture = null; // initialized below class definition
    
        public function testImagesIncludedInTests()
        {
            $this->alertWhenImagesExcludedFromTests();
        }
    
        /**
         * @dataProvider getApiForTesting
         */
        public function testApi($api, $params)
        {
            $this->runApiTests($api, $params);
        }
    
        protected function getApiToCall()
        {
            return array('VisitFrequency.get',
    
                         'Referrers.getWebsites',
    
                         'Actions.getPageUrls',
                         'Actions.getPageTitles',
                         'Actions.getOutlinks',
                         'Actions.getPageTitle',
                         'Actions.getPageUrl',
                         'VisitorInterest.getNumberOfVisitsByDaysSinceLast');
    
            $idSite1 = self::$fixture->idSite1;
            $dateTime = self::$fixture->dateTime;
    
            $apiToCall = $this->getApiToCall();
    
            $singlePeriodApi = array('VisitsSummary.get', 'Goals.get');
    
            $periods = array('day', 'week', 'month', 'year');
    
            $result = array(
                // Request data for the last 6 periods and idSite=all
    
                array($apiToCall, array('idSite'       => 'all',
    
                                        'setDateLastN' => true)),
    
                // Request data for the last 6 periods and idSite=1
    
                array($apiToCall, array('idSite'       => $idSite1,
                                        'date'         => $dateTime,
    
                                        'periods'      => $periods,
                                        'setDateLastN' => true,
                                        'testSuffix'   => '_idSiteOne_')),
    
    
                // We also test a single period to check that this use case (Reports per idSite in the response) works
    
                array($singlePeriodApi, array('idSite'       => 'all',
    
                                              'periods'      => array('day', 'month'),
                                              'setDateLastN' => false,
                                              'testSuffix'   => '_NotLastNPeriods')),
    
            );
    
            // testing metadata API for multiple periods
            $apiToCall = array_diff($apiToCall, array('Actions.getPageTitle', 'Actions.getPageUrl'));
            foreach ($apiToCall as $api) {
                list($apiModule, $apiAction) = explode(".", $api);
    
                $result[] = array(
    
                    'API.getProcessedReport', array('idSite'       => $idSite1,
                                                    'date'         => $dateTime,
    
                                                    'periods'      => array('day'),
                                                    'setDateLastN' => true,
                                                    'apiModule'    => $apiModule,
                                                    'apiAction'    => $apiAction,
                                                    'testSuffix'   => '_' . $api . '_firstSite_lastN')
    
            return array_merge($result, self::getApiForTestingScheduledReports($dateTime, 'month'));
    
        {
            return 'TwoVisitors_twoWebsites_differentDays';
        }
    
    TwoVisitorsTwoWebsitesDifferentDaysTest::$fixture = new TwoSitesTwoVisitorsDifferentDays();