Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
From 51ef986549a5797abf1aea6441c268fe3287ed62 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 24 Aug 2009 16:01:03 -0400 Subject: [PATCH] Events are now intialized with arguments, rather than a Context. --- events/event.php | 13 ++++++------- testing/tests/events/event_test.php | 22 ++++++---------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/events/event.php b/events/event.php index a089fb5..242431a 100644 --- a/events/event.php +++ b/events/event.php @@ -21,19 +21,18 @@ namespace phalanx\events; // the view system. abstract class Event { - // The DateTime that the event occurred at. - protected $time; - // The Context in which the event is being handled. protected $context; + // The arguments passed to the event upon creation. + protected $arguments = null; + // Whether or not the event is cancelled. protected $cancelled = false; - public function __construct(Context $context = null) + public function __construct(\phalanx\base\PropertyBag $arguments = null) { - $this->time = new \DateTime(); - $this->context = $context; + $this->arguments = $arguments; } // Does precondition checks and returns a bool indicating if the event can be @@ -54,7 +53,7 @@ abstract class Event // Getters and setters. // -------------------------------------------------------------------------- - public function time() { return $this->time; } + public function arguments() { return $this->arguments; } public function set_context(Context $context) { $this->context = $context; } public function context() { return $this->context; } diff --git a/testing/tests/events/event_test.php b/testing/tests/events/event_test.php index 31b0191..5ff39fd 100644 --- a/testing/tests/events/event_test.php +++ b/testing/tests/events/event_test.php @@ -25,20 +25,13 @@ class EventTest extends \PHPUnit_Framework_TestCase { $this->event = new TestEvent(); } - - public function testTime() - { - $before = new \DateTime(); - sleep(1); - $event = new TestEvent(); - sleep(1); - $after = new \DateTime(); - - $time = $event->time(); - $this->assertNotNull($time); - $this->assertLessThan($time->getTimestamp(), $before->getTimestamp()); - $this->assertGreaterThan($time->getTimestamp(), $after->getTimestamp()); + public function testArguments() + { + $args = new \phalanx\base\PropertyBag(); + $args->test = 'foo'; + $this->event = new TestEvent($args); + $this->assertSame($args, $this->event->arguments()); } public function testSetContext() @@ -50,9 +43,6 @@ class EventTest extends \PHPUnit_Framework_TestCase $event->set_context($context); $this->assertSame($context, $event->context()); - - $event = new TestEvent($context); - $this->assertSame($context, $event->context()); } public function testCanRunInContext() -- 1.7.11.3