symfony functional test / tasks autoloading problems

Solution:

In the test setup / task:

    $autoloader = sfSimpleAutoload::getInstance();
    $autoloader->addDirectory(sfConfig::get('sf_lib_dir'));
    $autoloader->addDirectory(sfConfig::get('sf_app_lib_dir'));
    $autoloader->register(); 

Problem:

 

When providing a class replacement in the apps/ dir for a class in a plugin's lib folder, the replaced class is ignored in functional tests.

Using the web frontend it works perfectly.

Experimental setup using a fresh symfony 1.3.3 installation:

apps/
  frontend/
    lib/
      myClass.class.php

plugins/
  myPlugin/
    lib/
      myClass.class.php

When using the web frontend the myClass.class.php file in apps/frontend/lib is used as expected.

When running a functional test which uses myClass the file in apps/frontend/lib is ignored. Instead the original plugins/myPlugin/lib/myClass.class.php is used.


 

Digging around a little brought the following results (and further questions):

Invoking the web frontend causes the symfony autoloading framework to react like that:

First, the sfCoreAutoload says that it doesn't have the file, then the sfAutoloader handles it.

When executing the functional test, the sfCoreAutoload again says that it doesn't have the file, however then the sfSimpleAutoload gets called, which loads the file, but the wrong version.

Now the problems seems to be, that sfSimpleAutoload is configured to search plugins only wheras sfAutoloader itself indexes files from all locations.

 

Why is the sfsimpleautoloader even invoked, and not the core autoloader? sfPluginConfiguration initializes it in its constructor, however, it does that only if the project configuration passed to it is an instance of sfApplicationConfiguration.

Remember inheritance: frontendConfig <- sfApplicationConfiguration <- ProjectConfiguration <- sfProjectConfiguration

During a web request the sfPluginConfiguration is called once for each plugin, with ProjectConfiguration -> no simple autoloaders, everything works

During function testing however, the plugins are loaded (i.e. sfPluginConfigurations are constructed) three times, the first two times with frontendConfig instead of ProjectConfiguration, which triggers simple autoloading -> bad

Which leads to the following questions:

Is this triple-loading supposed to happen?

Since that simple autoloading stuff is not from us, I guess it is supposed to be there and working, right?

Do we have similiar overriding situations somewhere, and if yes, is it working?

And finally: what are we doing wrong, or if that is not the case, where is the bug in symfony?