mercredi 20 décembre 2017

PHP - How to handle real test doubles that should live in the app namespace?

I have a client class which uses the magic __call method to construct and endpoint class. Similar to http://ift.tt/2DeeLYT.

My namespace for endpoints is App\Endpoints. Worth mentioning that all my endpoints extend from an abstract Endpoint class which contains all the logic needed. The endpoints themselves are pretty much empty with them only containing the endpoint url.

Now I want to test the magic method and don't really want to use a real endpoint from that namespace but rather want to write my own test double. In order to do that I have to put the test double inside the ClientTest class under the real namespace App\Endpoints. This class will only be available for this test.

Is there a better way to achieve this?

Aucun commentaire:

Enregistrer un commentaire