Skip to content
Permalink
Browse files

Remove use of TestCase::getMock() from "Event" namepace tests.

  • Loading branch information...
ADmad committed Jun 5, 2016
1 parent 5a812b7 commit 718551b0ba544e749c6f75334d20644e0cca1362
Showing with 24 additions and 10 deletions.
  1. +24 −10 tests/TestCase/Event/EventManagerTest.php
@@ -368,8 +368,10 @@ public function testDetachFromAll()
public function testDispatch()
{
$manager = new EventManager();
$listener = $this->getMock(__NAMESPACE__ . '\EventTestListener');
$anotherListener = $this->getMock(__NAMESPACE__ . '\EventTestListener');
$listener = $this->getMockBuilder(__NAMESPACE__ . '\EventTestListener')
->getMock();
$anotherListener = $this->getMockBuilder(__NAMESPACE__ . '\EventTestListener')
->getMock();
$manager->attach([$listener, 'listenerFunction'], 'fake.event');
$manager->attach([$anotherListener, 'listenerFunction'], 'fake.event');
$event = new Event('fake.event');
@@ -409,8 +411,10 @@ public function testDispatchReturnValue()
'These tests fail in PHPUnit 3.6'
);
$manager = new EventManager;
$listener = $this->getMock(__NAMESPACE__ . '\EventTestListener');
$anotherListener = $this->getMock(__NAMESPACE__ . '\EventTestListener');
$listener = $this->getMockBuilder(__NAMESPACE__ . '\EventTestListener')
->getMock();
$anotherListener = $this->getMockBuilder(__NAMESPACE__ . '\EventTestListener')
->getMock();
$manager->attach([$listener, 'listenerFunction'], 'fake.event');
$manager->attach([$anotherListener, 'listenerFunction'], 'fake.event');
$event = new Event('fake.event');
@@ -439,8 +443,10 @@ public function testDispatchFalseStopsEvent()
);
$manager = new EventManager();
$listener = $this->getMock(__NAMESPACE__ . '\EventTestListener');
$anotherListener = $this->getMock(__NAMESPACE__ . '\EventTestListener');
$listener = $this->getMockBuilder(__NAMESPACE__ . '\EventTestListener')
->getMock();
$anotherListener = $this->getMockBuilder(__NAMESPACE__ . '\EventTestListener')
->getMock();
$manager->attach([$listener, 'listenerFunction'], 'fake.event');
$manager->attach([$anotherListener, 'listenerFunction'], 'fake.event');
$event = new Event('fake.event');
@@ -483,7 +489,9 @@ public function testDispatchPrioritized()
public function testAttachSubscriber()
{
$manager = new EventManager();
$listener = $this->getMock(__NAMESPACE__ . '\CustomTestEventListenerInterface', ['secondListenerFunction']);
$listener = $this->getMockBuilder(__NAMESPACE__ . '\CustomTestEventListenerInterface')
->setMethods(['secondListenerFunction'])
->getMock();
$manager->attach($listener);
$event = new Event('fake.event');
@@ -508,7 +516,9 @@ public function testAttachSubscriber()
public function testAttachSubscriberMultiple()
{
$manager = new EventManager();
$listener = $this->getMock(__NAMESPACE__ . '\CustomTestEventListenerInterface', ['listenerFunction', 'thirdListenerFunction']);
$listener = $this->getMockBuilder(__NAMESPACE__ . '\CustomTestEventListenerInterface')
->setMethods(['listenerFunction', 'thirdListenerFunction'])
->getMock();
$manager->attach($listener);
$event = new Event('multiple.handlers');
$listener->expects($this->once())
@@ -528,7 +538,9 @@ public function testAttachSubscriberMultiple()
public function testDetachSubscriber()
{
$manager = new EventManager();
$listener = $this->getMock(__NAMESPACE__ . '\CustomTestEventListenerInterface', ['secondListenerFunction']);
$listener = $this->getMockBuilder(__NAMESPACE__ . '\CustomTestEventListenerInterface')
->setMethods(['secondListenerFunction'])
->getMock();
$manager->attach($listener);
$expected = [
['callable' => [$listener, 'secondListenerFunction']]
@@ -565,7 +577,9 @@ public function testGlobalDispatcherGetter()
*/
public function testDispatchWithGlobal()
{
$generalManager = $this->getMock('Cake\Event\EventManager', ['prioritisedListeners']);
$generalManager = $this->getMockBuilder('Cake\Event\EventManager')
->setMethods(['prioritisedListeners'])
->getMock();
$manager = new EventManager();
$event = new Event('fake.event');
EventManager::instance($generalManager);

0 comments on commit 718551b

Please sign in to comment.
You can’t perform that action at this time.