Skip to content

Commit 2fc682a

Browse files
ACPT-987
making requested changes for PR
1 parent 157b526 commit 2fc682a

File tree

4 files changed

+22
-41
lines changed

4 files changed

+22
-41
lines changed

dev/tests/integration/testsuite/Magento/GraphQl/App/GraphQlStateTest.php

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77

88
namespace Magento\GraphQl\App;
99

10-
use Laminas\Stdlib\Parameters;
1110
use Magento\Framework\App\Http as HttpApp;
1211
use Magento\Framework\App\Request\HttpFactory as RequestFactory;
1312
use Magento\Framework\App\Response\Http as HttpResponse;
1413
use Magento\Framework\ObjectManagerInterface;
1514
use Magento\GraphQl\App\State\Comparator;
16-
use Magento\MessageQueue\Api\PoisonPillCompareInterface;
1715
use Magento\TestFramework\Helper\Bootstrap;
1816

1917
/**
@@ -32,13 +30,13 @@ class GraphQlStateTest extends \PHPUnit\Framework\TestCase
3230
private const CONTENT_TYPE = 'application/json';
3331

3432
/** @var ObjectManagerInterface */
35-
private $objectManager;
33+
private ObjectManagerInterface $objectManager;
3634

3735
/** @var Comparator */
38-
private $comparator;
36+
private Comparator $comparator;
3937

4038
/** @var RequestFactory */
41-
private $requestFactory;
39+
private RequestFactory $requestFactory;
4240

4341
/**
4442
* @return void
@@ -91,7 +89,7 @@ private function request(string $query, string $operationName, bool $firstReques
9189
$result = $this->comparator->compare($operationName);
9290
$this->assertEmpty(
9391
$result,
94-
\sprintf(
92+
sprintf(
9593
'%d objects changed state during request. Details: %s',
9694
count($result),
9795
var_export($result, true)
@@ -109,24 +107,8 @@ private function request(string $query, string $operationName, bool $firstReques
109107
private function doRequest(string $query)
110108
{
111109
$request = $this->requestFactory->create();
112-
$request->setEnv(new Parameters([]));
113-
$request->setContent($query); // TODO add parameter
114-
$request->setServer(new Parameters([
115-
'query_string' => '',
116-
'request_method' => 'POST',
117-
'request_uri' => '/graphql',
118-
'path_info' => '/graphql',
119-
'request_time' => 1678398349,
120-
'request_time_float' => 1678398349.6005,
121-
'server_protocol' => 'HTTP/1.0',
122-
'server_port' => 9501,
123-
'remote_port' => 50166,
124-
'remote_addr' => '172.22.0.9',
125-
'master_time' => 1678398349,
126-
'http_content_type' => self::CONTENT_TYPE,
127-
]));
110+
$request->setContent($query);
128111
$request->setMethod('POST');
129-
$request->setUri('/graphql');
130112
$request->setPathInfo('/graphql');
131113
$request->getHeaders()->addHeaders(['content_type' => self::CONTENT_TYPE]);
132114
$unusedResponse = $this->objectManager->create(HttpResponse::class);

dev/tests/integration/testsuite/Magento/GraphQl/App/State/Collector.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99

1010
use Magento\Framework\ObjectManagerInterface;
1111

12+
/**
13+
* Collects shared objects from ObjectManager and clones properties for later comparison
14+
*/
1215
class Collector
1316
{
1417
/**
1518
* @var ObjectManagerInterface
1619
*/
17-
private $objectManager;
20+
private ObjectManagerInterface $objectManager;
1821

1922
/**
2023
* @param ObjectManagerInterface $objectManager
@@ -32,12 +35,12 @@ public function __construct(ObjectManagerInterface $objectManager)
3235
*/
3336
private function cloneArray(array $array) : array
3437
{
35-
return \array_map(
38+
return array_map(
3639
function ($element) {
37-
if (\is_object($element)) {
40+
if (is_object($element)) {
3841
return clone $element;
3942
}
40-
if (\is_array($element)) {
43+
if (is_array($element)) {
4144
return $this->cloneArray($element);
4245
}
4346
return $element;
@@ -57,7 +60,7 @@ public function getSharedObjects(): array
5760
$sharedObjects = [];
5861
$obj = new \ReflectionObject($this->objectManager);
5962
if (!$obj->hasProperty('_sharedInstances')) {
60-
throw new \Exception('Cannot get shared objects from ' . \get_class($this->objectManager));
63+
throw new \Exception('Cannot get shared objects from ' . get_class($this->objectManager));
6164
}
6265
do {
6366
$property = $obj->getProperty('_sharedInstances');
@@ -76,11 +79,11 @@ public function getSharedObjects(): array
7679
$propName = $property->getName();
7780
$property->setAccessible(true);
7881
$value = $property->getValue($object);
79-
if (\is_object($value)) {
82+
if (is_object($value)) {
8083
$didClone = true;
8184
$properties[$propName] = clone $value;
8285
continue;
83-
} elseif (\is_array($value)) {
86+
} elseif (is_array($value)) {
8487
$didClone = true;
8588
$properties[$propName] = $this->cloneArray($value);
8689
} else {

dev/tests/integration/testsuite/Magento/GraphQl/App/State/Comparator.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ private function getFilterList(): array
172172
*/
173173
private function formatValue($type): array
174174
{
175-
$type = \is_array($type) ? $type : [$type];
175+
$type = is_array($type) ? $type : [$type];
176176
$data = [];
177177
foreach ($type as $k => $v) {
178-
if (\is_object($v)) {
179-
$v = \get_class($v);
180-
} elseif (\is_array($v)) {
178+
if (is_object($v)) {
179+
$v = get_class($v);
180+
} elseif (is_array($v)) {
181181
$v = $this->formatValue($v);
182182
}
183183
$data[$k] = $v;
@@ -220,8 +220,8 @@ private function checkValues($before, $after): array
220220
break;
221221
case 'object':
222222
if ($before != $after) {
223-
$result['before'] = \get_class($before);
224-
$result['after'] = \get_class($after);
223+
$result['before'] = get_class($before);
224+
$result['after'] = get_class($after);
225225
}
226226
break;
227227
}

dev/tests/integration/testsuite/Magento/GraphQl/_files/state-filter-list.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
Magento\Framework\App\View\Deployment\Version::class => [
4343
'cachedValue' => null // deployment version of static files
4444
],
45-
Magento\Framework\View\Design\Fallback\RulePool::class => ['rules' => null],
4645
Magento\Framework\View\Asset\Minification::class => ['configCache' => null], // TODO: depends on mode
4746
Magento\Eav\Model\Config::class => [ // TODO: is this risky?
4847
'attributeProto' => null,
@@ -62,7 +61,6 @@
6261
'config' => null, // $_connectionNames changes
6362
],
6463
Magento\Framework\Cache\InvalidateLogger::class => ['request' => null],
65-
Magento\Framework\View\Design\Fallback\RulePool::class => ['filesystem' => null],
6664
Magento\Framework\View\Design\FileResolution\Fallback\Resolver\Simple::class => ['rulePool' => null],
6765
Magento\Framework\View\Template\Html\Minifier::class => ['filesystem' => null],
6866
Magento\Store\Model\Config\Processor\Fallback::class => ['scopes' => null],
@@ -99,11 +97,9 @@
9997
Magento\Framework\Event\Invoker\InvokerDefault::class => ['_appState' => null], // .
10098
Magento\Developer\Model\Logger\Handler\Debug::class => ['state' => null], // .
10199
Magento\Framework\View\Design\FileResolution\Fallback\TemplateFile::class => // .
102-
['appState' => null], // ... using Magento\Framework\App\Http instead of ApplicationServer for the requests
103-
Magento\Framework\App\ResourceConnection::class => ['connections' => null],
100+
['appState' => null], // ... using Magento\Framework\App\Http for the requests
104101
Magento\Store\App\Config\Source\RuntimeConfigSource::class => ['connection' => null],
105102
Magento\Framework\Mview\View\Changelog::class => ['connection' => null],
106103
Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::class => ['_conn' => null],
107-
Magento\Framework\App\ResourceConnection::class => ['config' => null],
108104
],
109105
];

0 commit comments

Comments
 (0)