Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
    
First you need to enter into project directory. Then only the command will work.. –  Manivasagan Oct 16 '12 at 5:54
add comment

2 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
pretty much that should be it, agreed –  edorian Sep 26 '11 at 18:46
add comment

I had the same problem today testing my controllers. Turns out just following the Book's command for it doesn't work, since PHPUnit can't find the test classes. I managed to find a workaround, just specify the test file you'd like tested, and it'll work.

phpunit -c app src/Acme/DemoBundle/Tests/Utility/CalculatorTest.php
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.