Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-de-wit committed Jan 27, 2025
1 parent ba2dcaa commit e2e9364
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function getPackageProviders($app): array
/**
* @test
*/
public function it_auto_registration_off_model_hook(): void
public function it_auto_registers_model_hook(): void
{
/** @var Application $app */
$app = $this->app;
Expand All @@ -43,4 +43,24 @@ public function it_auto_registration_off_model_hook(): void
(array) $config->get('ide-helper.model_hooks', []),
);
}

/**
* @test
*/
public function it_auto_registers_model_hook_with_wrong_service_provider_order(): void
{
/** @var Application $app */
$app = $this->app;

$app->loadDeferredProvider(LaravelIdeHelperHookPaperclipServiceProvider::class);
$app->loadDeferredProvider(IdeHelperServiceProvider::class);

/** @var Repository $config */
$config = $app->get('config');

$this->assertContains(
PaperclipHook::class,
(array) $config->get('ide-helper.model_hooks', []),
);
}
}
2 changes: 2 additions & 0 deletions tests/Unit/Hooks/PaperclipHookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function it_writes_paperclip_properties(): void
/** @var ModelsCommand|MockInterface $command */
$command = Mockery::mock(ModelsCommand::class)
->shouldReceive('setProperty')
->once()
->with(
'foobar',
'\\Czim\\Paperclip\\Contracts\\AttachmentInterface|\\SplFileInfo|\\Czim\\FileHandling\\Storage\\File\\SplFileInfoStorableFile|\\Czim\\FileHandling\\Contracts\\Support\\RawContentInterface|string',
Expand All @@ -37,6 +38,7 @@ public function it_writes_paperclip_properties(): void
/** @var ModelWithAttachment|MockInterface $model */
$model = Mockery::mock(ModelWithAttachment::class)
->shouldReceive('getAttachedFiles')
->once()
->andReturn([
'foobar' => Mockery::mock(AttachmentInterface::class),
])
Expand Down

0 comments on commit e2e9364

Please sign in to comment.