Skip to content

Commit b0708f6

Browse files
ACPT-1186
fixing static test failures
1 parent 8581baa commit b0708f6

File tree

7 files changed

+33
-19
lines changed

7 files changed

+33
-19
lines changed

dev/tests/integration/testsuite/Magento/Framework/ObjectManager/ResetAfterRequestTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/**
1717
* Test that verifies that resetState method for classes cause the state to be the same as it was initially constructed
1818
* @magentoDbIsolation disabled
19+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1920
*/
2021
class ResetAfterRequestTest extends \PHPUnit\Framework\TestCase
2122
{
@@ -40,6 +41,8 @@ protected function setUp(): void
4041
*
4142
* @return array
4243
* @magentoAppIsolation enabled
44+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
45+
* @SuppressWarnings(PHPMD.NPathComplexity)
4346
*/
4447
public function resetAfterRequestClassDataProvider()
4548
{
@@ -105,6 +108,8 @@ public function resetAfterRequestClassDataProvider()
105108
* @dataProvider resetAfterRequestClassDataProvider
106109
* @magentoAppArea graphql
107110
* @magentoDbIsolation disabled
111+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
112+
* @SuppressWarnings(PHPMD.NPathComplexity)
108113
*/
109114
public function testResetAfterRequestClasses(string $className)
110115
{
@@ -170,8 +175,8 @@ public function testResetAfterRequestClasses(string $className)
170175
continue; // We can skip _select because we load a fresh new Select after reset
171176
}
172177
if ('_regionModels' == $propertyName
173-
&& is_a($className, \Magento\Customer\Model\Address\AbstractAddress::class, true))
174-
{
178+
&& is_a($className, \Magento\Customer\Model\Address\AbstractAddress::class, true)
179+
) {
175180
continue; // AbstractAddress has static property _regionModels, so it would fail this test.
176181
// TODO: Can we convert _regionModels to member variable,
177182
// or move to a dependency injected service class instead?

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class GraphQlStateTest extends \PHPUnit\Framework\TestCase
3737
/** @var ObjectManagerInterface */
3838
private ObjectManagerInterface $objectManagerForTest;
3939

40-
4140
/** @var Comparator */
4241
private Comparator $comparator;
4342

@@ -87,8 +86,13 @@ protected function tearDown(): void
8786
* @return void
8887
* @throws \Exception
8988
*/
90-
public function testState(string $query, array $variables, array $variables2, string $operationName, string $expected): void
91-
{
89+
public function testState(
90+
string $query,
91+
array $variables,
92+
array $variables2,
93+
string $operationName,
94+
string $expected,
95+
): void {
9296
$jsonEncodedRequest = json_encode([
9397
'query' => $query,
9498
'variables' => $variables,

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*/
1313
class CollectedObject
1414
{
15+
private static ?CollectedObject $skippedObject = null;
16+
private static ?CollectedObject $recursionEndObject = null;
17+
1518
public function __construct(
1619
private readonly string $className,
1720
private readonly array $properties,
@@ -34,15 +37,16 @@ public function getObjectId() : int
3437
return $this->objectId;
3538
}
3639

37-
private static ?CollectedObject $skippedObject = null;
38-
public static function getSkippedObject() {
40+
public static function getSkippedObject()
41+
{
3942
if (!self::$skippedObject) {
4043
self::$skippedObject = new CollectedObject('(skipped)', [], 0);
4144
}
4245
return self::$skippedObject;
4346
}
44-
private static ?CollectedObject $recursionEndObject = null;
45-
public static function getRecursionEndObject() {
47+
48+
public static function getRecursionEndObject()
49+
{
4650
if (!self::$recursionEndObject) {
4751
self::$recursionEndObject = new CollectedObject('(end of recursion level)', [], 0);
4852
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ private function copyArray(
4141
CompareType $compareType,
4242
int $recursionLevel,
4343
int $arrayRecursionLevel = 100
44-
) : array
45-
{
44+
) : array {
4645
return array_map(
4746
function ($element) use (
4847
$compareType,
@@ -129,7 +128,7 @@ public function getPropertiesConstructedAndCurrent(): array
129128
}
130129
/* Note: We must force garbage collection to clean up cyclic referenced objects after _resetState()
131130
Otherwise, they may still show up in the WeakMap. */
132-
$collectedCount = gc_collect_cycles();
131+
gc_collect_cycles();
133132
$objects = [];
134133
foreach ($objectManager->getWeakMap() as $object => $propertiesBefore) {
135134
$objects[] = new CollectedObjectConstructedAndCurrent(

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function compareConstructedAgainstCurrent(string $operationName): array
9898
$filterListParentClasses = $filterList['parents'] ?? [];
9999
$filterListServices = $filterList['services'] ?? [];
100100
$filterListAll = $filterList['all'] ?? [];
101-
foreach($this->collector->getPropertiesConstructedAndCurrent() as $objectAndProperties) {
101+
foreach ($this->collector->getPropertiesConstructedAndCurrent() as $objectAndProperties) {
102102
$object = $objectAndProperties->getObject();
103103
$constructedObject = $objectAndProperties->getConstructedCollected();
104104
$currentObject = $objectAndProperties->getCurrentCollected();
@@ -139,6 +139,7 @@ public function compareConstructedAgainstCurrent(string $operationName): array
139139
* @param array $skipList
140140
* @param string $serviceName
141141
* @return array
142+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
142143
*/
143144
private function compare(
144145
CollectedObject $before,
@@ -217,10 +218,12 @@ private function formatValue($value): mixed
217218
*
218219
* @param mixed $before
219220
* @param mixed $after
221+
* @param array $skipList
220222
* @return array
221223
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
222224
*/
223-
public function checkValues(mixed $before, mixed $after, array $skipList): array {
225+
public function checkValues(mixed $before, mixed $after, array $skipList): array
226+
{
224227
$typeBefore = gettype($before);
225228
$typeAfter = gettype($after);
226229
if ($typeBefore !== $typeAfter) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(TestFrameworkObjectManager $testFrameworkObjectManag
3333
/* Note: PHP doesn't have copy constructors, so we have to use get_object_vars,
3434
* but luckily all the properties in the superclass are protected. */
3535
$properties = get_object_vars($testFrameworkObjectManager);
36-
foreach($properties as $key => $value) {
36+
foreach ($properties as $key => $value) {
3737
$this->$key = $value;
3838
}
3939
$skipListAndFilterList = new SkipListAndFilterList;
@@ -66,7 +66,8 @@ public function get($requestedType)
6666
if (!array_key_exists(get_class($object), $this->skipList)) {
6767
if ($object instanceof ResetAfterRequestInterface) {
6868
/* Note: some service classes get added to weakMap after they are already used, so
69-
* we need to make sure to reset them to get proper initial state after construction for comparison */
69+
* we need to make sure to reset them to get proper initial state after construction for
70+
* comparison */
7071
$object->_resetState();
7172
}
7273
$this->weakMap[$object] =

lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class ConfigLoader implements ConfigLoaderInterface
2828
protected $_readerFactory;
2929

3030
/**
31-
* Cache
32-
*
3331
* @var \Magento\Framework\Config\CacheInterface
3432
*/
3533
protected $_cache;
@@ -69,7 +67,7 @@ protected function _getReader()
6967
}
7068

7169
/**
72-
* {inheritdoc}
70+
* @inheritdoc
7371
*/
7472
public function load($area)
7573
{

0 commit comments

Comments
 (0)