Skip to content

Commit 616d898

Browse files
ACPT-1194: Fixing bugs found by web api functional tests
1 parent a74f840 commit 616d898

File tree

7 files changed

+59
-7
lines changed

7 files changed

+59
-7
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
1111
use Magento\Catalog\Model\Product\Attribute\Backend\Price;
1212
use Magento\Customer\Api\GroupManagementInterface;
13+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1314

1415
/**
1516
* Catalog product abstract group price backend attribute model
1617
*
1718
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1819
*/
19-
abstract class AbstractGroupPrice extends Price
20+
abstract class AbstractGroupPrice extends Price implements ResetAfterRequestInterface
2021
{
2122
/**
2223
* @var \Magento\Framework\EntityManager\MetadataPool
@@ -26,7 +27,7 @@ abstract class AbstractGroupPrice extends Price
2627
/**
2728
* Website currency codes and rates
2829
*
29-
* @var array
30+
* @var array|null
3031
*/
3132
protected $_rates;
3233

@@ -82,6 +83,14 @@ public function __construct(
8283
);
8384
}
8485

86+
/**
87+
* @inheritdoc
88+
*/
89+
public function _resetState() : void
90+
{
91+
$this->_rates = null;
92+
}
93+
8594
/**
8695
* Retrieve websites currency rates and base currency codes
8796
*

app/code/Magento/Eav/Model/Config.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,5 +990,12 @@ public function _resetState(): void
990990
{
991991
$this->attributesPerSet = [];
992992
$this->_attributeData = [];
993+
foreach($this->attributes as $attributesGroupedByEntityTypeCode) {
994+
foreach($attributesGroupedByEntityTypeCode as $attribute) {
995+
if ($attribute instanceof ResetAfterRequestInterface) {
996+
$attribute->_resetState();
997+
}
998+
}
999+
}
9931000
}
9941001
}

app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Framework\Api\AttributeValueFactory;
1111
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1213
use Magento\Framework\Serialize\Serializer\Json;
1314

1415
/**
@@ -23,7 +24,8 @@
2324
*/
2425
abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtensibleModel implements
2526
AttributeInterface,
26-
\Magento\Eav\Api\Data\AttributeInterface
27+
\Magento\Eav\Api\Data\AttributeInterface,
28+
ResetAfterRequestInterface
2729
{
2830
const TYPE_STATIC = 'static';
2931

@@ -216,6 +218,16 @@ public function __construct(
216218
?: \Magento\Framework\App\ObjectManager::getInstance()->get(FrontendLabelFactory::class);
217219
}
218220

221+
/**
222+
* @inheritdoc
223+
*/
224+
public function _resetState() : void
225+
{
226+
if ($this->_backend instanceof ResetAfterRequestInterface) {
227+
$this->_backend->_resetState();
228+
}
229+
}
230+
219231
/**
220232
* Get Serializer instance.
221233
*

app/code/Magento/Store/Model/StoreManager.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
namespace Magento\Store\Model;
77

88
use Magento\Framework\App\ObjectManager;
9-
use Magento\Framework\Exception\NoSuchEntityException;
10-
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
119
use Magento\Store\Api\StoreResolverInterface;
1210
use Magento\Store\Model\ResourceModel\StoreWebsiteRelation;
1311

dev/tests/api-functional/testsuite/Magento/GraphQl/Newsletter/Guest/SubscribeEmailToNewsletterTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ protected function setUp(): void
3131
$this->subscriberResource = $objectManager->get(SubscriberResourceModel::class);
3232
}
3333

34+
/**
35+
* @magentoConfigFixture default_store newsletter/subscription/allow_guest_subscribe 1
36+
*/
3437
public function testAddEmailIntoNewsletterSubscription()
3538
{
3639
$query = $this->getQuery('guest@example.com');
@@ -41,6 +44,9 @@ public function testAddEmailIntoNewsletterSubscription()
4144
self::assertEquals('SUBSCRIBED', $response['subscribeEmailToNewsletter']['status']);
4245
}
4346

47+
/**
48+
* @magentoConfigFixture default_store newsletter/subscription/allow_guest_subscribe 1
49+
*/
4450
public function testNewsletterSubscriptionWithIncorrectEmailFormat()
4551
{
4652
$query = $this->getQuery('guest.example.com');
@@ -68,6 +74,7 @@ public function testNewsletterSubscriptionWithDisallowedGuestSubscription()
6874

6975
/**
7076
* @magentoApiDataFixture Magento/Newsletter/_files/guest_subscriber.php
77+
* @magentoConfigFixture default_store newsletter/subscription/allow_guest_subscribe 1
7178
*/
7279
public function testNewsletterSubscriptionWithAlreadySubscribedEmail()
7380
{

lib/internal/Magento/Framework/Acl/Builder.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Framework\Acl;
77

8+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
9+
810
/**
911
* Access Control List Builder. Retrieves required role/rule/resource loaders
1012
* and uses them to populate provided ACL object. Acl object is put to cache after creation.
@@ -13,7 +15,7 @@
1315
* @api
1416
* @since 100.0.2
1517
*/
16-
class Builder
18+
class Builder implements ResetAfterRequestInterface
1719
{
1820
/**
1921
* Acl object
@@ -85,4 +87,12 @@ public function resetRuntimeAcl()
8587
$this->_acl = null;
8688
return $this;
8789
}
90+
91+
/**
92+
* @inheritdoc
93+
*/
94+
public function _resetState(): void
95+
{
96+
$this->resetRuntimeAcl();
97+
}
8898
}

lib/internal/Magento/Framework/Pricing/Price/Collection.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Framework\Pricing\Price;
88

9+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
910
use Magento\Framework\Pricing\SaleableInterface;
1011

1112
/**
@@ -14,7 +15,7 @@
1415
* @api
1516
* @since 100.0.2
1617
*/
17-
class Collection implements \Iterator
18+
class Collection implements \Iterator, ResetAfterRequestInterface
1819
{
1920
/**
2021
* @var Pool
@@ -74,6 +75,14 @@ public function __construct(
7475
$this->priceModels = [];
7576
}
7677

78+
/**
79+
* @inheritdoc
80+
*/
81+
public function _resetState() : void
82+
{
83+
$this->priceModels = [];
84+
}
85+
7786
/**
7887
* Reset the Collection to the first element
7988
*

0 commit comments

Comments
 (0)