diff options
author | Frédéric Guillot <fred@kanboard.net> | 2017-12-15 11:24:35 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2017-12-15 11:55:42 -0800 |
commit | a93b8e10f5954be0853eec693c13e84c4bd9e6f2 (patch) | |
tree | eda5de9494b819235616e8623bb3393e9cc373af /vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php | |
parent | 2c72a283f2d51034f85f4e2ca8b194d304a3c433 (diff) |
Kanboard requires at least PHP 5.6 now
Diffstat (limited to 'vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php')
-rw-r--r-- | vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php | 85 |
1 files changed, 11 insertions, 74 deletions
diff --git a/vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php b/vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php index 0f3f5ba7..9d5eecc5 100644 --- a/vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ b/vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php @@ -12,11 +12,13 @@ namespace Symfony\Component\EventDispatcher\Tests; use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\DependencyInjection\Scope; use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * @group legacy + */ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest { protected function createEventDispatcher() @@ -30,7 +32,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest { $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $service ->expects($this->once()) @@ -51,7 +53,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest { $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\SubscriberService')->getMock(); $service ->expects($this->once()) @@ -86,7 +88,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest { $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $service ->expects($this->once()) @@ -104,73 +106,11 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest $dispatcher->dispatch('onEvent', $event); } - /** - * @expectedException \InvalidArgumentException - */ - public function testTriggerAListenerServiceOutOfScope() - { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $scope = new Scope('scope'); - $container = new Container(); - $container->addScope($scope); - $container->enterScope('scope'); - - $container->set('service.listener', $service, 'scope'); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $container->leaveScope('scope'); - $dispatcher->dispatch('onEvent'); - } - - public function testReEnteringAScope() - { - $event = new Event(); - - $service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service1 - ->expects($this->exactly(2)) - ->method('onEvent') - ->with($event) - ; - - $scope = new Scope('scope'); - $container = new Container(); - $container->addScope($scope); - $container->enterScope('scope'); - - $container->set('service.listener', $service1, 'scope'); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - $dispatcher->dispatch('onEvent', $event); - - $service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service2 - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container->enterScope('scope'); - $container->set('service.listener', $service2, 'scope'); - - $dispatcher->dispatch('onEvent', $event); - - $container->leaveScope('scope'); - - $dispatcher->dispatch('onEvent'); - } - public function testHasListenersOnLazyLoad() { $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $container = new Container(); $container->set('service.listener', $service); @@ -178,9 +118,6 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest $dispatcher = new ContainerAwareEventDispatcher($container); $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - $event->setDispatcher($dispatcher); - $event->setName('onEvent'); - $service ->expects($this->once()) ->method('onEvent') @@ -196,7 +133,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest public function testGetListenersOnLazyLoad() { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $container = new Container(); $container->set('service.listener', $service); @@ -206,14 +143,14 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest $listeners = $dispatcher->getListeners(); - $this->assertTrue(isset($listeners['onEvent'])); + $this->assertArrayHasKey('onEvent', $listeners); $this->assertCount(1, $dispatcher->getListeners('onEvent')); } public function testRemoveAfterDispatch() { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $container = new Container(); $container->set('service.listener', $service); @@ -228,7 +165,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest public function testRemoveBeforeDispatch() { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $container = new Container(); $container->set('service.listener', $service); |