简体   繁体   English

phing phpunit“已注册stackIndex为“ 1”的插件”错误

[英]Phing phpunit “plugin with stackIndex ”1“ already registered” error

For my Zend Framework (v1.12) project deployment Im using Phing. 对于我的Zend Framework(v1.12)项目部署,我使用Phing。 It deploys front-end and back-end applications. 它部署前端和后端应用程序。 Everything goes fine, untill Phing starts phpunit testing: 一切顺利,直到Phing开始phpunit测试:

<!-- Testing backend -->    
<target name="backend-test" description="Testing backend system"> 
    <phpunit codecoverage="false" haltonerror="true" haltonfailure="true" printsummary="true" bootstrap="${path.build}/${DSTAMP}${TSTAMP}/admin/tests/bootstrap.php">
        <batchtest>
            <fileset dir="${path.build}/${DSTAMP}${TSTAMP}/admin/tests">
                <include name="**/*Test.php" />
            </fileset>
        </batchtest>
       <formatter type="summary" usefile="false" />
    </phpunit>  
</target>

<!-- Testing frontend environment -->   
<target name="site-test" description="Testing frontend system"> 
    <phpunit codecoverage="false" haltonerror="true" haltonfailure="true" printsummary="true" bootstrap="${path.build}/${DSTAMP}${TSTAMP}/site/tests/bootstrap.php">
        <batchtest>
            <fileset dir="${path.build}/${DSTAMP}${TSTAMP}/site/tests">
                <include name="**/*Test.php" />
            </fileset>
        </batchtest>
       <formatter type="summary" usefile="false" />
    </phpunit>  
</target>

Back-end part phpunit tests succeed, but when it starts testing front-end - it fails it error: 后端部分phpunit测试成功,但是当它开始测试前端时-失败,错误:

[phingcall] Plugin with stackIndex "1" already registered [phingcall] #0 /var/www/zend/Controller/Front.php(733): Zend_Controller_Plugin_Broker->registerPlugin(Object(Application_Plugin_ACL), 1) [phingcall] #1 /var/www/_qa/build/201311181711/admin/application/Bootstrap.php(199): Zend_Controller_Front->registerPlugin(Object(Application_Plugin_ACL), 1)....... [phingcall]堆栈索引为“ 1”的插件已注册[phingcall]#0 /var/www/zend/Controller/Front.php(733):Zend_Controller_Plugin_Broker-> registerPlugin(Object(Application_Plugin_ACL),1)[phingcall]#1 / var / www / _qa / build / 201311181711 / admin / application / Bootstrap.php(199):Zend_Controller_Front-> registerPlugin(Object(Application_Plugin_ACL),1).......

Any ideas? 有任何想法吗? Your help would be appreciated. 您的帮助将不胜感激。

Your bootstrap is being called twice (or at least the resource [ _init function]). 您的引导程序被调用两次(或至少调用资源[ _init函数])。

You get this error because you can't define an other plugin instance for the same stack index. 之所以会出现此错误,是因为您无法为同一堆栈索引定义其他插件实例。

You should try to find a way to mock all periferral classes loaded in your bootstrap and test each of these classes individually. 您应该尝试找到一种方法来模拟引导程序中加载的所有外围类,并分别测试每个类。

An other way would be to bootstrap your application in the phpUnit setup method and make sure it's destroyed in the teardown. 另一种方法是在phpUnit设置方法中引导您的应用程序,并确保它在拆卸中被销毁。 This will be more ressource instensive and will most likely slow down your tests as the whole Zend stack will be instanciated, then killed, then re-instantiated for each of your test cases. 这将更加耗费资源,并且很可能会减慢测试速度,因为将针对每个测试用例实例化整个Zend堆栈,然后将其杀死,然后重新实例化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM