2
2
3
3
namespace LastDragon_ru \LaraASP \GraphQL \SearchBy ;
4
4
5
+ use Closure ;
6
+ use Exception ;
7
+ use LastDragon_ru \LaraASP \GraphQL \Testing \BuilderDataProvider ;
5
8
use LastDragon_ru \LaraASP \GraphQL \Testing \TestCase ;
9
+ use LastDragon_ru \LaraASP \Testing \Providers \ArrayDataProvider ;
10
+ use LastDragon_ru \LaraASP \Testing \Providers \CompositeDataProvider ;
6
11
use LastDragon_ru \LaraASP \Testing \Utils \WithTestData ;
7
12
8
13
/**
@@ -25,6 +30,24 @@ public function testManipulateArgDefinition(string $expected, string $graphql):
25
30
26
31
$ this ->assertEquals ($ expected , $ actual );
27
32
}
33
+
34
+ /**
35
+ * @covers ::handleBuilder
36
+ *
37
+ * @dataProvider dataProviderHandleBuilder
38
+ *
39
+ * @param array<mixed> $input
40
+ */
41
+ public function testHandleBuilder (bool |Exception $ expected , Closure $ builder , array $ input ): void {
42
+ if ($ expected instanceof Exception) {
43
+ $ this ->expectExceptionObject ($ expected );
44
+ }
45
+
46
+ $ builder = $ builder ($ this );
47
+ $ directive = new Directive ($ this ->app , [], []);
48
+
49
+ $ this ->assertNotNull ($ directive ->handleBuilder ($ builder , $ input ));
50
+ }
28
51
// </editor-fold>
29
52
30
53
// <editor-fold desc="DataProvider">
@@ -38,5 +61,45 @@ public function dataProviderManipulateArgDefinition(): array {
38
61
'only used type should be added ' => ['~usedonly-expected.graphql ' , '~usedonly.graphql ' ],
39
62
];
40
63
}
64
+
65
+ /**
66
+ * @return array<mixed>
67
+ */
68
+ public function dataProviderHandleBuilder (): array {
69
+ return (new CompositeDataProvider (
70
+ new BuilderDataProvider (),
71
+ new ArrayDataProvider ([
72
+ 'valid condition ' => [
73
+ true ,
74
+ [
75
+ 'not ' => 'yes ' ,
76
+ 'allOf ' => [
77
+ [
78
+ 'a ' => [
79
+ 'eq ' => 1 ,
80
+ 'not ' => 'yes ' ,
81
+ ],
82
+ ],
83
+ [
84
+ 'anyOf ' => [
85
+ [
86
+ 'a ' => [
87
+ 'eq ' => 2 ,
88
+ ],
89
+ ],
90
+ [
91
+ 'b ' => [
92
+ 'eq ' => 3 ,
93
+ 'not ' => 'yes ' ,
94
+ ],
95
+ ],
96
+ ],
97
+ ],
98
+ ],
99
+ ],
100
+ ],
101
+ ]),
102
+ ))->getData ();
103
+ }
41
104
// </editor-fold>
42
105
}
0 commit comments