-- Paul Shoemaker <[EMAIL PROTECTED]> wrote
(on Tuesday, 01 July 2008, 09:32 AM -0500):
> Ok, I found the error in how I was instantiating my bootstrap.  I neglected to
> utilize the callback properly.  I have a static method called run in a
> Bootstrap class that bootstraps the application.  I am now using public
> $bootstrap = array(‘Bootstrap’, ‘run’); to bootstrap the test.  Now I am
> receiving the error below related to a headers sent issue:
> 1) testCallingController(ControllerTest)
> Zend_Controller_Response_Exception: Cannot send headers; headers already sent
> in /Applications/MAMP/Library/PHPUnit/Util/Printer.php, line 145
> /Applications/MAMP/Library/Zend/Controller/Response/Abstract.php:114
> /Users/pshoemaker/Documents/mamp_workspace/mvcblog/application/Bootstrap.php:75
> /Users/pshoemaker/Documents/mamp_workspace/mvcblog/application/Bootstrap.php:14
> /Users/pshoemaker/Documents/mamp_workspace/ZendIncubator/Test/PHPUnit/
> ControllerTestCase.php:119
> /Users/pshoemaker/Documents/mamp_workspace/ZendIncubator/Test/PHPUnit/
> ControllerTestCase.php:100
> /Users/pshoemaker/Documents/mamp_workspace/mvcblog/tests/ControllerTest.php:12
> 
> Any ideas?  Let me know if you need more information.

If you're going to unit test your ZF MVC applications, it's very
important that you never call header() or any function that would set a
header. You can mitigate this by setting your headers directly in your
response object.

However, it appears that what's at fault here is your Bootstrap class;
are you setting or sending headers via that class? If so, I'd recommend
that you defer those actions to a plugin, as that will ensure that the
Response object stub is used -- which prevents any calls to
headers_sent() or header() from occuring.


>   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
> From: Matthew Weier O'Phinney <[EMAIL PROTECTED]>
> Date: Tue, 1 Jul 2008 07:15:24 -0500
> To: <[email protected]>, <[EMAIL PROTECTED]>
> Subject: Re: [fw-mvc] MVC testing scaffold is feature complete
> 
> -- Paul Shoemaker <[EMAIL PROTECTED]> wrote
> (on Monday, 30 June 2008, 05:00 PM -0500):
> > I have tested it out and there seems to be an issue in my particular case I
> am
> > sure.  Perhaps you can lend some assistance?
> >
> > I have a valid simple bootstrap.  It works fine and resolves to
> IndexController
> > when I go to the root ‘/’ in my browser.  However, when I invoke $this->
> > dispatch(‘/’); the test fails with the error below:
> >
> > 1) testCallingController(ControllerTest)
> > Zend_Controller_Exception: No default module defined for this application
> > /Applications/MAMP/Library/Zend/Controller/Dispatcher/Standard.php:211
> > /Applications/MAMP/Library/Zend/Controller/Dispatcher/Standard.php:245
> > /Applications/MAMP/Library/Zend/Controller/Front.php:914
> > /Users/pshoemaker/Documents/mamp_workspace/ZendIncubator/Test/PHPUnit/
> > ControllerTestCase.php:158
> > /Users/pshoemaker/Documents/mamp_workspace/mvcblog/tests/
> ControllerTest.php:14
> >
> > My bootstrap class is large but uncomplicated so I won’t clutter the list
> with
> > it unless requested to do so.  Suffice it to say that it works as advertised
> > but is not working in the test.  Any ideas with the information I have 
> > given?
> >  Perhaps I am missing something very simple?
> 
> How does your bootstrap work normally -- i.e., how do you invoke it? And
> how are you informing the testcase of your bootstrap? What the above
> tells me is that the front controller was never told of your controller
> directories, so most likely the issue lies with how you bootstrapped the
> testcase.
> 
> 
> >   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
> > From: Matthew Weier O'Phinney <[EMAIL PROTECTED]>
> > Date: Mon, 30 Jun 2008 13:40:45 -0500
> > To: <[email protected]>
> > Cc: <[EMAIL PROTECTED]>
> > Subject: [fw-mvc] MVC testing scaffold is feature complete
> >
> > Greetings, all.
> >
> > This morning, I blogged about a new feature for 1.6 that you should
> > start looking at: a functional testing scaffold for your MVC
> > applications. You can read more about it here:
> >
> >     http://weierophinney.net/matthew/archives/
> > 182-Testing-Zend-Framework-MVC-Applications.html
> >
> > The basic idea is that you setup your bootstrapping, and start writing
> > test methods. Your test methods would setup the request environment (if
> > necessary), dispatch a url, and then make assertions against the final
> > environment. No actual web server is required, as the environment is
> > encapsulated in the request and response objects.
> >
> > This code is in the incubator; please pull via SVN and start testing!
> >
> > --
> > Matthew Weier O'Phinney
> > Software Architect       | [EMAIL PROTECTED]
> > Zend Framework           | http://framework.zend.com/
> >
> 
> --
> Matthew Weier O'Phinney
> Software Architect       | [EMAIL PROTECTED]
> Zend Framework           | http://framework.zend.com/
> 

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to