diff options
-rw-r--r-- | tests/PHPUnit/System/AutoSuggestAPITest.php | 19 | ||||
-rwxr-xr-x | tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php | 11 |
2 files changed, 19 insertions, 11 deletions
diff --git a/tests/PHPUnit/System/AutoSuggestAPITest.php b/tests/PHPUnit/System/AutoSuggestAPITest.php index 22780af180..d4d848a9a7 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 e76be8f1dc..9cbc606a1f 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(); |