summaryrefslogtreecommitdiff
path: root/vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php')
-rw-r--r--vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php34
1 files changed, 14 insertions, 20 deletions
diff --git a/vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php b/vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php
index f6556f0b1b..edce6f199d 100644
--- a/vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php
+++ b/vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\EventDispatcher\Tests;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\ImmutableEventDispatcher;
@@ -21,7 +22,7 @@ use Symfony\Component\EventDispatcher\ImmutableEventDispatcher;
class ImmutableEventDispatcherTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $innerDispatcher;
@@ -30,7 +31,7 @@ class ImmutableEventDispatcherTest extends TestCase
*/
private $dispatcher;
- protected function setUp()
+ protected function setUp(): void
{
$this->innerDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher);
@@ -39,13 +40,14 @@ class ImmutableEventDispatcherTest extends TestCase
public function testDispatchDelegates()
{
$event = new Event();
+ $resultEvent = new Event();
$this->innerDispatcher->expects($this->once())
->method('dispatch')
->with($event, 'event')
- ->willReturn('result');
+ ->willReturn($resultEvent);
- $this->assertSame('result', $this->dispatcher->dispatch($event, 'event'));
+ $this->assertSame($resultEvent, $this->dispatcher->dispatch('event', $event));
}
public function testGetListenersDelegates()
@@ -53,9 +55,9 @@ class ImmutableEventDispatcherTest extends TestCase
$this->innerDispatcher->expects($this->once())
->method('getListeners')
->with('event')
- ->willReturn('result');
+ ->willReturn(['result']);
- $this->assertSame('result', $this->dispatcher->getListeners('event'));
+ $this->assertSame(['result'], $this->dispatcher->getListeners('event'));
}
public function testHasListenersDelegates()
@@ -63,42 +65,34 @@ class ImmutableEventDispatcherTest extends TestCase
$this->innerDispatcher->expects($this->once())
->method('hasListeners')
->with('event')
- ->willReturn('result');
+ ->willReturn(true);
- $this->assertSame('result', $this->dispatcher->hasListeners('event'));
+ $this->assertTrue($this->dispatcher->hasListeners('event'));
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testAddListenerDisallowed()
{
+ $this->expectException('\BadMethodCallException');
$this->dispatcher->addListener('event', function () { return 'foo'; });
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testAddSubscriberDisallowed()
{
+ $this->expectException('\BadMethodCallException');
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
$this->dispatcher->addSubscriber($subscriber);
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testRemoveListenerDisallowed()
{
+ $this->expectException('\BadMethodCallException');
$this->dispatcher->removeListener('event', function () { return 'foo'; });
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testRemoveSubscriberDisallowed()
{
+ $this->expectException('\BadMethodCallException');
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
$this->dispatcher->removeSubscriber($subscriber);