23
23
*/
24
24
class GraphQlConfigTest extends \PHPUnit \Framework \TestCase
25
25
{
26
+ /** @var ObjectManagerInterface */
27
+ private $ objectManager ;
28
+
26
29
/** @var \Magento\Framework\GraphQl\Config */
27
30
private $ model ;
28
31
29
- protected function setUp (): void
30
- {
31
- /** @var ObjectManagerInterface $objectManager */
32
- $ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
33
- /** @var Cache $cache */
34
- $ cache = $ objectManager ->get (Cache::class);
35
- $ cache ->clean ();
32
+ public function __construct () {
33
+ $ this ->objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
36
34
$ fileResolverMock = $ this ->getMockBuilder (
37
35
\Magento \Framework \Config \FileResolverInterface::class
38
36
)->disableOriginalConstructor ()->getMock ();
@@ -43,21 +41,31 @@ protected function setUp(): void
43
41
$ filePath2 => file_get_contents ($ filePath2 )
44
42
];
45
43
$ fileResolverMock ->expects ($ this ->any ())->method ('get ' )->willReturn ($ fileList );
46
- $ graphQlReader = $ objectManager ->create (
44
+ $ graphQlReader = $ this -> objectManager ->create (
47
45
\Magento \Framework \GraphQlSchemaStitching \GraphQlReader::class,
48
46
['fileResolver ' => $ fileResolverMock ]
49
47
);
50
- $ reader = $ objectManager ->create (
51
- // phpstan:ignore
48
+ $ reader = $ this -> objectManager ->create (
49
+ // phpstan:ignore
52
50
\Magento \Framework \GraphQlSchemaStitching \Reader::class,
53
51
['readers ' => ['graphql_reader ' => $ graphQlReader ]]
54
52
);
55
- $ data = $ objectManager ->create (
56
- // phpstan:ignore
57
- \Magento \Framework \GraphQl \Config \Data ::class,
53
+ $ data = $ this -> objectManager ->create (
54
+ // phpstan:ignore
55
+ \Magento \Framework \GraphQl \Config \Data::class,
58
56
['reader ' => $ reader ]
59
57
);
60
- $ this ->model = $ objectManager ->create (\Magento \Framework \GraphQl \Config::class, ['data ' =>$ data ]);
58
+ $ this ->model = $ this ->objectManager ->create (\Magento \Framework \GraphQl \Config::class, ['data ' =>$ data ]);
59
+ parent ::__construct ();
60
+ }
61
+
62
+ protected function setUp (): void
63
+ {
64
+ /** @var ObjectManagerInterface $objectManager */
65
+ $ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
66
+ /** @var Cache $cache */
67
+ $ cache = $ objectManager ->get (Cache::class);
68
+ $ cache ->clean ();
61
69
}
62
70
63
71
/**
@@ -87,7 +95,7 @@ public function testGraphQlTypeAndFieldConfigStructure()
87
95
]
88
96
];
89
97
$ this ->assertResponseFields ($ expectedOutputArray ['Query ' ]['fields ' ][$ fieldKey ], $ fieldAssertionMap );
90
- /** @var \Magento\Framework\GraphQl\Config\Element\Argument $queryFieldArguments */
98
+ /** @var \Magento\Framework\GraphQl\Config\Element\Argument[] $queryFieldArguments */
91
99
$ queryFieldArguments = $ queryFields [$ fieldKey ]->getArguments ();
92
100
foreach (array_keys ($ queryFieldArguments ) as $ argumentKey ) {
93
101
$ argumentAssertionMap = [
@@ -121,7 +129,7 @@ public function testGraphQlEnumTypeConfigStructure()
121
129
$ queryEnum = 'PriceAdjustmentDescriptionEnum ' ;
122
130
/** @var \Magento\Framework\GraphQl\Config\Element\Enum $outputEnum */
123
131
$ outputEnum = $ this ->model ->getConfigElement ($ queryEnum );
124
- /** @var EnumValue $outputEnumValues */
132
+ /** @var EnumValue[] $outputEnumValues */
125
133
$ outputEnumValues = $ outputEnum ->getValues ();
126
134
$ expectedOutputArray = require __DIR__ . '/_files/query_array_output.php ' ;
127
135
$ this ->assertEquals ($ outputEnum ->getName (), $ queryEnum );
@@ -154,7 +162,7 @@ public function testGraphQlTypeThatImplementsInterface()
154
162
$ expectedOutputArray = require __DIR__ . '/_files/query_array_output.php ' ;
155
163
$ this ->assertEquals ($ outputInterface ->getName (), $ typeThatImplements );
156
164
$ outputInterfaceValues = $ outputInterface ->getInterfaces ();
157
- /** @var \Magento\Framework\GraphQl\Config\Element\Field $outputInterfaceFields */
165
+ /** @var \Magento\Framework\GraphQl\Config\Element\Field[] $outputInterfaceFields */
158
166
$ outputInterfaceFields =$ outputInterface ->getFields ();
159
167
foreach (array_keys ($ outputInterfaceValues ) as $ outputInterfaceValue ) {
160
168
$ this ->assertEquals (
0 commit comments