5
5
*/
6
6
namespace Magento \TestFramework \TestCase ;
7
7
8
- use Magento \Framework \App \DeploymentConfig \Reader ;
9
- use Magento \Framework \App \DeploymentConfig \Writer \PhpFormatter ;
10
- use Magento \Framework \App \Filesystem \DirectoryList ;
11
- use Magento \Framework \Config \File \ConfigFilePool ;
12
- use Magento \Framework \Filesystem ;
13
- use Magento \GraphQlCache \Model \CacheId \CacheIdCalculator ;
14
8
use Magento \TestFramework \Helper \Bootstrap ;
15
9
16
10
/**
@@ -32,26 +26,6 @@ abstract class GraphQlAbstract extends WebapiAbstract
32
26
*/
33
27
private $ appCache ;
34
28
35
- /**
36
- * @var Filesystem
37
- */
38
- private $ filesystem ;
39
-
40
- /**
41
- * @var string
42
- */
43
- private $ envConfigPath ;
44
-
45
- /**
46
- * @var Reader
47
- */
48
- private $ envConfigReader ;
49
-
50
- /**
51
- * @var PhpFormatter
52
- */
53
- private $ formatter ;
54
-
55
29
/**
56
30
* Perform GraphQL query call via GET to the system under test.
57
31
*
@@ -232,62 +206,4 @@ protected function assertResponseFields($actualResponse, $assertionMap)
232
206
);
233
207
}
234
208
}
235
-
236
- /**
237
- * If the cache id salt didn't exist in env.php before a GraphQL request it gets added. To prevent test failures
238
- * due to a config getting changed (which is normally illegal), the salt needs to be removed from env.php after
239
- * a test if it wasn't there before.
240
- *
241
- * @see \Magento\TestFramework\Isolation\DeploymentConfig
242
- *
243
- * @inheritdoc
244
- */
245
- protected function runTest ()
246
- {
247
- /** @var Reader $reader */
248
- if (!$ this ->envConfigPath ) {
249
- /** @var ConfigFilePool $configFilePool */
250
- $ configFilePool = Bootstrap::getObjectManager ()->get (ConfigFilePool::class);
251
- $ this ->envConfigPath = $ configFilePool ->getPath (ConfigFilePool::APP_ENV );
252
- }
253
- $ this ->envConfigReader = $ this ->envConfigReader ?: Bootstrap::getObjectManager ()->get (Reader::class);
254
- $ initialConfig = $ this ->envConfigReader ->load (ConfigFilePool::APP_ENV );
255
-
256
- try {
257
- return parent ::runTest ();
258
- } finally {
259
- $ this ->formatter = $ this ->formatter ?: new PhpFormatter ();
260
- $ this ->filesystem = $ this ->filesystem ?: Bootstrap::getObjectManager ()->get (Filesystem::class);
261
- $ cacheSaltPathChunks = explode ('/ ' , CacheIdCalculator::SALT_CONFIG_PATH );
262
- $ currentConfig = $ this ->envConfigReader ->load (ConfigFilePool::APP_ENV );
263
- $ resetConfig = $ this ->resetAddedSection ($ initialConfig , $ currentConfig , $ cacheSaltPathChunks );
264
- $ resetFileContents = $ this ->formatter ->format ($ resetConfig );
265
- $ directoryWrite = $ this ->filesystem ->getDirectoryWrite (DirectoryList::CONFIG );
266
- sleep (4 );
267
- $ directoryWrite ->writeFile ($ this ->envConfigPath , $ resetFileContents );
268
- }
269
- }
270
-
271
- /**
272
- * Go over the current deployment config and unset a section that was not present in the pre-test deployment config
273
- *
274
- * @param array $initial
275
- * @param array $current
276
- * @param string[] $chunks
277
- * @return array
278
- */
279
- private function resetAddedSection (array $ initial , array $ current , array $ chunks ): array
280
- {
281
- if ($ chunks ) {
282
- $ chunk = array_shift ($ chunks );
283
- if (!isset ($ initial [$ chunk ])) {
284
- if (isset ($ current [$ chunk ])) {
285
- unset($ current [$ chunk ]);
286
- }
287
- } elseif (isset ($ current [$ chunk ]) && is_array ($ initial [$ chunk ]) && is_array ($ current [$ chunk ])) {
288
- $ current [$ chunk ] = $ this ->resetAddedSection ($ initial [$ chunk ], $ current [$ chunk ], $ chunks );
289
- }
290
- }
291
- return $ current ;
292
- }
293
209
}
0 commit comments