2013-07-06 62 views
0

我用Auth模块编写了一个ZF2应用程序。此Auth模块的设置在其Module.php文件中完成。如何防止在Zend Framework中加载模块2 phpunit test

我在Zend Framework 2单元测试教程(http://framework.zend.com/manual/2.2/en/tutorials/unittesting.html)中设置了一个测试,但要使用Application模块进行测试。在测试的bootstrap.php中我只包括在配置应用模块:

$config = array(
    'module_listener_options' => array(
     'module_paths' => $zf2ModulePaths, 
    ), 
    'modules' => array(
     'Application', 
    ) 
); 

而在phpunit.xml我只包括这个测试目录:

<phpunit bootstrap="Bootstrap.php"> 
    <testsuites> 
     <testsuite name="myApplication"> 
      <directory>./ApplicationTest</directory> 
     </testsuite> 
    </testsuites> 
</phpunit> 

我希望不要有验证模块正在加载,所以它应该被禁用的测试。但是我得到一个由Auth模块中的函数抛出的异常,所以我认为它是无论如何加载的。

难道我误解了引导,并且有没有办法阻止该模块被加载?

回答

0

也许不是完美的解决方案,但是以下工作:与

public function setUp() 
{ 
    $config = include '/path/to/config/application.config.php'; 
    $config['modules'] = array('Application'); 

    $this->setApplicationConfig($config); 

    parent::setUp(); 
} 

阵列替换方法安装程序可以包括其它模块。

相关问题