Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep getting 'You have requested a non-existent service "test.client"' in Symfony2 Beta3

I'm trying to setup a unit test but whenever I run "phpunit -c app" I get this error:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "test.client".

The code in my test case is just:

public function testNonAuthenticatedPathsIndex()
{
    $client = $this->createClient();
}

If I don't make the call to createClient everything runs correctly. I've checked AppKernel.php to make sure the FrameworkBundle (I believe that's where this service is defined) is definitely still in there and it is.

I'm a bit confused as to what might be causing this as I've managed to do this kind of thing before.

Thanks for any help.

like image 730
pogo Avatar asked Jun 02 '11 10:06

pogo


3 Answers

Have you enabled the framework.test option in config_test.yml?

framework:
  test: ~
like image 59
Ajb Avatar answered Oct 05 '22 15:10

Ajb


In phpunit.xml you should have env variable like:

<env name="APP_ENV" value="test"/>
like image 10
Karol Gasienica Avatar answered Oct 05 '22 15:10

Karol Gasienica


I had this problem with symfony version 3.3.13.

The config_test.yml file was fine, but I did the same mistake.

I solved adding the <server name ="APP_ENV" value="test" /> option under php in the phpunit.xml file

like image 5
matiux Avatar answered Oct 05 '22 14:10

matiux