I have a class that uses Str::random()
which I would like to test.
But when I use Str::shouldReceive('random')
in my test, I get a BadMethodCallException saying the method shouldReceive does not exist.
I also tried to mock the class directly and bind it to the IOC but it keeps executing the original class, generating a random string and not the return value I set on the mock.
$stringHelper = Mockery::mock('Illuminate\Support\Str');
$this->app->instance('Illuminate\Support\Str', $stringHelper);
//$this->app->instance('Str', $stringHelper);
$stringHelper->shouldReceive('random')->once()->andReturn('some password');
//Str::shouldReceive('random')->once()->andReturn('some password');