Permalink
Browse files

More testing

  • Loading branch information...
1 parent 271afbc commit 65a50104276cd12ea935759f60af660fe5148249 Sean Crystal committed Aug 25, 2011
@@ -68,7 +68,7 @@ public function addHandler($eventClass, $handler)
if (is_object($handler)
&& !($handler instanceof \Tracks\EventHandler\IEventHandler)
) {
- throw new LogicException('Event handlers must implement IEventHandler');
+ throw new \LogicException('Event handlers must implement IEventHandler');
}
if (!isset($this->_handlers[$eventClass])) {
@@ -0,0 +1,36 @@
+<?php
+require_once 'PHPUnit/Framework/TestCase.php';
+use Tracks\EventHandler\DirectRouter;
+
+class Tracks_EventHandler_DirectRouterTest extends PHPUnit_Framework_TestCase
+{
+ public function testRoute()
+ {
+ $handler = $this->getMock('Tracks\EventHandler\IEventHandler');
+ $handler->expects($this->once())->method('execute');
+
+ $event = $this->getMockBuilder('Tracks\Event\Base')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $event->expects($this->never())->method('null');
+
+ $router = new DirectRouter;
+ $router->addHandler(get_class($event), $handler);
+ $router->route($event);
+ }
+
+ public function testAddHandlerWithStringHandlerClass()
+ {
+ $router = new DirectRouter;
+ $router->addHandler('stdClass', 'handler');
+ }
+
+ public function testAddHandlerWithObjectHandler()
+ {
+ $handler = $this->getMock('Tracks\EventHandler\IEventHandler');
+ $handler->expects($this->never())->method('execute');
+
+ $router = new DirectRouter;
+ $router->addHandler('stdClass', $handler);
+ }
+}
@@ -2,7 +2,7 @@
require_once 'PHPUnit/Framework/TestCase.php';
use Tracks\UnitOfWork\UnitOfWork;
-class UnitOfWorkTest extends PHPUnit_Framework_TestCase
+class Tracks_UnitOfWork_UnitOfWorkTest extends PHPUnit_Framework_TestCase
{
private $unitOfWork;

0 comments on commit 65a5010

Please sign in to comment.