Browse Source

Fix typehint on protected method.

Mark Story 6 years ago
parent
commit
b1651e3aa0

+ 2 - 2
src/Event/EventManager.php

@@ -342,10 +342,10 @@ class EventManager implements EventManagerInterface
      * Calls a listener.
      *
      * @param callable $listener The listener to trigger.
-     * @param \Cake\Event\Event $event Event instance.
+     * @param \Cake\Event\EventInterface $event Event instance.
      * @return mixed The result of the $listener function.
      */
-    protected function _callListener(callable $listener, Event $event)
+    protected function _callListener(callable $listener, EventInterface $event)
     {
         $data = $event->getData();
 

+ 2 - 84
tests/TestCase/Event/EventManagerTest.php

@@ -15,94 +15,11 @@
 namespace Cake\Test\TestCase\Event;
 
 use Cake\Event\Event;
-use Cake\Event\EventInterface;
 use Cake\Event\EventList;
 use Cake\Event\EventListenerInterface;
 use Cake\Event\EventManager;
 use Cake\TestSuite\TestCase;
-
-/**
- * TestEvent
- */
-class TestEvent implements EventInterface
-{
-    /**
-     * @var string
-     */
-    protected $name;
-
-    /**
-     * @param string $name
-     */
-    public function __construct($name)
-    {
-        $this->name = $name;
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getName()
-    {
-        return $this->name;
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getSubject()
-    {
-        // TODO: Implement getSubject() method.
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function stopPropagation()
-    {
-        // TODO: Implement stopPropagation() method.
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function isStopped()
-    {
-        // TODO: Implement isStopped() method.
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getResult()
-    {
-        // TODO: Implement getResult() method.
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function setResult($value = null)
-    {
-        // TODO: Implement setResult() method.
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getData($key = null)
-    {
-        // TODO: Implement getData() method.
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function setData($key, $value = null)
-    {
-        // TODO: Implement setData() method.
-    }
-}
+use TestApp\Event\TestEvent;
 
 /**
  * Mock class used to test event dispatching
@@ -190,6 +107,7 @@ class EventManagerTest extends TestCase
         $manager = new EventManager();
         $manager->on($listener);
         $manager->dispatch($event);
+        $this->assertCount(1, $manager->listeners('fake.event'));
     }
 
     /**

+ 84 - 0
tests/test_app/TestApp/Event/TestEvent.php

@@ -0,0 +1,84 @@
+<?php
+namespace TestApp\Event;
+
+use Cake\Event\EventInterface;
+
+/**
+ * TestEvent
+ */
+class TestEvent implements EventInterface
+{
+    /**
+     * @var string
+     */
+    protected $name;
+
+    /**
+     * @param string $name
+     */
+    public function __construct($name)
+    {
+        $this->name = $name;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function getSubject()
+    {
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function stopPropagation()
+    {
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function isStopped()
+    {
+        return false;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function getResult()
+    {
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function setResult($value = null)
+    {
+        return $this;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function getData($key = null)
+    {
+        return [];
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function setData($key, $value = null)
+    {
+        return $this;
+    }
+}