AutoLoader Effect #2: Foreign Sources

I started experimenting with Selenium testcases. Therefor I wanted to use Extbase’s class “SeleniumBaseTestCase” as a root class for all my test cases. This wasn’t possible, because of AutoLoader Effect #1. The autoloader was not able to find this class, because it wasn’t part of Extbase’s “/Classes” directory and it also wasn’t mentioned in Extbase’s “/ext_autoload.php” file.

Well, thinking of AutoLoader Effect #1‘s solution, I simply added an according line to my own “/ext_autoload.php” file, in order to tell the autoloader where to find “SeleniumBaseTestCase”.

$extensionClassesPath = t3lib_extMgm::extPath('csevents') . 'Classes/';
return array(
    'tx_extbase_tests_seleniumbasetestcase' => t3lib_extMgm::extPath('extbase') . 'Tests/SeleniumBaseTestCase.php',
    'tx_csevents_tests_unit_domain_repository_repositorybasetestcase' => $extensionClassesPath . '../Tests/Unit/Domain/Repository/RepositoryBaseTestCase.php',

Effect: None – same error, the class cannot be found by the autoloader.

Reason: The autoloader splits the class name, it is searching for, by “_” and searches for the second part, which holds the extension name (“extbase” or “csevents” in my cases). Afterwards it searches for the “ext_autoload.php” file in the extension’s root directory. Thus, searching for “Tx_Extbase_…” makes the autoloader search for “ext_autoload.php” in the “extbase” directory, “my” ext_autoload is never used while searching for “Tx_Extbase_…”. Even if I define the correct solution, the autoloader will never listen to it. Line #3 has absolutly no effect as long as it is not part of the “extbase” extension. 🙁

Solution: None by myself. The extension itself (extbase in this case) has to define all necessary autoload-entries. In this particular case, I was glad that “SeleniumBaseTestCase” is a 1:1 extension of “tx_phpunit_selenium_testcase”, which can be found easily by the autoloader. Thus I used that one. Not nice, but successfull.


* Base Selenium testcase for the Extbase extension.
abstract class Tx_Extbase_SeleniumBaseTestCase extends tx_phpunit_selenium_testcase {

Leave a Reply