diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index 44deebf1ce1..1d25793433e 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -669,6 +669,7 @@ private function reloadPlugins() $this->pluginsToLoad = array_unique($this->pluginsToLoad); + $pluginsToPostPendingEventsTo = array(); foreach ($this->pluginsToLoad as $pluginName) { if (!$this->isPluginLoaded($pluginName) && !$this->isPluginThirdPartyAndBogus($pluginName) @@ -678,9 +679,14 @@ private function reloadPlugins() continue; } - EventDispatcher::getInstance()->postPendingEventsTo($newPlugin); + $pluginsToPostPendingEventsTo[] = $newPlugin; } } + + // post pending events after all plugins are successfully loaded + foreach ($pluginsToPostPendingEventsTo as $plugin) { + EventDispatcher::getInstance()->postPendingEventsTo($plugin); + } } public function getIgnoredBogusPlugins() diff --git a/core/View.php b/core/View.php index 8505aafe3fb..4afea486616 100644 --- a/core/View.php +++ b/core/View.php @@ -134,9 +134,14 @@ public function __construct($templateFile) $this->initializeTwig(); $this->piwik_version = Version::VERSION; - $this->piwikUrl = SettingsPiwik::getPiwikUrl(); $this->userLogin = Piwik::getCurrentUserLogin(); $this->isSuperUser = Access::getInstance()->hasSuperUserAccess(); // TODO: redundancy w/ userIsSuperUser + + try { + $this->piwikUrl = SettingsPiwik::getPiwikUrl(); + } catch (Exception $ex) { + // pass (occurs when DB cannot be connected to, perhaps piwik URL cache should be stored in config file...) + } } /** @@ -337,8 +342,8 @@ public function assign($var, $value = null) */ static public function clearCompiledTemplates() { - $view = new View(null); - $view->twig->clearTemplateCache(); + $twig = new Twig(); + $twig->getTwigEnvironment()->clearTemplateCache(); } /** diff --git a/tests/PHPUnit/UI b/tests/PHPUnit/UI index f18a9102aa4..f744d26a33b 160000 --- a/tests/PHPUnit/UI +++ b/tests/PHPUnit/UI @@ -1 +1 @@ -Subproject commit f18a9102aa434db63bfdd2c6d47d9ee4fca77581 +Subproject commit f744d26a33b64570a039d65c23c7dfaaff1a245a diff --git a/tests/lib/screenshot-testing/support/app.js b/tests/lib/screenshot-testing/support/app.js index ee9ad303140..8a67e68ed6f 100644 --- a/tests/lib/screenshot-testing/support/app.js +++ b/tests/lib/screenshot-testing/support/app.js @@ -105,7 +105,7 @@ Application.prototype.loadTestModules = function () { // configure suites (auto-add fixture setup/teardown) mocha.suite.suites.forEach(function (suite) { - var fixture = suite.fixture || 'UITestFixture'; + var fixture = typeof suite.fixture === 'undefined' ? 'UITestFixture' : suite.fixture; suite.beforeAll(function (done) { testEnvironment.setupFixture(fixture, done); @@ -115,6 +115,11 @@ Application.prototype.loadTestModules = function () { suite._beforeAll.unshift(suite._beforeAll.pop()); suite.afterAll(function (done) { + if (!fixture) { + done(); + return; + } + testEnvironment.teardownFixture(fixture, done); }); }); diff --git a/tests/lib/screenshot-testing/support/setupDatabase.php b/tests/lib/screenshot-testing/support/setupDatabase.php index e91e4ffd16f..e4efccb0e74 100644 --- a/tests/lib/screenshot-testing/support/setupDatabase.php +++ b/tests/lib/screenshot-testing/support/setupDatabase.php @@ -20,19 +20,21 @@ require_once "PHPUnit/Autoload.php"; require_once dirname(__FILE__) . "/../../../PHPUnit/bootstrap.php"; -if (!class_exists($fixtureClass)) { - $fixtureClass = "Piwik\\Tests\\Fixtures\\$fixtureClass"; -} +if (!empty($fixtureClass)) { + if (!class_exists($fixtureClass)) { + $fixtureClass = "Piwik\\Tests\\Fixtures\\$fixtureClass"; + } -$fixture = new $fixtureClass(); -if (in_array("--persist-fixture-data", $argv)) { - $fixture->persistFixtureData = true; -} -if (in_array("--drop", $argv)) { - $fixture->resetPersistedFixture = true; + $fixture = new $fixtureClass(); + if (in_array("--persist-fixture-data", $argv)) { + $fixture->persistFixtureData = true; + } + if (in_array("--drop", $argv)) { + $fixture->resetPersistedFixture = true; + } + $fixture->printToScreen = true; + $fixture->performSetUp(""); } -$fixture->printToScreen = true; -$fixture->performSetUp(""); // make sure symbolic links exist (phantomjs doesn't support symlink-ing yet) foreach (array('libs', 'plugins', 'tests', 'piwik.js') as $linkName) { diff --git a/tests/lib/screenshot-testing/support/test-environment.js b/tests/lib/screenshot-testing/support/test-environment.js index c371d444e31..7096b2af26b 100644 --- a/tests/lib/screenshot-testing/support/test-environment.js +++ b/tests/lib/screenshot-testing/support/test-environment.js @@ -88,7 +88,7 @@ TestingEnvironment.prototype.setupFixture = function (fixtureClass, done) { console.log(" Setting up fixture " + fixtureClass + "..."); var setupFile = path.join("./support", "setupDatabase.php"), - processArgs = [setupFile, "--server=" + JSON.stringify(config.phpServer), "--fixture=" + fixtureClass]; + processArgs = [setupFile, "--server=" + JSON.stringify(config.phpServer), "--fixture=" + (fixtureClass || "")]; if (options['persist-fixture-data']) { processArgs.push('--persist-fixture-data');