PHP unit tests for controller returns no errors and no success message.
Posted
by Mallika Iyer
on Stack Overflow
See other posts from Stack Overflow
or by Mallika Iyer
Published on 2010-04-21T18:36:27Z
Indexed on
2010/04/21
18:43 UTC
Read the original article
Hit count: 387
I'm using the zend modular director structure, i.e.
application
modules
users
controllers
.
.
lessons
reports
blog
I have a unit test for a controller in 'blog' that goes something like the below section of code: I'm definitely doing something very wrong, or missing something - as when i run the test, i get no error, no success message (that goes usually like ...OK (2 tests, 2 assertions)). I get all the text from layout.phtml, where i have the global site layout.
This is my first endeavor writing a unittest for zend-M-V-C structure so probably I'm missing something important?
Here goes....
require_once '../../../../public/index.php';
require_once '../../../../application/Bootstrap.php';
require_once '../../../../application/modules/blog/controllers/BrowseController.php';
require_once '../../../TestConfiguration.php';
class Blog_BrowseControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public function setUp() {
$this->bootstrap = array($this, 'appBootstrap');
Blog_BrowseController::setUp();
}
public function appBootstrap() {
require_once dirname(__FILE__) . '/../../bootstrap.php';
}
public function testAction() {
$this->dispatch('/');
$this->assertController('browse');
$this->assertAction('index');
}
public function tearDown() {
$this->resetRequest();
$this->resetResponse();
Blog_BrowseController::tearDown();
}
}
© Stack Overflow or respective owner