Skip to content

Commit

Permalink
fix(graphql): add unit test for interitance case
Browse files Browse the repository at this point in the history
  • Loading branch information
josef.wagner committed Apr 15, 2024
1 parent 522e1cf commit f4580c0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/GraphQl/Tests/State/Provider/ResolverProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use ApiPlatform\GraphQl\Resolver\QueryItemResolverInterface;
use ApiPlatform\GraphQl\State\Provider\ResolverProvider;
use ApiPlatform\GraphQl\Tests\Fixtures\ApiResource\ChildFoo;
use ApiPlatform\GraphQl\Tests\Fixtures\ApiResource\ParentFoo;
use ApiPlatform\Metadata\GraphQl\Query;
use ApiPlatform\Metadata\GraphQl\QueryCollection;
use ApiPlatform\State\ProviderInterface;
use PHPUnit\Framework\TestCase;
Expand All @@ -35,4 +38,18 @@ public function testProvide(): void
$provider = new ResolverProvider($decorated, $resolverLocator);
$this->assertEquals($res, $provider->provide($operation, [], $context));
}

public function testProvideInheritedClass(): void
{
$res = new ChildFoo();
$operation = new Query(class: ParentFoo::class, resolver: 'foo');
$context = [];
$decorated = $this->createMock(ProviderInterface::class);
$resolverMock = $this->createMock(QueryItemResolverInterface::class);
$resolverMock->expects($this->once())->method('__invoke')->willReturn($res);
$resolverLocator = $this->createMock(ContainerInterface::class);
$resolverLocator->expects($this->once())->method('get')->with('foo')->willReturn($resolverMock);
$provider = new ResolverProvider($decorated, $resolverLocator);
$this->assertEquals($res, $provider->provide($operation, [], $context));
}
}

0 comments on commit f4580c0

Please sign in to comment.