Skip to content

Commit c21bb85

Browse files
committed
Refactoring
1 parent 48b7458 commit c21bb85

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/IdeHelper/RecursiveRelationsHook.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class RecursiveRelationsHook implements ModelHookInterface
127127

128128
public function run(ModelsCommand $command, Model $model): void
129129
{
130-
/** @var \Illuminate\Config\Repository $config */
130+
/** @var \Illuminate\Contracts\Config\Repository $config */
131131
$config = $command->getLaravel()->make('config');
132132

133133
$traits = class_uses_recursive($model);
@@ -162,7 +162,7 @@ public function run(ModelsCommand $command, Model $model): void
162162
*/
163163
protected function addRelationship(ModelsCommand $command, array $relationship, string $type): void
164164
{
165-
/** @var \Illuminate\Config\Repository $config */
165+
/** @var \Illuminate\Contracts\Config\Repository $config */
166166
$config = $command->getLaravel()->make('config');
167167

168168
$command->setProperty(

tests/IdeHelper/RecursiveRelationsHookTest.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Staudenmeir\LaravelAdjacencyList\Tests\IdeHelper;
44

55
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
6+
use Illuminate\Contracts\Config\Repository;
7+
use Illuminate\Contracts\Foundation\Application;
68
use Mockery;
79
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
810
use PHPUnit\Framework\TestCase;
@@ -16,11 +18,14 @@ class RecursiveRelationsHookTest extends TestCase
1618

1719
public function testTreeRelations(): void
1820
{
19-
$config = Mockery::mock();
21+
$config = Mockery::mock(Repository::class);
2022
$config->shouldReceive('get')->andReturn(true);
2123

24+
$app = Mockery::mock(Application::class);
25+
$app->shouldReceive('make')->andReturn($config);
26+
2227
$command = Mockery::mock(ModelsCommand::class);
23-
$command->shouldReceive('getLaravel')->andReturn(['config' => $config]);
28+
$command->shouldReceive('getLaravel')->andReturn($app);
2429
$command->shouldReceive('setProperty')->times(2);
2530
$command->shouldReceive('setProperty')->once()->with(
2631
'ancestorsAndSelf',
@@ -55,11 +60,14 @@ public function testTreeRelations(): void
5560

5661
public function testGraphRelations(): void
5762
{
58-
$config = Mockery::mock();
63+
$config = Mockery::mock(Repository::class);
5964
$config->shouldReceive('get')->andReturn(true);
6065

66+
$app = Mockery::mock(Application::class);
67+
$app->shouldReceive('make')->andReturn($config);
68+
6169
$command = Mockery::mock(ModelsCommand::class);
62-
$command->shouldReceive('getLaravel')->andReturn(['config' => $config]);
70+
$command->shouldReceive('getLaravel')->andReturn($app);
6371
$command->shouldReceive('setProperty')->times(2);
6472
$command->shouldReceive('setProperty')->once()->with(
6573
'ancestorsAndSelf',

0 commit comments

Comments
 (0)