Hi,  I am using zf.sh to create my controllers/models/actions so my
test classes all inherit from Zend_Test_PHPUnit_ControllerTestCase.

My problem is that for some reason the objects that I try to
instantiate only work if I do a require/include.  The include path is
correct since I do not have to specify the whole path just include
'MyApp/Foo.php' for MyApp_Foo class

this is the result from print_r(spl_autoload_functions())

Array
(
    [0] => phpunit_autoload
    [1] => Array
        (
            [0] => Zend_Loader_Autoloader
            [1] => autoload
        )

)

My phpunit.xml

<phpunit bootstrap="./bootstrap.php">
    <testsuite name="Application Test Suite">
        <directory>./application</directory>
    </testsuite>
    <testsuite name="Library Test Suite">
        <directory>./library</directory>
    </testsuite>

    <filter>
        <whitelist>
            <directory suffix=".php">../../library/Doctrine</directory>
            <directory suffix=".php">../../library/Utils</directory>
            <directory suffix=".php">../../library/Smarty</directory>
            <directory suffix=".php">../../library/HTMLPurifier</directory>
        </whitelist>
    </filter>
</phpunit>

The bootstrap.php

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) .
'/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ?
getenv('APPLICATION_ENV') : 'testing'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to