ZF-7996: Zend_Bootstrap_BoostrapAbstract (line 354) is loading Zend_Db which is causing second unit test to fail

Description

When using "Fallback Autloader" with Zend_Test_PHPUnit_ControllerTestCase and Zend_Application, upon the second test setUp() the application is redeclaring Zend_Db even though Zend_Db was never explicitly declared anywhere in the project.

Comments

Here is the source code to reproduce the issue. It works fine when you do not use the fallback autoloader, for example, if I go to tests/application/Bootstrap.php and replacing the fallback autoloader line with the following code:

$autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('TestCase');

try using, for silence of the error redeclare


Zend_Loader_Autoloader::suppressNotFoundWarnings(true);

Zend_Application::bootstrap(), execute all resources, if not passing the resource wanted. In your case, beyond execute the resource FrontController execute the resource of the Db.

The issue is not that warnings are being raised, the problem lies that Zend attempts to autoload blindly on line 354 of Zend_Bootstrap_BootstrapAbstract, the use of class_exists($plugin) where $plugin is "db", "view" (or whatever you have in your application.ini resource.*) this causes class_exists to call the autoloader with "db" which when not using useFallbackAutoloader(true) causes it to blindly check include paths for the file "Db.php" which it finds in my ZF include path but as the class does not exist within the file it will attempt to autoload it again upon the second testcase and crash with a fatal error that class Zend_Db is already initiated.

This error also affects live code, but produces warnings that are surpressed, if you try loading a zend website using the bootstrap within a debugger such as Zend or XDebug the error messages should be shown in the console.