Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2022-10-17 10:33:55 +0300
committerGitHub <noreply@github.com>2022-10-17 10:33:55 +0300
commit32bb2f99e59ba410b01832f789bc591cad6acf8c (patch)
tree960bce39a7813762473ed9bd70b9380186e676a9
parent1409691735dc8fa0d6483a3d61471cd874745ad3 (diff)
Ensure plugin updates are executed when setting up UITestFixture (#19825)
* ensure plugin updates are executed when setting up UITestFixture * Skip dispatching events when setting up UITestFixture to prevent segfault * update TagManager submodule * cs
-rw-r--r--core/EventDispatcher.php6
m---------plugins/TagManager0
-rw-r--r--tests/PHPUnit/Fixtures/UITestFixture.php24
-rw-r--r--tests/PHPUnit/Framework/Fixture.php4
4 files changed, 31 insertions, 3 deletions
diff --git a/core/EventDispatcher.php b/core/EventDispatcher.php
index bb029af6af..97d6595304 100644
--- a/core/EventDispatcher.php
+++ b/core/EventDispatcher.php
@@ -60,6 +60,8 @@ class EventDispatcher
private $pluginHooks = array();
+ public static $_SKIP_EVENTS_IN_TESTS = false;
+
/**
* Constructor.
*/
@@ -87,6 +89,10 @@ class EventDispatcher
*/
public function postEvent($eventName, $params, $pending = false, $plugins = null)
{
+ if (self::$_SKIP_EVENTS_IN_TESTS) {
+ return;
+ }
+
if ($pending) {
$this->pendingEvents[] = array($eventName, $params);
}
diff --git a/plugins/TagManager b/plugins/TagManager
-Subproject 2edec7e4ba8b1ae3b7046d0e937436baaa49488
+Subproject 485dc7c15f761d44e4ae35127502f4ea5791b3f
diff --git a/tests/PHPUnit/Fixtures/UITestFixture.php b/tests/PHPUnit/Fixtures/UITestFixture.php
index 65fa4b8273..4a742681d2 100644
--- a/tests/PHPUnit/Fixtures/UITestFixture.php
+++ b/tests/PHPUnit/Fixtures/UITestFixture.php
@@ -20,10 +20,12 @@ use Piwik\DataTable\Row;
use Piwik\Date;
use Piwik\Db;
use Piwik\DbHelper;
+use Piwik\EventDispatcher;
use Piwik\Filesystem;
use Piwik\FrontController;
use Piwik\Option;
use Piwik\Plugin\Dimension\VisitDimension;
+use Piwik\Plugin\Manager;
use Piwik\Plugin\ProcessedMetric;
use Piwik\Plugin\Report;
use Piwik\Plugins\API\API;
@@ -72,11 +74,31 @@ class UITestFixture extends SqlDump
{
parent::setUp();
- self::resetPluginsInstalledConfig();
+ // We need to disable events for running updates below.
+ // Otherwise PHP will run into a segfault when trying to execute updates for plugins.
+ EventDispatcher::$_SKIP_EVENTS_IN_TESTS = true;
+
+ // fetch the installed versions of all plugins from options table
+ $pluginVersions = Option::getLike('version_%');
+ $plugins = [];
+
+ foreach ($pluginVersions as $pluginName => $version) {
+ $name = substr($pluginName, 8);
+ if (Manager::getInstance()->isValidPluginName($name) && Manager::getInstance()->isPluginInFilesystem($name)) {
+ $plugins[] = $name;
+ }
+ }
+
+ self::resetPluginsInstalledConfig($plugins);
+
self::updateDatabase();
+
self::installAndActivatePlugins($this->getTestEnvironment());
+
self::updateDatabase();
+ EventDispatcher::$_SKIP_EVENTS_IN_TESTS = false;
+
// make sure site has an early enough creation date (for period selector tests)
Db::get()->update(
Common::prefixTable("site"),
diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php
index fbae8eead2..ab2030f16a 100644
--- a/tests/PHPUnit/Framework/Fixture.php
+++ b/tests/PHPUnit/Framework/Fixture.php
@@ -436,11 +436,11 @@ class Fixture extends \PHPUnit\Framework\Assert
Manager::getInstance()->loadPluginTranslations();
}
- protected static function resetPluginsInstalledConfig()
+ protected static function resetPluginsInstalledConfig($plugins = [])
{
$config = self::getConfig();
$installed = $config->PluginsInstalled;
- $installed['PluginsInstalled'] = [];
+ $installed['PluginsInstalled'] = $plugins;
$config->PluginsInstalled = $installed;
}