public function getSegmentToTest()
 {
     $segments = AutoSuggestAPITest::getSegmentsMetadata();
     $minimumExpectedSegmentsCount = 55;
     // as of Piwik 1.12
     $this->assertGreaterThan($minimumExpectedSegmentsCount, count($segments));
     $segmentExpression = array();
     $seenVisitorId = false;
     foreach ($segments as $segment) {
         $value = 'campaign';
         if ($segment == 'visitorId') {
             $seenVisitorId = true;
             $value = '34c31e04394bdc63';
         }
         if ($segment == 'visitEcommerceStatus') {
             $value = 'none';
         }
         if ($segment == 'actionType') {
             $value = 'pageviews';
         }
         $matchNone = $segment . '!=' . $value;
         // deviceType != campaign matches ALL visits, but we want to match None
         if ($segment == 'deviceType') {
             $matchNone = $segment . '==car%20browser';
         }
         $segmentExpression[] = $matchNone;
     }
     $segment = implode(";", $segmentExpression);
     // just checking that this segment was tested (as it has the only visible to admin flag)
     $this->assertTrue($seenVisitorId);
     $this->assertGreaterThan(100, strlen($segment));
     return $segment;
 }
            }
            $apiForTesting[] = array('VisitsSummary.get', array('idSite' => self::$fixture->idSite, 'date' => date("Y-m-d", strtotime(self::$fixture->dateTime)) . ',today', 'period' => 'range', 'testSuffix' => '_' . $segment['segment'], 'segmentToComplete' => $segment['segment']));
        }
        return $apiForTesting;
    }
    /**
     * @depends      testAnotherApi
     */
    public function testCheckOtherTestsWereComplete()
    {
        // Check that only a few haven't been tested specifically (these are all custom variables slots since we only test slot 1, 2, 5 (see the fixture) and example dimension slots)
        $maximumSegmentsToSkip = 16;
        $this->assertLessThan($maximumSegmentsToSkip, count(self::$skipped), 'SKIPPED ' . count(self::$skipped) . ' segments --> some segments had no "auto-suggested values"
            but we should try and test the autosuggest for all new segments. Segments skipped were: ' . implode(', ', self::$skipped));
        // and check that most others have been tested
        $minimumSegmentsToTest = 46;
        $message = 'PROCESSED ' . self::$processed . ' segments --> it seems some segments "auto-suggested values" haven\'t been tested as we were expecting. ';
        $this->assertGreaterThan($minimumSegmentsToTest, self::$processed, $message);
    }
    public static function getSegmentsMetadata($idSite)
    {
        // Refresh cache for CustomVariables\Model
        Cache::clearCacheGeneral();
        \Piwik\Plugins\CustomVariables\Model::install();
        // Segment matching NONE
        $segments = \Piwik\Plugins\API\API::getInstance()->getSegmentsMetadata($idSite);
        return $segments;
    }
}
AutoSuggestAPITest::$fixture = new ManyVisitsWithGeoIP();
AutoSuggestAPITest::$fixture->dateTime = Date::yesterday()->subDay(30)->getDatetime();