Skip to content

Commit 6986321

Browse files
author
Roman Skoropadsky
committed
fix: added non regression test
1 parent defc50b commit 6986321

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/GraphQl/Tests/State/Provider/ReadProviderTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace ApiPlatform\GraphQl\Tests\State\Provider;
1515

16+
use ApiPlatform\Exception\ItemNotFoundException;
1617
use ApiPlatform\GraphQl\Serializer\SerializerContextBuilderInterface;
1718
use ApiPlatform\GraphQl\State\Provider\ReadProvider;
1819
use ApiPlatform\Metadata\GraphQl\Query;
@@ -36,6 +37,25 @@ public function testProvide(): void
3637
$provider->provide($operation, [], $context);
3738
}
3839

40+
/**
41+
* Tests that provider returns null if resource is not found.
42+
* @see https://github.com/api-platform/core/issues/6072
43+
*/
44+
public function testProvideNotExistedResource(): void
45+
{
46+
$context = ['args' => ['id' => '/dummy/1']];
47+
$operation = new Query(class: 'dummy');
48+
$decorated = $this->createMock(ProviderInterface::class);
49+
$iriConverter = $this->createMock(IriConverterInterface::class);
50+
$iriConverter->expects($this->once())->method('getResourceFromIri')->with('/dummy/1');
51+
$iriConverter->method('getResourceFromIri')->willThrowException(new ItemNotFoundException());
52+
$serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
53+
$provider = new ReadProvider($decorated, $iriConverter, $serializerContextBuilder, '.');
54+
$result = $provider->provide($operation, [], $context);
55+
56+
$this->assertNull($result);
57+
}
58+
3959
public function testProvideCollection(): void
4060
{
4161
$info = $this->createMock(ResolveInfo::class);

0 commit comments

Comments
 (0)