mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
19 lines
478 B
PHP
19 lines
478 B
PHP
<?php
|
|
|
|
namespace Tests\Traits;
|
|
|
|
use Mockery;
|
|
use Mockery\MockInterface;
|
|
|
|
trait InteractsWithIoc
|
|
{
|
|
/**
|
|
* Mock an IOC dependency, for example an injected service in controllers.
|
|
*/
|
|
protected static function mockIocDependency(string $abstract, ...$args): MockInterface
|
|
{
|
|
return tap(Mockery::mock($abstract, ...$args), static function (MockInterface $mocked) use ($abstract): void {
|
|
app()->instance($abstract, $mocked);
|
|
});
|
|
}
|
|
}
|