Skip to content

Commit c352647

Browse files
OskarStarknicolas-grekas
authored andcommitted
Use createMock() and use import instead of FQCN
1 parent e190184 commit c352647

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Tests/Debug/WrappedListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class WrappedListenerTest extends TestCase
2323
*/
2424
public function testListenerDescription($listener, $expected)
2525
{
26-
$wrappedListener = new WrappedListener($listener, null, $this->getMockBuilder(Stopwatch::class)->getMock(), $this->getMockBuilder(EventDispatcherInterface::class)->getMock());
26+
$wrappedListener = new WrappedListener($listener, null, $this->createMock(Stopwatch::class), $this->createMock(EventDispatcherInterface::class));
2727

2828
$this->assertStringMatchesFormat($expected, $wrappedListener->getPretty());
2929
}

Tests/EventDispatcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function testAddSubscriberWithPriorities()
228228
$listeners = $this->dispatcher->getListeners('pre.foo');
229229
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
230230
$this->assertCount(2, $listeners);
231-
$this->assertInstanceOf(\Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities::class, $listeners[0][0]);
231+
$this->assertInstanceOf(TestEventSubscriberWithPriorities::class, $listeners[0][0]);
232232
}
233233

234234
public function testAddSubscriberWithMultipleListeners()

Tests/ImmutableEventDispatcherTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use PHPUnit\Framework\MockObject\MockObject;
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Component\EventDispatcher\Event;
17+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
18+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1719
use Symfony\Component\EventDispatcher\ImmutableEventDispatcher;
1820

1921
/**
@@ -33,7 +35,7 @@ class ImmutableEventDispatcherTest extends TestCase
3335

3436
protected function setUp(): void
3537
{
36-
$this->innerDispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
38+
$this->innerDispatcher = $this->createMock(EventDispatcherInterface::class);
3739
$this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher);
3840
}
3941

@@ -79,7 +81,7 @@ public function testAddListenerDisallowed()
7981
public function testAddSubscriberDisallowed()
8082
{
8183
$this->expectException(\BadMethodCallException::class);
82-
$subscriber = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventSubscriberInterface::class)->getMock();
84+
$subscriber = $this->createMock(EventSubscriberInterface::class);
8385

8486
$this->dispatcher->addSubscriber($subscriber);
8587
}
@@ -93,7 +95,7 @@ public function testRemoveListenerDisallowed()
9395
public function testRemoveSubscriberDisallowed()
9496
{
9597
$this->expectException(\BadMethodCallException::class);
96-
$subscriber = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventSubscriberInterface::class)->getMock();
98+
$subscriber = $this->createMock(EventSubscriberInterface::class);
9799

98100
$this->dispatcher->removeSubscriber($subscriber);
99101
}

0 commit comments

Comments
 (0)