I have an application based on the Zend Framework that I am trying to use phpunit to generate skeletons for the test cases. Phpunit can't seem to find the parent classes of the classes I am trying to generate for:
phpunit --skeleton-test Default_Model_Person ../application/models/Person.php
PHPUnit 3.5.11 by Sebastian Bergmann.
PHP Fatal error: Class 'X1_Db_Table_Auditable' not found in /path/to/application/models/Person.php on line 3
Fatal error: Class 'X1_Db_Table_Auditable' not found in /path/to/application/models/Person.php on line 3
So I have for example application/models/Person.php
<?php
class Default_Model_Person extends X1_Db_Table_Auditable
{
In library/X1/Db/Table/Auditable.php is
<?php
class X1_Db_Table_Auditable extends X1_Db_Table
{
...
I have other test cases written by hand that phpunit can run on this application without a problem. I have also tried specifying the bootstrap file with --bootstrap and the config with --configuration to make sure that the path to the library should be found, but I can't seem to get this to work (th开发者_运维百科e result is the same as above). How can I get this library class to be found by phpunit to generate the skeleton?
I am fairly new to PHP, phpUnit and Zend, so please forgive my beginner questions ;) Thanks in advance!
You need to set up an autoloader to allow PHP to import the X1 and any other classes when referenced, typically in bootstrap.php.
require_once 'Zend/Loader/AutoLoader.php';
$autoloader = Zend_Loader_AutoLoader::getInstance();
$autoloader->registerNamespace('X1_');
精彩评论