0

I am a little lost on how to perform integration test using mockery.

I have the following classes: TeacherController TeacherManager - Interface TeacherManagerImpl - Implementation

When it comes to mockery / PHPUnit, how do I call a method from my interface? It says that the interface can not be instantiated. I know it can't but how can I inject it into the test class or should I just do new on the implementation. Doing a new on the implementation just does not seem right to me.

Trevor
  • 363
  • 7
  • 20

1 Answers1

1

Thanks to Kindari in the Laravel IRC chat room In the Test setup method just bind the interface to the implementation and then set a private member variable using App::make. See below.

App::bind('FooInterface', 'FooImplementation'); 
$foo = App::make('FooInterface');

also app() is a shortcut to App::make

Mike Sherrill 'Cat Recall'
  • 91,602
  • 17
  • 122
  • 185
Trevor
  • 363
  • 7
  • 20