mirror of
https://github.com/koel/koel
synced 2024-12-03 01:09:23 +00:00
24 lines
523 B
PHP
24 lines
523 B
PHP
<?php
|
|
|
|
namespace Tests\Traits;
|
|
|
|
use Mockery;
|
|
use Mockery\MockInterface;
|
|
|
|
trait InteractsWithIoc
|
|
{
|
|
/**
|
|
* Mock an IOC dependency, for example an injected service in controllers.
|
|
*
|
|
* @param string $abstract
|
|
* @param array $args
|
|
*
|
|
* @return MockInterface
|
|
*/
|
|
protected function mockIocDependency($abstract, ...$args)
|
|
{
|
|
return tap(Mockery::mock($abstract, ...$args), function ($mocked) use ($abstract) {
|
|
app()->instance($abstract, $mocked);
|
|
});
|
|
}
|
|
}
|