Skip to content

Commit b43ffac

Browse files
Merge branch 'ACPT-1634' into ACPT-1660-and-ACPT-1634
2 parents 66dc059 + 79294cf commit b43ffac

File tree

13 files changed

+100
-33
lines changed

13 files changed

+100
-33
lines changed

app/code/Magento/ApplicationPerformanceMonitor/Profiler/Profiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function doProfile(callable $functionBeingProfiled, Application $applicat
7373
*
7474
* @param Metrics $beforeMetrics
7575
* @param Metrics $afterMetrics
76-
* @param Metrics|null $previousAfterMetrics,
76+
* @param Metrics|null $previousAfterMetrics
7777
* @param array $information extra information that we send to output
7878
* @return void
7979
*/

app/code/Magento/ApplicationPerformanceMonitorNewRelic/Profiler/Output/NewRelicOutput.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ class NewRelicOutput implements OutputInterface
2121
public const CONFIG_VERBOSE_KEY = 'application/performance_monitor/newrelic_output_verbose';
2222

2323
public function __construct(
24-
private readonly DeploymentConfig $deploymentConfig, private readonly NewRelicWrapper $newRelicWrapper)
25-
{
24+
private readonly DeploymentConfig $deploymentConfig,
25+
private readonly NewRelicWrapper $newRelicWrapper
26+
) {
2627
}
2728

2829
/**
@@ -59,6 +60,11 @@ public function doOutput(array $metrics, array $information) : void
5960
}
6061
}
6162

63+
/**
64+
* Is configured to output verbose
65+
*
66+
* @return bool
67+
*/
6268
private function isVerbose(): bool
6369
{
6470
return match ($this->deploymentConfig->get(static::CONFIG_VERBOSE_KEY)) {

dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ private function getAvailableProductCustomOption(string $productSku): array
753753
{
754754
$query = <<<QUERY
755755
{
756-
products(filter: {sku: {eq: "${productSku}"}}) {
756+
products(filter: {sku: {eq: "{$productSku}"}}) {
757757
items {
758758
name
759759
... on CustomizableProductInterface {

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

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

1010
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1111
use Magento\Framework\ObjectManagerInterface;
12+
use Magento\GraphQl\App\State\ObjectManagerInterface as StateObjectManagerInterface;
1213

1314
/**
1415
* Collects shared objects from ObjectManager and copies properties for later comparison
16+
*
17+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1518
*/
1619
class Collector
1720
{
@@ -45,7 +48,7 @@ public function __construct(
4548
*/
4649
private function copyArray(
4750
array $array,
48-
string $compareType,
51+
CompareType $compareType,
4952
int $recursionLevel,
5053
int $arrayRecursionLevel = 100
5154
) : array {
@@ -86,9 +89,9 @@ function ($element) use (
8689
* @param ShouldResetState $shouldResetState
8790
* @return CollectedObject[]
8891
*/
89-
public function getSharedObjects(string $shouldResetState): array
92+
public function getSharedObjects(ShouldResetState $shouldResetState): array
9093
{
91-
if ($this->objectManager instanceof ObjectManager) {
94+
if ($this->objectManager instanceof ObjectManagerInterface) {
9295
$sharedInstances = $this->objectManager->getSharedInstances();
9396
} else {
9497
$obj = new \ReflectionObject($this->objectManager);
@@ -128,7 +131,7 @@ public function getPropertiesConstructedAndCurrent(): array
128131
{
129132
/** @var ObjectManager $objectManager */
130133
$objectManager = $this->objectManager;
131-
if (!($objectManager instanceof ObjectManager)) {
134+
if (!($objectManager instanceof StateObjectManagerInterface)) {
132135
throw new \Exception("Not the correct type of ObjectManager");
133136
}
134137
// Calling _resetState helps us avoid adding skip/filter for these classes.
@@ -156,7 +159,7 @@ public function getPropertiesConstructedAndCurrent(): array
156159
*/
157160
public function getPropertiesFromObject(
158161
object $object,
159-
string $compareType,
162+
CompareType $compareType,
160163
int $recursionLevel = 1,
161164
): CollectedObject {
162165
$className = get_class($object);
@@ -165,7 +168,7 @@ public function getPropertiesFromObject(
165168
if (array_key_exists($className, $skipList)) {
166169
return CollectedObject::getSkippedObject();
167170
}
168-
if ($this->objectManager instanceof ObjectManager) {
171+
if ($this->objectManager instanceof StateObjectManagerInterface) {
169172
$serviceName = array_search($object, $this->objectManager->getSharedInstances(), true);
170173
if ($serviceName && array_key_exists($serviceName, $skipList)) {
171174
return CollectedObject::getSkippedObject();

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,21 @@ private function compare(
179179
}
180180
}
181181
}
182-
if ($objectState) {
183-
return [
184-
'objectClassBefore' => $before->getClassName(),
185-
'objectClassAfter' => $after->getClassName(),
186-
'properties' => $objectState,
187-
'objectIdBefore' => $before->getObjectId(),
188-
'objectIdAfter' => $after->getObjectId(),
189-
];
182+
if (!$objectState) {
183+
return [];
190184
}
191-
return [];
185+
$returnValue = [
186+
'objectClassBefore' => $before->getClassName(),
187+
'properties' => $objectState,
188+
];
189+
if ($returnValue['objectClassBefore'] !== $after->getClassName()) {
190+
$returnValue['objectClassAfter'] = $after->getClassName();
191+
}
192+
if ($before->getObjectId() != $after->getObjectId()) {
193+
$returnValue['objectIdBefore'] = $before->getObjectId();
194+
$returnValue['objectIdAfter'] = $after->getObjectId();
195+
}
196+
return $returnValue;
192197
}
193198

194199
/**

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99

1010
/**
1111
* What type of comparison
12-
*
13-
* TODO: change this back into enum once magento-semvar is fixed
1412
*/
15-
class CompareType
13+
enum CompareType
1614
{
17-
public const CompareBetweenRequests = "CompareBetweenRequests";
18-
public const CompareConstructedAgainstCurrent = "CompareConstructedAgainstCurrent";
15+
case CompareBetweenRequests;
16+
case CompareConstructedAgainstCurrent;
1917
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function _resetState(): void
102102
/**
103103
* Returns the WeakMap that stores the CollectedObject
104104
*
105-
* @return WeakMap
105+
* @return WeakMap with CollectedObject as values
106106
*/
107107
public function getWeakMap() : WeakMap
108108
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* ObjectManager decorator used by GraphQlStateTest for resetting objects and getting initial properties from objects
1616
*/
17-
class ObjectManager extends TestFrameworkObjectManager
17+
class ObjectManager extends TestFrameworkObjectManager implements ObjectManagerInterface
1818
{
1919
/**
2020
* Constructs this instance by copying test framework's ObjectManager
@@ -35,7 +35,7 @@ public function __construct(TestFrameworkObjectManager $testFrameworkObjectManag
3535
/**
3636
* Returns the WeakMap used by DynamicFactoryDecorator
3737
*
38-
* @return WeakMap
38+
* @return WeakMap with CollectedObject as values
3939
*/
4040
public function getWeakMap() : WeakMap
4141
{
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GraphQl\App\State;
9+
10+
use Magento\Framework\ObjectManagerInterface as FrameworkObjectManagerInterface;
11+
use Weakmap;
12+
13+
/**
14+
* Interface for ObjectManager that has additional methods used by Collector for comparing state
15+
*/
16+
interface ObjectManagerInterface extends FrameworkObjectManagerInterface
17+
{
18+
/**
19+
* Returns the WeakMap with CollectedObject as values
20+
*
21+
* @return WeakMap with CollectedObject as values
22+
*/
23+
public function getWeakMap() : WeakMap;
24+
25+
/**
26+
* Returns shared instances
27+
*
28+
* @return object[]
29+
*/
30+
public function getSharedInstances() : array;
31+
32+
/**
33+
* Resets all factory objects that implement ResetAfterRequestInterface
34+
*/
35+
public function resetStateWeakMapObjects() : void;
36+
37+
/**
38+
* Resets all objects sharing state & implementing ResetAfterRequestInterface
39+
*/
40+
public function resetStateSharedInstances() : void;
41+
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
namespace Magento\GraphQl\App\State;
99

10-
// TODO: change this back into enum once magento-semvar is fixed
11-
class ShouldResetState
10+
enum ShouldResetState
1211
{
13-
public const DoResetState = "DoResetState";
14-
public const DoNotResetState = "DoNotResetState";
12+
case DoResetState;
13+
case DoNotResetState;
1514
}

0 commit comments

Comments
 (0)