简体   繁体   中英

Phing phpunit “plugin with stackIndex ”1“ already registered” error

For my Zend Framework (v1.12) project deployment Im using Phing. It deploys front-end and back-end applications. Everything goes fine, untill Phing starts phpunit testing:

<!-- 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:

[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).......

Any ideas? Your help would be appreciated.

Your bootstrap is being called twice (or at least the resource [ _init function]).

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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