Skip to content

Commit 1e7076c

Browse files
authored
fix(laravel): register ErrorProvider (#7018)
fixes #6998
1 parent 42991b9 commit 1e7076c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Diff for: src/Laravel/ApiPlatformProvider.php

+2
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ public function register(): void
445445
return new CollectionProvider($app->make(Pagination::class), new LinksHandler($app, $app->make(ResourceMetadataCollectionFactoryInterface::class)), $app->tagged(QueryExtensionInterface::class), new ServiceLocator($tagged));
446446
});
447447

448+
$this->app->tag([ItemProvider::class, CollectionProvider::class, ErrorProvider::class], ProviderInterface::class);
449+
448450
$this->app->singleton(CallableProvider::class, function (Application $app) {
449451
$tagged = iterator_to_array($app->tagged(ProviderInterface::class));
450452

Diff for: src/Laravel/Tests/JsonLdTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,15 @@ public function testError(): void
330330
$this->assertArrayHasKey('trace', $content);
331331
}
332332

333+
public function testErrorNotFound(): void
334+
{
335+
$response = $this->get('/api/books/asd', ['accept' => 'application/ld+json']);
336+
$response->assertStatus(404);
337+
$content = $response->json();
338+
$this->assertArrayHasKey('status', $content);
339+
$this->assertEquals(404, $content['status']);
340+
}
341+
333342
public function testRelationWithGroups(): void
334343
{
335344
WithAccessorFactory::new()->create();

0 commit comments

Comments
 (0)