Jump to content

Unit Testing Zend Controllers - Errors


cmiddlebrook

Recommended Posts

Hi there,

 

I have a simple Zend Framework application and I am experimenting with unit testing before I develop too much code. I am using Zend_Test and the tests run ok but the assertions fail on the simplest of tests. Here is an example of what I am doing:

 

class AccountControllerTests extends Zend_Test_PHPUnit_ControllerTestCase

{

public $bootstrap = 'c:\xampp\htdocs\code\ima-live\tests\TestBootstrap.php';

 

public function testErrorController()

{

$this->dispatch('poo');

$this->assertController('error');

$this->assertAction('error');

}

 

public function testDefaultAction()

{

$this->dispatch('/index');

$this->assertController('index');

}

 

The test for the error controller passes but the test for the default action fails. If I assert the last Controller to be 'error' that works so I'm assuming that Zend is throwing some kind of exception causing the error controller to be invoked.

 

The site itself works fine both locally (using Xampp) and on a live server that I have - it's just in this test environment that its failing.

 

I'm not really sure where to go from here. Firstly I don't know why the tests are failing but I also don't know how to get more information. Is there any way to output debugging information from the tests or write to a log file etc. Any way to extract information about the error that's being reported?

 

Any advice greatly appreciated,

 

Caroline

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.