I am trying to use the unit test Silex application, but the Silex \ WebTestCase namespace was not found

I have installed phpunit 3.6.12 as well as Silex. In the root directory of my application, I have a test directory containing the trivial test file BlogFunctionTest.php

<? use Silex\WebTestCase; // BLOG: Front end test class BlogFunctionalTest extends Silex\WebTestCase { public function testIndex() { $this->assertGreaterThan(0, 1); } } ?> 

when I run phpunit from the command line, I get an error

 PHP Fatal error: Class 'Silex\WebTestCase' not found in {path}/BlogFunctionTest.php line 7 

which refers to the line where I am trying to extend WebTestCase. The same thing happens if I replace

 use Silex\WebTestCase; 

with

 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; 

Silex installs compared to my test file in

 ../vendor/silex/ 

Any advice is greatly appreciated, thanks!

+4
source share
1 answer

you need to define a load inside phpunit.xml.dist that indicates the load of your silex application, as it was done here https://github.com/joshuamorse/Silex-Boilerplate/blob/master/phpunit.xml.dist

+7
source

Source: https://habr.com/ru/post/1436266/


All Articles