Skip to content
Permalink
Browse files

fixed reading data property on tests

  • Loading branch information...
thinkingmedia
thinkingmedia committed Aug 30, 2016
1 parent 9ada469 commit 61fe5cedc6400a774ca2dcf10bbdd6e698c125cc
@@ -24,7 +24,7 @@
* @property mixed $result Property used to retain the result value of the event listeners
* @property array $data Custom data for the method that receives the event
*/
class Event implements EventInterface
class Event
{
/**

This file was deleted.

Oops, something went wrong.
@@ -44,9 +44,9 @@ class ControllerFactoryFilter extends DispatcherFilter
*/
public function beforeDispatch(Event $event)
{
$request = $event->data['request'];
$response = $event->data['response'];
$event->data['controller'] = $this->_getController($request, $response);
$request = $event->data('request');
$response = $event->data('response');
$event->setData('controller', $this->_getController($request, $response));
}
/**
@@ -47,7 +47,7 @@ class RoutingFilter extends DispatcherFilter
*/
public function beforeDispatch(Event $event)
{
$request = $event->data['request'];
$request = $event->data('request');
if (Router::getRequest(true) !== $request) {
Router::setRequestInfo($request);
}
@@ -57,9 +57,10 @@ public function beforeDispatch(Event $event)
$params = Router::parse($request->url, $request->method());
$request->addParams($params);
}
return null;
} catch (RedirectException $e) {
$event->stopPropagation();
$response = $event->data['response'];
$response = $event->data('response');
$response->statusCode($e->getCode());
$response->header('Location', $e->getMessage());
@@ -38,7 +38,7 @@ public function testCanTriggerIf()
$decorator = new ConditionDecorator($callable, [
'if' => function (Event $event) {
return $event->data['canTrigger'];
return $event->data('canTrigger');
}
]);
@@ -63,7 +63,7 @@ public function testCanTriggerIf()
public function testCascadingEvents()
{
$callable = function (Event $event) {
$event->data['counter']++;
$event->setData('counter', $event->data('counter') + 1);
return $event;
};
@@ -75,7 +75,7 @@ public function testCascadingEvents()
]);
$listener2 = function (Event $event) {
$event->data['counter']++;
$event->setData('counter', $event->data('counter') + 1);
return $event;
};
@@ -88,7 +88,7 @@ public function testCascadingEvents()
]);
EventManager::instance()->dispatch($event);
$this->assertEquals(2, $event->data['counter']);
$this->assertEquals(2, $event->data('counter'));
}
/**
@@ -702,7 +702,7 @@ public function testDispatchLocalHandledByGlobal()
$manager = new EventManager();
$event = new Event('my_event', $manager);
$manager->dispatch($event);
$this->assertEquals('ok', $event->data['callback']);
$this->assertEquals('ok', $event->data('callback'));
}
/**
@@ -78,7 +78,7 @@ public function testPropagation()
public function testEventData()
{
$event = new Event('fake.event', $this, ['some' => 'data']);
$this->assertEquals(['some' => 'data'], $event->data);
$this->assertEquals(['some' => 'data'], $event->data());
}
/**
@@ -2,14 +2,13 @@
namespace TestApp\Routing\Filter;
use Cake\Event\Event;
use Cake\Network\Response;
use Cake\Routing\DispatcherFilter;
class AppendFilter extends DispatcherFilter
{
public function afterDispatch(Event $event)
{
$response = $event->data['response'];
$response = $event->data('response');
$response->body($response->body() . ' appended content');
}
}

0 comments on commit 61fe5ce

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