Zend_Test_PHPUnit_ControllerTestCase: Test view parameters and not rendered output
Posted
by erenon
on Stack Overflow
See other posts from Stack Overflow
or by erenon
Published on 2010-03-23T09:19:03Z
Indexed on
2010/03/23
9:23 UTC
Read the original article
Hit count: 404
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
);
}
}
© Stack Overflow or respective owner