i just try to go in this : I have a class A which uses services of class B. To isolate this class A and to test it I would like to use Mockery and stub class B.
To do so I did
public function testMock()
{
$driver = Mockery::mock('Driver');
App::instance('Driver',$driver);
$driver->shouldReceive('get')->once()->andReturn('Did the job');
$request = new BSRequest($driver);
$this->assertEquals($request->get(),'Did the job');
}
But i get always this message after running test ErrorException: Argument 1 passed to BSrequest::__construct() must be an instance of Driver, instance of Mockery_0_Library_Driver given, called in /var/www/laravel/app/tests/ExampleTest.php on line 56 and defined
And my BSrequest is just this:
class BSrequest {
private $driver;
public function __construct(Driver $driver) {
$this->driver = $driver;
}
function get() {
return $this->driver->get();
}}
Could you tell me how to achieve this ? Thanks