-- Peter Wansch <[EMAIL PROTECTED]> wrote
(on Sunday, 31 August 2008, 10:17 PM -0700):
> 
> Hi Matt,
> Thanks for the explanation. I ensured that GGV_DISPATCH_CONTROLLER is set to
> false:
> 
>     public function setUp()
>     {
>         // Execute any startup code here
>         defined('GOGOVERDE_DISPATCH_FRONT_CONTROLLER') or
> define('GOGOVERDE_DISPATCH_FRONT_CONTROLLER', false);
>         parent::setUp();
>     }
> 
> right where you suggested I should define it. I still get the same error.
> Here is the output from phpunit:
> 
> 1) testValidLoginShouldGoToIndexPage(Ggv_LoginTest)
> Zend_Controller_Exception: No default module defined for this application
> /Library/WebServer/ZendFramework-1.6.0RC3/library/Zend/Controller/Dispatcher/Standard.php:211
> /Library/WebServer/ZendFramework-1.6.0RC3/library/Zend/Controller/Dispatcher/Standard.php:245
> /Library/WebServer/ZendFramework-1.6.0RC3/library/Zend/Controller/Front.php:946
> /Library/WebServer/ZendFramework-1.6.0RC3/library/Zend/Test/PHPUnit/ControllerTestCase.php:172
> 
> Any ideas what the reason for that could be?

Is GGV_PATH_ROOT defined? I noticed that you're setting the controller
directory based on that information.

Also, can you do this as the first action in your test:

    $this->fail(var_export($this->frontController->getControllerDirectory(), 
1));

This will let you know if the front controller has set controller
directories for you prior to dispatching. 


> Matthew Weier O'Phinney-3 wrote:
> > 
> > -- Peter Wansch <[EMAIL PROTECTED]> wrote
> > (on Sunday, 31 August 2008, 04:19 PM -0700):
> >> I wrote the following unit test case:
> >> 
> >> class Ggv_LoginTest extends Zend_Test_PHPUnit_ControllerTestCase
> >> {
> >>     public $bootstrap = '/Library/WebServer/Documents/GGV/www/index.php';
> >> 
> >>     public function testCallWithoutActionShouldPullFromIndexAction()
> >>     {
> >>         $this->dispatch('/');
> >>         $this->assertResponseCode(200);
> >>     }
> >> 
> >>     public function testValidLoginShouldGoToIndexPage()
> >>     {
> >>         $this->request->setMethod('POST')
> >>               ->setPost(array(
> >>                   'user_name' => TESTS_LOGIN_NAME,
> >>                   'user_password' => TESTS_LOGIN_PASSWORD
> >>               ));
> >>         $this->dispatch('/GGV/www/user/login/');
> >>         $this->assertResponseCode(200);
> >>     }
> >> }
> >> 
> >> The first test case that dispatches to '/' works. The second test case
> >> that
> >> dispatches to throws Zend_Controller_Exception: No default module defined
> >> for this application. I use the same index.php bootstrap file for running
> >> the application and testing the application. Here is a relevant excerpt:
> >> 
> >> defined('GGV_DISPATCH_FRONT_CONTROLLER') or
> >> define('GGV_DISPATCH_FRONT_CONTROLLER', true);
> >> 
> >>     // Set the session into the registry
> >>     Zend_Registry::set('session', $session);
> >> 
> >>     // Set up the front controller and dispatch
> >>     $front = Zend_Controller_Front::getInstance();
> >>     $front->registerPlugin(new LoggerPlugin());
> >>     $front->throwExceptions(false);
> >>     $front->setControllerDirectory(GGV_PATH_ROOT .
> >> '/application/controllers');
> >>     $front->setBaseUrl($config->www->baseurl);
> >>     if (GGV_DISPATCH_FRONT_CONTROLLER)
> >>     {
> >>         $front->dispatch();
> >>     }
> >> 
> >> the only difference is that in my test case I require_once a test
> >> configuration PHP file that defines GGV_DISPATCH_FRONT_CONTROLLER to
> >> false
> >> as per the documentation the bootstrap file must not dispatch the front
> >> controller. Unlike all the samples given, I don't use a Bootstrap class
> >> or
> >> callback in my testcase. It appears that Zend_Test does not use the
> >> $front
> >> controller I setup in my index.php but creates it's own which isn't
> >> initialized and throws the error.
> > 
> > Well, Zend_Controller_Front is a singleton, so any instance of it is
> > going to be the same instance, regardless of where it is executed.
> > 
> >> I have also experimented with adding a setUp
> >> 
> >> public function setUp()
> >>     {
> >>         // Execute any startup code here
> > 
> > I would define GGV_DISPATCH_FRONT_CONTROLLER right here, before calling
> > parent::setUp() to ensure that you don't accidently dispatch the
> > controller during bootstrapping.
> > 
> >>         parent::setUp();
> >>     }
> >> 
> >> method into my testcase and trying to set the
> >> $this->frontController=$front
> >> but the global variable that gets set in index.php is not available. What
> >> am
> >> I doing wrong here? Any help is appreciated.
> > 
> > -- 
> > Matthew Weier O'Phinney
> > Software Architect       | [EMAIL PROTECTED]
> > Zend Framework           | http://framework.zend.com/
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Zend_Test_PHPUnit_ControllerTestCase-with-bootstrap-php-file-tp19247111p19249003.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 

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

Reply via email to