Str::random()
テストしたいクラスがあります。
しかしStr::shouldReceive('random')
、テストで使用すると、メソッド shouldReceive が存在しないという BadMethodCallException が発生します。
また、クラスを直接モックして IOC にバインドしようとしましたが、元のクラスを実行し続け、モックに設定した戻り値ではなく、ランダムな文字列を生成します。
$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');