Completed
Push — master ( 65f525...acf933 )
by David
14s
created

AggregateQueryProviderTest.php$0 ➔ getMutations()   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
use PHPUnit\Framework\TestCase;
6
use ReflectionClass;
7
8
class AggregateQueryProviderTest extends TestCase
9
{
10
    private function getMockQueryProvider(): QueryProviderInterface
11
    {
12
        return new class implements QueryProviderInterface {
13
            public function getQueries(): array
14
            {
15
                $queryFieldRef = new ReflectionClass(QueryField::class);
16
                return [ $queryFieldRef->newInstanceWithoutConstructor() ];
17
            }
18
19
            public function getMutations(): array
20
            {
21
                $queryFieldRef = new ReflectionClass(QueryField::class);
22
                return [ $queryFieldRef->newInstanceWithoutConstructor() ];
23
            }
24
        };
25
    }
26
27
    public function testGetMutations()
28
    {
29
        $aggregateQueryProvider = new AggregateQueryProvider([$this->getMockQueryProvider(), $this->getMockQueryProvider()]);
30
        $this->assertCount(2, $aggregateQueryProvider->getMutations());
31
32
        $aggregateQueryProvider = new AggregateQueryProvider([]);
33
        $this->assertCount(0, $aggregateQueryProvider->getMutations());
34
    }
35
36
    public function testGetQueries()
37
    {
38
        $aggregateQueryProvider = new AggregateQueryProvider([$this->getMockQueryProvider(), $this->getMockQueryProvider()]);
39
        $this->assertCount(2, $aggregateQueryProvider->getQueries());
40
41
        $aggregateQueryProvider = new AggregateQueryProvider([]);
42
        $this->assertCount(0, $aggregateQueryProvider->getQueries());
43
    }
44
}
45