Zend_Test_PHPUnit_ControllerTestCase: Test view parameters and not rendered output
- by erenon
Hi,
I'm using Zend_Test_PHPUnit_ControllerTestCase to test my controllers. This class provides various ways to test the rendered output, but I don't want to get my view scripts involved. I'd like to test my view's vars. Is there a way to access to the controllers view object?
Here is an example, what I'm trying to do:
<?php
class Controller extends Zend_Controller_Action
{
public function indexAction()
{
$this-view->foo = 'bar';
}
}
class ControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public function testShowCallsServiceFind()
{
$this->dispatch('/controller');
//doesn't work, there is no such method:
$this->assertViewVar('foo', 'bar');
//doesn't work:
$this-assertEquals(
'bar',
$this->getView()->foo
);
}
}