Completed
Push — master ( 106e30...f04cc8 )
by David
11s
created

AggregateControllerQueryProviderTest.php$0 ➔ get()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
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