Skip to content
Extraits de code Groupes Projets
AutoSuggestAPITest.php 5,70 Kio
<?php
/**
 * Piwik - free/libre analytics platform
 *
 * @link    http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */
namespace Piwik\Tests\System;

use Piwik\API\Request;
use Piwik\Date;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
use Piwik\Tests\Fixtures\ManyVisitsWithGeoIP;
use Piwik\Tests\Framework\Fixture;

/**
 * testing a the auto suggest API for all known segments
 *
 * @group AutoSuggestAPITest
 * @group Core
 */
class AutoSuggestAPITest extends SystemTestCase
{
    public static $fixture = null; // initialized below class definition

    protected static $processed = 0;
    protected static $skipped = array();

    /**
     * @dataProvider getApiForTesting
     */
    public function testApi($api, $params)
    {
        if(self::isPhpVersion53() && self::isTravisCI()) {
            $this->markTestSkipped("Skipping this test as it seg faults on php 5.3 (bug triggered on travis)");
        }

        $this->runApiTests($api, $params);
    }

    public function getApiForTesting()
    {
        // we will test all segments from all plugins
        Fixture::loadAllPlugins();

        $idSite = self::$fixture->idSite;
        $apiForTesting = array();

        $segments = \Piwik\Plugins\API\API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
        foreach ($segments as $segment) {
            $apiForTesting[] = $this->getApiForTestingForSegment($idSite, $segment['segment']);
        }

        if (self::isMysqli() || self::isTravisCI()) {
            // Skip the test on Mysqli as it fails due to rounding Float errors on latitude/longitude
            // then the test started failing after bc19503 and I cannot understand why
            echo "Skipped test \n";
        } else {
            $apiForTesting[] = array('Live.getLastVisitsDetails',
                                     array('idSite' => $idSite,
                                           'date'   => '1998-07-12,today',
                                           'period' => 'range',
                                           'otherRequestParameters' => array('filter_limit' => 1000)));

        }
        return $apiForTesting;
    }

    /**
     * @param $idSite