. namespace hoplite\test; use hoplite\http as http; require_once HOPLITE_ROOT . '/http/action_controller.php'; class TestActionController extends http\ActionController { public $did_action = FALSE; public function ActionSomething(http\Request $request, http\Response $response) { $this->did_action = TRUE; } } class ActionControllerTest extends \PHPUnit_Framework_TestCase { public function setUp() { $globals = array(); $this->fixture = new TestActionController(new http\FrontController($globals)); $this->request = new http\Request(); $this->response = new http\Response(); } public function testDispatch() { $this->request->data['action'] = 'something'; $this->fixture->Invoke($this->request, $this->response); $this->assertTrue($this->fixture->did_action); } public function testFailedDispatch() { $globals = array(); $mock = $this->getMock('hoplite\http\FrontController', array('SendResponse'), array($globals)); $this->fixture = new TestActionController($mock); $mock->expects($this->once()) ->method('SendResponse'); $this->request->data['action'] = 'nothing'; $this->fixture->Invoke($this->request, $this->response); $this->assertFalse($this->fixture->did_action); } }