forked from thecodingmachine/graphqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobControllerQueryProviderTest.php
61 lines (49 loc) · 1.88 KB
/
GlobControllerQueryProviderTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace TheCodingMachine\GraphQLite;
use Kcs\ClassFinder\Finder\ComposerFinder;
use Psr\Container\ContainerInterface;
use ReflectionClass;
use Symfony\Component\Cache\Adapter\NullAdapter;
use Symfony\Component\Cache\Psr16Cache;
use TheCodingMachine\GraphQLite\Fixtures\TestController;
class GlobControllerQueryProviderTest extends AbstractQueryProviderTest
{
public function testGlob(): void
{
$controller = new TestController();
$container = new class ([TestController::class => $controller]) implements ContainerInterface {
/** @var array */
private $controllers;
public function __construct(array $controllers)
{
$this->controllers = $controllers;
}
public function get($id): mixed
{
return $this->controllers[$id];
}
public function has($id): bool
{
return isset($this->controllers[$id]);
}
};
$finder = new ComposerFinder();
$finder->filter(static fn (ReflectionClass $class) => $class->getNamespaceName() === 'TheCodingMachine\\GraphQLite\\Fixtures'); // Fix for recursive:false
$globControllerQueryProvider = new GlobControllerQueryProvider(
'TheCodingMachine\\GraphQLite\\Fixtures',
$this->getFieldsBuilder(),
$container,
$this->getAnnotationReader(),
new Psr16Cache(new NullAdapter()),
$finder,
0,
);
$queries = $globControllerQueryProvider->getQueries();
$this->assertCount(9, $queries);
$mutations = $globControllerQueryProvider->getMutations();
$this->assertCount(2, $mutations);
$subscriptions = $globControllerQueryProvider->getSubscriptions();
$this->assertCount(2, $subscriptions);
}
}