0

I can use CLI(phpunit --configuration phpunit.xml) to run the tests normally.

The tests directory has such hierarchy:


tests
├── application
│   ├── bootstrap.php
│   ├── controllers
│   │   └── ControllerTest.php
│   └── FirstTest.php
├── library
├── log
│   ├── report
│   └── testdox.html
└── phpunit.xml

Contents in the files

  1. phpunit.xml

    <phpunit bootstrap="./application/bootstrap.php" colors="true">
    <testsuite name="Webguide Unit Test">
        <directory>./</directory>
    </testsuite>
    
    <filter>
        <whitelist>
            <directory suffix=".php">../library/</directory>
            <directory suffix=".php">../application/</directory>
            <exclude>
                <directory suffix=".phtml">../application/</directory>
                        <file>../application/Bootstrap.php</file>
                            <file>../application/controllers/ErrorController.php</file>
            </exclude>
        </whitelist>
    </filter>
    
    <logging>
        <log highlowerbound="80" lowupperbound="50" highlight="true" yui="true" charset="UTF-8" target="./log/report" type="coverage-html"/>
        <log target="./log/testdox.html" type="testdox-html"/>
    </logging>
    </phpunit>
    
  2. application/bootstrap.php

    <?php
        error_reporting(E_ALL | E_STRICT);
    
        date_default_timezone_set('GMT');
    
        define('APPLICATION_ENV', 'testing');
    
        define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
    
        define('APPLICATION_CONFIG', APPLICATION_PATH . '/configs/application.ini');
    
        set_include_path(implode(PATH_SEPARATOR, array(
            realpath(APPLICATION_PATH . '/../library'),
            get_include_path()
        )));
    
        require_once 'Zend/Loader/Autoloader.php';
    
        Zend_Loader_Autoloader::getInstance();
    
        require_once 'Zend/Application.php';
    

(for those who are want to to set up Zend Test, here are are the references: Unit Testing with Zend Framework 1.11 and PHPUnit)

While I ran the tests in Zend Studio 9, I got an error message: "No test executed. Either a fatal error occurred, the launch was stopped manually or the script execution was halted with 'die/exit' statement".

And in the Console, the output is:

*Compile Error: /home/coiby/ZendStudio/plugins/com.zend.php.phpunit_9.0.1.201112141951/resources/ZendPHPUnit.php line 109 - require_once() [function.require]: Failed opening required '/var/www/webguide/tests/controllers/ControllerTest.php' (include_path='/var/www/webguide/library:.:/usr/share/php::/var/www/webguide:')*

According the the above information, I moved the directory "controllers/ControllerTest.php" to the upper one, i.e '/var/www/webguide/tests/controllers/ControllerTest.php' exists now.

But there's error, the output of the Console is:

*Debug Error: /webguide/library/Doctrine/Common/Cache/ApcCache.php line 52 - Call to undefined function Doctrine\Common\Cache\apc_fetch()*

How could this happen? I've installed PHP APC by pear, and this module is in the result of phpinfo(). And the tests are executed OK through CLI. Another thing I've checked is the php include path, I've already add /usr/share/php to Zend Studio include path.

Would anyone give a suggestion?

Thanks!

4

0 回答 0