diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Framework/TestCase/SystemTestCase.php | 13 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestCase/UnitTestCase.php | 15 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/ReleaseCheckListTest.php | 8 |
3 files changed, 35 insertions, 1 deletions
diff --git a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php index 20ebb007bb..da1e1dfb23 100644 --- a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php @@ -58,6 +58,19 @@ abstract class SystemTestCase extends TestCase */ public static $fixture; + public function setGroups(array $groups): void + { + $pluginName = explode('\\', get_class($this)); + if (!empty($pluginName[2]) && !empty($pluginName[1]) && $pluginName[1] === 'Plugins') { + // we assume \Piwik\Plugins\PluginName nanmespace... + if (!in_array($pluginName[2], $groups, true)) { + $groups[] = $pluginName[2]; + } + } + + parent::setGroups($groups); + } + public static function setUpBeforeClass(): void { Log::debug("Setting up " . get_called_class()); diff --git a/tests/PHPUnit/Framework/TestCase/UnitTestCase.php b/tests/PHPUnit/Framework/TestCase/UnitTestCase.php index d81f000a3d..56428a92de 100644 --- a/tests/PHPUnit/Framework/TestCase/UnitTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/UnitTestCase.php @@ -26,6 +26,19 @@ abstract class UnitTestCase extends \PHPUnit\Framework\TestCase */ protected $environment; + public function setGroups(array $groups): void + { + $pluginName = explode('\\', get_class($this)); + if (!empty($pluginName[2]) && !empty($pluginName[1]) && $pluginName[1] === 'Plugins') { + // we assume \Piwik\Plugins\PluginName nanmespace... + if (!in_array($pluginName[2], $groups, true)) { + $groups[] = $pluginName[2]; + } + } + + parent::setGroups($groups); + } + public function setUp(): void { parent::setUp(); @@ -41,7 +54,7 @@ abstract class UnitTestCase extends \PHPUnit\Framework\TestCase // make sure the global container exists for the next test case that is executed (since logging can be done // before a test sets up an environment) - $nextTestEnviornment = new Environment($environment = null, array(), $postBootstrappedEvent = false); + $nextTestEnviornment = new Environment($environment = null, array()); $nextTestEnviornment->init(); parent::tearDown(); diff --git a/tests/PHPUnit/Integration/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php index 2f7b258b6d..1b436ecd37 100644 --- a/tests/PHPUnit/Integration/ReleaseCheckListTest.php +++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php @@ -9,6 +9,7 @@ namespace Piwik\Tests\Integration; use Exception; +use PHPUnit\Framework\TestCase; use Piwik\AssetManager\UIAssetFetcher; use Piwik\Config; use Piwik\Container\StaticContainer; @@ -38,6 +39,13 @@ class ReleaseCheckListTest extends \PHPUnit\Framework\TestCase parent::setUp(); } + public function test_TestCaseHasSetGroupsMethod() + { + // refs https://github.com/matomo-org/matomo/pull/16615 ensures setGroups method still exists in phpunit + // checking this way as it is not an official API + $this->assertTrue(method_exists(TestCase::class,'setGroups')); + } + public function test_woff2_fileIsUpToDate() { link(PIWIK_INCLUDE_PATH . "/plugins/Morpheus/fonts/matomo.ttf", "temp.ttf"); |