lundi 23 mars 2015

How to access get method in a Test Class Symfony2

I have to write a test class to test my service methods. In my controllers I could access the service by doing $service = $this->get('myService'); and I could access my methods by doing $service->someMethod();.

Now I want to write a test class to test some of the service methods, I tried doing like the doc :



class ServiceTest extends \PHPUnit_Framework_TestCase {
public function testSomeMethod() {
$service = $this->get('myService');
....
}
}


When I launch the test I get something like :

Fatal error : Call to undefined method XXX\XXXBundle\Tests\Services\ServicesTest::get() in ...

So my question is how can I use get method to be able to call my service methods


Aucun commentaire:

Enregistrer un commentaire