Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit reports a PHPUnit_Framework_Exception

I added a simple test to a bundle.

As suggested in the manual I tried to have PHPUnit load the configuration with:

phpunit -c /app

phpunit.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
    backupGlobals               = "false"
    backupStaticAttributes      = "false"
    colors                      = "true"
    convertErrorsToExceptions   = "true"
    convertNoticesToExceptions  = "true"
    convertWarningsToExceptions = "true"
    processIsolation            = "false"
    stopOnFailure               = "false"
    syntaxCheck                 = "false"
    bootstrap                   = "bootstrap.php.cache" >

    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>../src/*Bundle/Tests</directory>
        </testsuite>
    </testsuites>
</phpunit> 

The error message I get is:

root@h0x03:/var/www/fi/FrontendIntegrator# phpunit -c app/
PHP Fatal error:  Uncaught exception 'PHPUnit_Framework_Exception' with message 'Neither "Project Test Suite.php" nor "Project Test Suite.php" could be opened.' in /usr/share/php/PHPUnit/Util/Skeleton/Test.php:102
Stack trace:
#0 /usr/share/php/PHPUnit/TextUI/Command.php(157): PHPUnit_Util_Skeleton_Test->__construct('Project Test Su...', '')
#1 /usr/share/php/PHPUnit/TextUI/Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#2 /usr/bin/phpunit(49): PHPUnit_TextUI_Command::main()
#3 {main}
  thrown in /usr/share/php/PHPUnit/Util/Skeleton/Test.php on line 102

PHPUnit apparently loads the file and tries to find a PHP-file named after the test suites name. I cannot find any information on why it does so or how such a file should look like.

like image 723
Raffael Avatar asked Feb 22 '23 21:02

Raffael


1 Answers

It seems like PHPUnit tries to find a file named after the name-attribute of the testsuite-tag

  1. if it either cannot find any tests (wrong naming or wrong directory) or

  2. if there is a fatal error occuring in a test-script; which occures so early that PHPUnit cannot identify the content of that file as a test - as no class could be loaded up until that point.

like image 94
Raffael Avatar answered Mar 28 '23 18:03

Raffael