PhpUnit – UserTest\Framework\TestCase' not found in […] SampleTest.php

Home Forums Learn ZF2 PhpUnit – UserTest\Framework\TestCase' not found in […] SampleTest.php

This topic contains 1 reply, has 2 voices, and was last updated by  Slavey Karadzhov 3 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #293

    Hi,

    I take a second to thanks you for this amazing and clear Book that’s Learn ZF2: Learning by exemple.

    Now the problem 🙂

    On chapter 19.1, I’m trying to make use of PhpUnit but still get this error:
    PHP Fatal error: Class 'UserTest\Framework\TestCase' not found in /Users/frederick/Documents/www-dev/private/April/module/User/tests/User/SampleTest.php on line 7

    Here the complete stack:
    Fatal error: Class ‘UserTest\Framework\TestCase’ not found in /Users/frederick/Documents/www-dev/private/April/module/User/tests/User/SampleTest.php on line 7

    Call Stack:
    0.0014 339544 1. {main}() /private/var/folders/2h/yq07tp9j29sf1q1nmr0bk6gm0000gn/T/ide-phpunit.php:0

    PHP Stack trace:
        0.0951     837472   2. IDE_Base_PHPUnit_TextUI_Command::main() /private/var/folders/2h/yq07tp9j29sf1q1nmr0bk6gm0000gn/T/ide-phpunit.php:506
    PHP   1. {main}() /private/var/folders/2h/yq07tp9j29sf1q1nmr0bk6gm0000gn/T/ide-phpunit.php:0
        0.0951     843064   3. PHPUnit_TextUI_Command->run() /private/var/folders/2h/yq07tp9j29sf1q1nmr0bk6gm0000gn/T/ide-phpunit.php:268
    PHP   2. IDE_Base_PHPUnit_TextUI_Command::main() /private/var/folders/2h/yq07tp9j29sf1q1nmr0bk6gm0000gn/T/ide-phpunit.php:506
        0.1965    1091400   4. PHPUnit_Runner_BaseTestRunner->getTest() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:150
    PHP   3. PHPUnit_TextUI_Command->run() /private/var/folders/2h/yq07tp9j29sf1q1nmr0bk6gm0000gn/T/ide-phpunit.php:268
        0.2583    1286368   5. PHPUnit_Framework_TestSuite->addTestFiles() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/Runner/BaseTestRunner.php:96
    PHP   4. PHPUnit_Runner_BaseTestRunner->getTest() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:150
    PHP   5. PHPUnit_Framework_TestSuite->addTestFiles() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/Runner/BaseTestRunner.php:96
    PHP   6. PHPUnit_Framework_TestSuite->addTestFile() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:416
        0.2584    1286896   6. PHPUnit_Framework_TestSuite->addTestFile() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:416
    PHP   7. PHPUnit_Util_Fileloader::checkAndLoad() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:355
        0.2608    1373952   7. PHPUnit_Util_Fileloader::checkAndLoad() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:355
    PHP   8. PHPUnit_Util_Fileloader::load() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php:76
        0.2609    1374168   8. PHPUnit_Util_Fileloader::load() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php:76
    PHP   9. include_once() /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php:92
        0.2702    1378544   9. include_once('/Users/frederick/Documents/www-dev/private/April/module/User/tests/User/SampleTest.php') /Users/frederick/Documents/www-dev/private/April/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php:92

    I’m using PhpStorm as IDE an the “ctrl-click” on “Framework\TestCase” in SampleTest.php bring me to the TestCase class as expected. PhpUnit is running; if I withdraw “extends Framework\TestCase” from SampleTest.php I got this result:

    /usr/bin/php /private/var/folders/2h/yq07tp9j29sf1q1nmr0bk6gm0000gn/T/ide-phpunit.php --no-configuration /Users/frederick/Documents/www-dev/private/April/module/User/tests
    Testing started at 12:53 ...
    string(8) "UserTest"
    PHPUnit 3.7.33 by Sebastian Bergmann.
    
    Empty test suite.
    
    Time: 190 ms, Memory: 1.75Mb
    
    No tests executed!
    
    Process finished with exit code 0
    

    May be I forgot or misunderstood something, have you an hint to get me out of this please? 🙂

    #294

    Slavey Karadzhov
    Participant

    Here the complete stack:
    Fatal error: Class ‘UserTest\Framework\TestCase’ not found in /Users/frederick/Documents/www-dev/private/April/module/User/tests/User/SampleTest.php on line 7

    Try going into the User module and from there run the class_map generation:

    
    cd /Users/frederick/Documents/www-dev/private/April/module/User/
    php ../../vendor/bin/classmap_generator.php
    

    And after that run again phpunit.

    Hope this helps.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.