Why does the call of PHPUnit in the class CTestCase works:
require_once('PHPUnit/Autoload.php');
....
PHPUnit_Framework_Assert::assertNotNull($object);
But if I call it the same way in a file of components directory it shows me:
require_once(PHPUnit/Autoload.php): failed to open stream: No such file or directory
Even if I add the same imports as in CTestCase it doesn't work.
require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('PHPUnit/Autoload.php');
spl_autoload_unregister('phpunit_autoload');
Yii::registerAutoloader('phpunit_autoload');
It shows me:
require_once(PHPUnit/Util/Filesystem.php): failed to open stream: No such file or directory
I am using namespaces and want to use design-by-contract.
I really hope someone can help me.
Thanks to this post I found the solution for my problem. Here is the code to enable Design-By-Contract asserts of PHPUnit in Yii Controllers and Helper Classes.