I'm developing a project in symfony2 and I'm new with unit testing.
I have installed PHPUnit 3.6.10 via PEAR and it works from the terminal when I digit the phpunit command.
I wrote my first test class following the SensioLab suggestions (http://symfony.com/doc/current/book/testing.html) but when I use the command
php -c app src/My/CalendarBundle/Tests/Calendar/CalendarTest.php
I got
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /Library/WebServer/Documents/calendar/src/My/CalendarBundle/Tests/Calendar/CalendarTest.php on line 7
Here you are my test class:
<?php
namespace My\CalendarBundle\Tests\Calendar;
use My\CalendarBundle\Calendar\Calendar;
class CalendarTest extends \PHPUnit_Framework_TestCase
{
public function testGetNextMonth()
{
$calendar = new Calendar('09', '2012', null);
$result = $calendar->getNextMonth();
$this->assertEquals(10, $result);
}
}
I read this discussion Why, Fatal error: Class 'PHPUnit_Framework_TestCase' not found in ...? but the symfony documentation doesn't say to include PHPUnit...
What I'm doing wrong? Thank you
I just had a similar issue (with DoctrineFixturesBundle), and solved it by adding PHPUnit to Symfony (as opposed to installing PHPUnit via PEAR).
What worked for me was:
1) add "phpunit/phpunit": "4.0.*"
to the require
section of composer.json
:
{
"require": {
...
"phpunit/phpunit": "4.0.*"
}
}
2) running from the commandline:
php composer.phar update phpunit/phpunit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With