diff --git a/src/Datasource/RulesAwareTrait.php b/src/Datasource/RulesAwareTrait.php index d7166d994ba..c33b7256850 100644 --- a/src/Datasource/RulesAwareTrait.php +++ b/src/Datasource/RulesAwareTrait.php @@ -59,7 +59,7 @@ public function checkRules(EntityInterface $entity, $operation = RulesChecker::C compact('entity', 'options', 'operation') ); if ($event->isStopped()) { - return $event->result; + return $event->result(); } } @@ -72,7 +72,7 @@ public function checkRules(EntityInterface $entity, $operation = RulesChecker::C ); if ($event->isStopped()) { - return $event->result; + return $event->result(); } } diff --git a/src/TestSuite/Constraint/EventFiredWith.php b/src/TestSuite/Constraint/EventFiredWith.php index c320116ae90..743be15b4fd 100644 --- a/src/TestSuite/Constraint/EventFiredWith.php +++ b/src/TestSuite/Constraint/EventFiredWith.php @@ -78,6 +78,9 @@ public function matches($other) return false; } + /** + * @var Event[] $events + */ $events = $eventGroup[$other]; if (count($events) > 1) { @@ -86,7 +89,7 @@ public function matches($other) $event = $events[0]; - if (array_key_exists($this->_dataKey, $event->data) === false) { + if (array_key_exists($this->_dataKey, $event->data()) === false) { return false; } diff --git a/tests/TestCase/Event/EventDispatcherTraitTest.php b/tests/TestCase/Event/EventDispatcherTraitTest.php index 464f73499e5..8c255660e84 100644 --- a/tests/TestCase/Event/EventDispatcherTraitTest.php +++ b/tests/TestCase/Event/EventDispatcherTraitTest.php @@ -14,6 +14,7 @@ namespace Cake\Test\TestCase\Event; +use Cake\Event\EventDispatcherTrait; use Cake\Event\EventManager; use Cake\TestSuite\TestCase; @@ -22,6 +23,10 @@ */ class EventDispatcherTraitTest extends TestCase { + /** + * @var EventDispatcherTrait + */ + public $subject; /** * setup @@ -70,8 +75,8 @@ public function testDispatchEvent() $event = $this->subject->dispatchEvent('some.event', ['foo' => 'bar']); $this->assertInstanceOf('Cake\Event\Event', $event); - $this->assertSame($this->subject, $event->subject); - $this->assertEquals('some.event', $event->name); - $this->assertEquals(['foo' => 'bar'], $event->data); + $this->assertSame($this->subject, $event->subject()); + $this->assertEquals('some.event', $event->name()); + $this->assertEquals(['foo' => 'bar'], $event->data()); } } diff --git a/tests/TestCase/Event/EventManagerTest.php b/tests/TestCase/Event/EventManagerTest.php index 22b2a9c4417..e1be64e69a8 100644 --- a/tests/TestCase/Event/EventManagerTest.php +++ b/tests/TestCase/Event/EventManagerTest.php @@ -684,10 +684,12 @@ public function testDispatchGlobalBeforeLocal() /** * test callback + * + * @param Event $event */ - public function onMyEvent($event) + public function onMyEvent(Event $event) { - $event->data['callback'] = 'ok'; + $event->setData('callback', 'ok'); } /** @@ -698,7 +700,7 @@ public function onMyEvent($event) public function testDispatchLocalHandledByGlobal() { $callback = [$this, 'onMyEvent']; - EventManager::instance()->attach($callback, 'my_event'); + EventManager::instance()->on('my_event', $callback); $manager = new EventManager(); $event = new Event('my_event', $manager); $manager->dispatch($event); @@ -715,10 +717,10 @@ public function testDispatchLocalHandledByGlobal() public function testDispatchWithGlobalAndLocalEvents() { $listener = new CustomTestEventListenerInterface(); - EventManager::instance()->attach($listener); + EventManager::instance()->on($listener); $listener2 = new EventTestListener(); $manager = new EventManager(); - $manager->attach([$listener2, 'listenerFunction'], 'fake.event'); + $manager->on('fake.event', [$listener2, 'listenerFunction']); $manager->dispatch(new Event('fake.event', $this)); $this->assertEquals(['listenerFunction'], $listener->callList); diff --git a/tests/TestCase/ORM/Association/BelongsToManyTest.php b/tests/TestCase/ORM/Association/BelongsToManyTest.php index 00133842dd0..e57c7b0d25e 100644 --- a/tests/TestCase/ORM/Association/BelongsToManyTest.php +++ b/tests/TestCase/ORM/Association/BelongsToManyTest.php @@ -16,6 +16,7 @@ use Cake\Database\Expression\QueryExpression; use Cake\Datasource\ConnectionManager; +use Cake\Event\Event; use Cake\ORM\Association\BelongsToMany; use Cake\ORM\Entity; use Cake\ORM\TableRegistry;