Completed
Pull Request — master (#2)
by David
01:50
created

AggregateControllerQueryProviderTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 39
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ __construct() 0 4 1
A hp$0 ➔ get() 0 4 1
A hp$0 ➔ has() 0 4 1
B testAggregate() 0 36 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