4
votes

I have successfully setup a symfony 3.2.4 project with the following commands :

symfony new symfony_test
cd symfony_test
composer require --dev phpunit/phpunit ^6.0
composer update

Then I have the following error when I try to run the default test :

$ vendor/bin/phpunit tests/AppBundle/Controller/DefaultControllerTest.php

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in C:\Users\po.louis\PhpstormProjects\test\symfony_test\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.php on line 23

What am I missing?

2
which version of the framework are you using? - Matteo
You are testing the Symfony code from your project as well - and you will be pulling in a lot of other libraries as well, most of them (you'd hope) with many more tests. It will be useful to limit the tests you run to your own project/code (with phpunit.xml's 'whitelists'), and trust that the libraries (like Symfony) are well tested on their own - or go to the libraries and do a local composer install within them, to make sure you have all the support required. - Alister Bulman

2 Answers

2
votes

Seems not possibile yet on same version of the framework, as announced in the last weekly update:

This week Symfony continued refactoring tests to make use of the new PHPUnit namespaces.

Hope this will be available on all the supported version.

0
votes

Inside your composer.json edit

phpunit/phpunit ^6.0

to

phpunit/phpunit ^5.7

and all works fine.

As Matteo wrote to you isn't supported yet 6.0 version