78. <?php
class IndexControllerTest extends Test_ControllerTestCase
{
public function setUp()
{
$todo = new Todo();
$this->_request = new Request();
$this->_response = new Response();
$this->_controller = new IndexController($todo);
parent::setUp();
}
public function tearDown()
{
$this->_request->reset();
$this->_response->reset();
}
public function testHome()
{
$this->dispatch('/');
$this->assertAction('index')
->assertResponseCode(200);
}
79.
80.
81.
82. <?php
class IndexControllerTest extends Test_ControllerTestCase
{
public function setUp()
{
$todo = $this->_setUpTodo();
$this->_controller = new IndexController($todo);
// ...
}
protected function _setUpTodo()
{
$todo = Phake::mock('Todo');
Phake::when($todo)->fetchAll()->thenReturn(array(
array(
'id' => 1,
'task' => 'Task 1',
'done' => 'n',
),
));
return $todo;
}