Yii and PHPUnit Autoloaders conflict

108 views Asked by At

This question is related to an earlier question I had, but I learned a bit more now, and that question became too messy, so I start a new question here.

I am trying to use Yii and PHPUnit at the same time, and try to get the Autoloading working. I found an Autoloader here that I am using for PHPUnit. I read here that I should register the Yii autoloader last.

With the following bootstrap file:

<?php
require_once(__DIR__.'/../tests/AutoLoader.php');
Toolbox\Testing\AutoLoader::registerDirectory(__DIR__.'/../protected');
require_once(__DIR__.'/../yii-1.1.14.f0fee9/yii.php');
print_r(spl_autoload_functions());
?>

I see that the autoloaders are in place in the right order:

[1] => Array
    (
        [0] => Toolbox\Testing\AutoLoader
        [1] => loadClass
    )

[2] => Array
    (
        [0] => YiiBase
        [1] => autoload
    )

However, I still can't import the class I need. It goes wrong in YiiBase in the function autoload in the line include($className.'.php');, which tries to include a class name without a path attached to it.

  1. Why does Yii try to load a class without a full path to the file needed?
  2. How can I make this combination to work?
0

There are 0 answers