On Jun 3, 2011, at 4:15 PM, MTTrading wrote:

> I have been trying to solve this for two days and need some help.  I'm new
> to PHPUnit and unit testing in general. 
> 
> My problem is that when I do a dispatch it will only use the default module,
> or that is what I believe is happening.
> 
> 
I cannot see a problem with the code you sent, but I had this same problem, as 
have others. Somewhere during the bootstrap, during a test, there is an error 
or exception and then PHPUnit is loading a fresh instance of the 
FrontController.  You will need to find the error, I found my by looking in the 
error log, fix it and you should get the result you want. My first error was 
not setting the timezone and the second was my MySql socket. Others have 
experienced other errors.

Take a look at your error log and I think you will find the problem.

If you find it and need help fixing, post the problem and code and I will try 
to help.
> 
> 
> I'm supplying code from my bootstrap, and the test files.  My directory
> structures and the two methods first one fails
> 
> And the second one passes.  The login process is working from the web pages.
> 
> 
> 
> 
> When I run this test case:
> 
> public function testLoginControllerHasLoginAction(){
> 
> $this->dispatch('/mttauthacl/login/login');
> 
>               $this->assertModule('mttauthacl');
> 
>               $this->assertController('login');
> 
>               $this->assertAction('login'); 
> 
> }
> 
> It fails on "$this->assertModule('mttauthacl');" with a failure of : Failed
> asserting last module used <"default"> was "mttauthacl".
> 
> 
> 
> When I run this next test method it passes:
> 
> public function testWhenLayoutHasLoginFormButton(){
> 
> $this->dispatch('/default/index');
> 
>               $this->assertAction('index');
> 
> $this->assertQueryCount('#loginbtn', 1);
> 
> }
> 
> Which is what leads me to believe the test environment is not seeing my
> module path for some reason.  The application and the testing directories
> are set up the same as described below.
> 
> 
> 
> APP Directory Structure:
> 
> /application/modules/mttauthacl/controllers
> 
> 
> 
> Testing ENV Directory Structure
> 
> /tests/application/modules/mttauthacl/controllers
> 
> 
> 
> My test file is LoginControllerTest.php and the cod 
> 
> =======================================================
> 
> ============= LoginControllerTest. Start=====================
> 
> =======================================================
> 
> require_once 'PHPUnit/Framework/TestCase.php';
> 
> if (!defined('APPLICATION_PATH')) {
> 
>               require_once dirname(dirname(dirname(__FILE__))) .
> '../../../bootstrap.php';
> 
> }
> 
> $autoloader = new Zend_Application_Module_Autoloader(
> 
>               array(    
> 
> 'namespace' => 'Mttauthacl_',
> 
>                              'basePath' => APPLICATION_PATH .
> '/modules/mttauthacl',
> 
>               )
> 
> );
> 
> 
> 
> class Mttauthacl_LoginControllerTest extends
> Zend_Test_PHPUnit_ControllerTestCase
> 
> {
> 
>               private  $_authService;
> 
>               private  $_loginForm;
> 
>               private  $_loginEmail;
> 
>               private  $_password; 
> 
> 
> 
>    public function setUp(){
> 
>        /* Setup Routine */
> 
>               $this->bootstrap = new Zend_Application(APPLICATION_ENV,
> APPLICATION_PATH . '/configs/application.ini');
> 
>               parent::setUp();                
> 
>    }  
> 
> ============= LoginControllerTest. End =====================
> 
> 
> 
> ======================================================
> 
> =============         Bootstrap Start       =====================
> 
> =======================================================
> 
>    error_reporting(E_ALL | E_STRICT);
> 
> 
> 
>    // Define root path of project
> 
>    defined('BASE_PATH')
> 
>        || define('BASE_PATH', realpath(dirname(__FILE__) . '/../'));
> 
> 
> 
>    // Define path to application directory
> 
>    defined('APPLICATION_PATH')
> 
>        || define('APPLICATION_PATH', realpath(dirname(__FILE__) .
> '/../application'));
> 
> 
> 
>    // Define application environment
> 
>    defined('APPLICATION_ENV')
> 
>        || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ?
> getenv('APPLICATION_ENV') : 'testing'));
> 
> 
> 
>    // Ensure library/ is on include_path
> 
>    set_include_path(implode(PATH_SEPARATOR, array(
> 
>        realpath(APPLICATION_PATH . '/../library'),
> 
>        get_include_path(),
> 
>    )));
> 
> 
> 
>    require_once 'Zend/Loader/Autoloader.php';
> 
> $loader = Zend_Loader_Autoloader::getInstance();
> 
> =======================================================
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://zend-framework-community.634137.n4.nabble.com/PHPUnit-is-only-dispatching-default-module-why-tp3572200p3572200.html
> Sent from the Zend Framework mailing list archive at Nabble.com.

Shawn Ostler
InclusiveDv
[email protected]
801-686-0353



--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to