diff options
-rw-r--r-- | core/EventDispatcher.php | 37 | ||||
-rwxr-xr-x | tests/PHPUnit/Framework/TestCase/UnitTestCase.php | 1 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Tracker/Handler/FactoryTest.php | 7 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Tracker/RequestSetTest.php | 1 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Tracker/RequestTest.php | 7 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Tracker/Visit/FactoryTest.php | 7 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Tracker/Visit2Test.php | 6 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/TrackerTest.php | 1 | ||||
-rw-r--r-- | tests/PHPUnit/Unit/AssetManagerTest.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/Unit/TrackerTest.php | 6 |
10 files changed, 10 insertions, 65 deletions
diff --git a/core/EventDispatcher.php b/core/EventDispatcher.php index 47ae487cde..2955e5b03f 100644 --- a/core/EventDispatcher.php +++ b/core/EventDispatcher.php @@ -9,16 +9,23 @@ namespace Piwik; +use Piwik\Container\StaticContainer; use Piwik\Plugin; /** * This class allows code to post events from anywhere in Piwik and for * plugins to associate callbacks to be executed when events are posted. - * - * @method static \Piwik\EventDispatcher getInstance() */ -class EventDispatcher extends Singleton +class EventDispatcher { + /** + * @return EventDispatcher + */ + public static function getInstance() + { + return StaticContainer::get('Piwik\EventDispatcher'); + } + // implementation details for postEvent const EVENT_CALLBACK_GROUP_FIRST = 0; const EVENT_CALLBACK_GROUP_SECOND = 1; @@ -158,30 +165,6 @@ class EventDispatcher extends Singleton } /** - * Removes all registered extra observers for an event name. Only used for testing. - * - * @param string $eventName - */ - public function clearObservers($eventName) - { - $this->extraObservers[$eventName] = array(); - } - - /** - * Removes all registered extra observers. Only used for testing. - */ - public function clearAllObservers() - { - foreach ($this->extraObservers as $eventName => $eventObservers) { - if (strpos($eventName, 'Log.format') === 0) { - continue; - } - - $this->extraObservers[$eventName] = array(); - } - } - - /** * Re-posts all pending events to the given plugin. * * @param Plugin $plugin diff --git a/tests/PHPUnit/Framework/TestCase/UnitTestCase.php b/tests/PHPUnit/Framework/TestCase/UnitTestCase.php index 275f91eed8..fa7e987954 100755 --- a/tests/PHPUnit/Framework/TestCase/UnitTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/UnitTestCase.php @@ -35,7 +35,6 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase $this->initEnvironment(); File::reset(); - EventDispatcher::getInstance()->clearAllObservers(); } public function tearDown() diff --git a/tests/PHPUnit/Integration/Tracker/Handler/FactoryTest.php b/tests/PHPUnit/Integration/Tracker/Handler/FactoryTest.php index fd77913bfa..55abe63c73 100644 --- a/tests/PHPUnit/Integration/Tracker/Handler/FactoryTest.php +++ b/tests/PHPUnit/Integration/Tracker/Handler/FactoryTest.php @@ -23,13 +23,6 @@ use Piwik\Tracker\Handler\Factory; */ class FactoryTest extends IntegrationTestCase { - - public function tearDown() - { - EventDispatcher::getInstance()->clearObservers('Tracker.initRequestSet'); - parent::tearDown(); - } - public function test_make_shouldCreateDefaultInstance() { $handler = Factory::make(); diff --git a/tests/PHPUnit/Integration/Tracker/RequestSetTest.php b/tests/PHPUnit/Integration/Tracker/RequestSetTest.php index a551149fa0..6049ad6245 100644 --- a/tests/PHPUnit/Integration/Tracker/RequestSetTest.php +++ b/tests/PHPUnit/Integration/Tracker/RequestSetTest.php @@ -64,7 +64,6 @@ class RequestSetTest extends IntegrationTestCase $_GET = $this->get; $_POST = $this->post; - EventDispatcher::getInstance()->clearObservers('Tracker.initRequestSet'); parent::tearDown(); } diff --git a/tests/PHPUnit/Integration/Tracker/RequestTest.php b/tests/PHPUnit/Integration/Tracker/RequestTest.php index fe4ba830ca..32a00aedd5 100644 --- a/tests/PHPUnit/Integration/Tracker/RequestTest.php +++ b/tests/PHPUnit/Integration/Tracker/RequestTest.php @@ -8,7 +8,6 @@ namespace Piwik\Tests\Integration\Tracker; -use Piwik\EventDispatcher; use Piwik\Piwik; use Piwik\Plugins\CustomVariables\CustomVariables; use Piwik\Plugins\UsersManager\API; @@ -52,12 +51,6 @@ class RequestTest extends IntegrationTestCase $this->request = $this->buildRequest(array('idsite' => '1')); } - public function tearDown() - { - EventDispatcher::getInstance()->clearObservers('Request.initAuthenticationObject'); - parent::tearDown(); - } - public function test_getCustomVariablesInVisitScope_ShouldReturnNoCustomVars_IfNoWerePassedInParams() { $this->assertEquals(array(), $this->request->getCustomVariablesInVisitScope()); diff --git a/tests/PHPUnit/Integration/Tracker/Visit/FactoryTest.php b/tests/PHPUnit/Integration/Tracker/Visit/FactoryTest.php index 2cefabc23b..f2e911d66d 100644 --- a/tests/PHPUnit/Integration/Tracker/Visit/FactoryTest.php +++ b/tests/PHPUnit/Integration/Tracker/Visit/FactoryTest.php @@ -24,13 +24,6 @@ use Piwik\Tracker\Visit\Factory; */ class FactoryTest extends IntegrationTestCase { - - public function tearDown() - { - EventDispatcher::getInstance()->clearObservers('Tracker.makeNewVisitObject'); - parent::tearDown(); - } - public function test_make_shouldCreateDefaultInstance() { $visit = Factory::make(); diff --git a/tests/PHPUnit/Integration/Tracker/Visit2Test.php b/tests/PHPUnit/Integration/Tracker/Visit2Test.php index 3a64c6e54b..1564723189 100644 --- a/tests/PHPUnit/Integration/Tracker/Visit2Test.php +++ b/tests/PHPUnit/Integration/Tracker/Visit2Test.php @@ -148,12 +148,6 @@ class Visit2Test extends IntegrationTestCase }); } - public function tearDown() - { - EventDispatcher::getInstance()->clearObservers('Tracker.Request.getIdSite'); - parent::tearDown(); - } - public function test_handleNewVisitWithoutConversion_shouldTriggerDimensions() { $request = new Request(array()); diff --git a/tests/PHPUnit/Integration/TrackerTest.php b/tests/PHPUnit/Integration/TrackerTest.php index a7a3978e85..4daddc0d09 100644 --- a/tests/PHPUnit/Integration/TrackerTest.php +++ b/tests/PHPUnit/Integration/TrackerTest.php @@ -74,7 +74,6 @@ class TrackerTest extends IntegrationTestCase if($this->tracker) { $this->tracker->disconnectDatabase(); } - EventDispatcher::getInstance()->clearObservers('Tracker.makeNewVisitObject'); if (array_key_exists('PIWIK_TRACKER_DEBUG', $GLOBALS)) { unset($GLOBALS['PIWIK_TRACKER_DEBUG']); } diff --git a/tests/PHPUnit/Unit/AssetManagerTest.php b/tests/PHPUnit/Unit/AssetManagerTest.php index ceff55425b..4108aeeb16 100644 --- a/tests/PHPUnit/Unit/AssetManagerTest.php +++ b/tests/PHPUnit/Unit/AssetManagerTest.php @@ -139,8 +139,6 @@ class AssetManagerTest extends UnitTestCase private function setUpPluginManager() { $this->pluginManager = Manager::getInstance(); - - EventDispatcher::unsetInstance(); // EventDispatcher stores a reference to Plugin Manager } private function setUpPlugins() diff --git a/tests/PHPUnit/Unit/TrackerTest.php b/tests/PHPUnit/Unit/TrackerTest.php index 084ee627de..57a45e287e 100644 --- a/tests/PHPUnit/Unit/TrackerTest.php +++ b/tests/PHPUnit/Unit/TrackerTest.php @@ -69,12 +69,6 @@ class TrackerTest extends UnitTestCase $this->requestSet->setRequests(array($this->buildRequest(1), $this->buildRequest(1))); } - public function tearDown() - { - EventDispatcher::getInstance()->clearObservers('Tracker.end'); - parent::tearDown(); - } - public function test_isDebugModeEnabled_shouldReturnFalse_ByDefault() { unset($GLOBALS['PIWIK_TRACKER_DEBUG']); |