1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TheCodingMachine\GraphQL\Controllers; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use Psr\Container\ContainerExceptionInterface; |
9
|
|
|
use Psr\Container\ContainerInterface; |
10
|
|
|
use Psr\Container\NotFoundExceptionInterface; |
11
|
|
|
use TheCodingMachine\GraphQL\Controllers\Fixtures\TestController; |
12
|
|
|
use TheCodingMachine\GraphQL\Controllers\Security\VoidAuthenticationService; |
13
|
|
|
use TheCodingMachine\GraphQL\Controllers\Security\VoidAuthorizationService; |
14
|
|
|
|
15
|
|
|
class AggregateControllerQueryProviderTest extends AbstractQueryProviderTest |
16
|
|
|
{ |
17
|
|
|
public function testAggregate() |
18
|
|
|
{ |
19
|
|
|
$controller = new TestController(); |
20
|
|
|
$reader = new AnnotationReader(); |
21
|
|
|
|
22
|
|
|
$container = new class([ 'controller' => $controller ]) implements ContainerInterface { |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var array |
26
|
|
|
*/ |
27
|
|
|
private $controllers; |
28
|
|
|
|
29
|
|
|
public function __construct(array $controllers) |
30
|
|
|
{ |
31
|
|
|
$this->controllers = $controllers; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function get($id) |
35
|
|
|
{ |
36
|
|
|
return $this->controllers[$id]; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function has($id) |
40
|
|
|
{ |
41
|
|
|
return isset($this->controllers[$id]); |
42
|
|
|
} |
43
|
|
|
}; |
44
|
|
|
|
45
|
|
|
$aggregateQueryProvider = new AggregateControllerQueryProvider([ 'controller' ], $container, $reader, $this->getTypeMapper(), $this->getHydrator(), new VoidAuthenticationService(), new VoidAuthorizationService()); |
46
|
|
|
|
47
|
|
|
$queries = $aggregateQueryProvider->getQueries(); |
48
|
|
|
$this->assertCount(1, $queries); |
49
|
|
|
|
50
|
|
|
$mutations = $aggregateQueryProvider->getMutations(); |
51
|
|
|
$this->assertCount(1, $mutations); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|