diff --git a/tests/PHPUnit/System/AutoSuggestAPITest.php b/tests/PHPUnit/System/AutoSuggestAPITest.php index 22780af180fcce0c423333ed7393d127a07b917f..d4d848a9a70ed56086c27713966df0006f221bb0 100644 --- a/tests/PHPUnit/System/AutoSuggestAPITest.php +++ b/tests/PHPUnit/System/AutoSuggestAPITest.php @@ -119,6 +119,8 @@ class AutoSuggestAPITest extends SystemTestCase public function getAnotherApiForTesting() { + + $apiForTesting = array(); $segments = \Piwik\Plugins\API\API::getInstance()->getSegmentsMetadata(self::$fixture->idSite); foreach ($segments as $segment) { @@ -143,14 +145,27 @@ class AutoSuggestAPITest extends SystemTestCase { // 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->assertTrue(count(self::$skipped) <= $maximumSegmentsToSkip, 'SKIPPED ' . count(self::$skipped) . ' segments --> some segments had no "auto-suggested values" + $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->assertTrue(self::$processed >= $minimumSegmentsToTest, $message); + $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(); diff --git a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php index e76be8f1dcecea6102a184d5b3f909233e9e6d3a..9cbc606a1f8e8bce1125ec80b54929b25aae1a16 100755 --- a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php +++ b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php @@ -7,12 +7,9 @@ */ namespace Piwik\Tests\System; -use Piwik\Plugins\API\API; -use Piwik\Plugins\CustomVariables\Model; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Tests\Fixtures\TwoVisitsWithCustomVariables; use Piwik\Tests\Framework\Fixture; -use Piwik\Tracker\Cache; /** * testing a segment containing all supported fields @@ -50,12 +47,7 @@ class TwoVisitsWithCustomVariablesSegmentMatchNONETest extends SystemTestCase public function getSegmentToTest() { - // Refresh cache for CustomVariables\Model - Cache::clearCacheGeneral(); - Model::install(); - - // Segment matching NONE - $segments = API::getInstance()->getSegmentsMetadata(self::$fixture->idSite); + $segments = AutoSuggestAPITest::getSegmentsMetadata(self::$fixture->idSite); $minimumExpectedSegmentsCount = 55; // as of Piwik 1.12 $this->assertGreaterThan($minimumExpectedSegmentsCount, count($segments)); @@ -93,6 +85,7 @@ class TwoVisitsWithCustomVariablesSegmentMatchNONETest extends SystemTestCase { return 'twoVisitsWithCustomVariables_segmentMatchNONE'; } + } TwoVisitsWithCustomVariablesSegmentMatchNONETest::$fixture = new TwoVisitsWithCustomVariables();