Skip to content

Commit fdaf21f

Browse files
author
Prabhu Ram
committed
PWA-1619: New accounts created through GQL are not provisioned a wishlist
- Addressed review comments
1 parent 6cd1837 commit fdaf21f

File tree

3 files changed

+28
-44
lines changed

3 files changed

+28
-44
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Wishlist\Model\Item;
1616
use Magento\Wishlist\Model\ResourceModel\Wishlist\CollectionFactory;
1717
use Magento\Wishlist\Model\Wishlist;
18+
use Magento\Customer\Api\CustomerRepositoryInterface;
1819

1920
/**
2021
* Test coverage for customer wishlists
@@ -70,7 +71,7 @@ public function testCustomerWishlist(): void
7071

7172
/**
7273
* @magentoConfigFixture default_store wishlist/general/active 1
73-
* @magentoApiDataFixture Magento/Wishlist/_files/wishlist_product.php
74+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_duplicated.php
7475
* @throws Exception
7576
*/
7677
public function testWishlistCreationScenario(): void
@@ -94,8 +95,9 @@ public function testWishlistCreationScenario(): void
9495
$this->assertEquals(0, $wishlist['items_count']);
9596
$sku = 'simple-1';
9697
$qty = 1;
97-
$addProductToWishlistQuery =
98-
<<<QUERY
98+
try {
99+
$addProductToWishlistQuery =
100+
<<<QUERY
99101
mutation{
100102
addProductsToWishlist(
101103
wishlistId:{$wishlist['id']}
@@ -116,14 +118,29 @@ public function testWishlistCreationScenario(): void
116118
}
117119
118120
QUERY;
119-
$addToWishlistResponse = $this->graphQlMutation(
120-
$addProductToWishlistQuery,
121-
[],
122-
'',
123-
$this->getCustomerAuthHeaders($customerEmail, '123123^q')
124-
);
125-
$this->assertArrayHasKey('user_errors', $addToWishlistResponse['addProductsToWishlist']);
126-
$this->assertCount(0, $addToWishlistResponse['addProductsToWishlist']['user_errors']);
121+
$addToWishlistResponse = $this->graphQlMutation(
122+
$addProductToWishlistQuery,
123+
[],
124+
'',
125+
$this->getCustomerAuthHeaders($customerEmail, '123123^q')
126+
);
127+
$this->assertArrayHasKey('user_errors', $addToWishlistResponse['addProductsToWishlist']);
128+
$this->assertCount(0, $addToWishlistResponse['addProductsToWishlist']['user_errors']);
129+
} finally {
130+
/** @var \Magento\Framework\Registry $registry */
131+
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
132+
->get(\Magento\Framework\Registry::class);
133+
$registry->unregister('isSecureArea');
134+
$registry->register('isSecureArea', true);
135+
136+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
137+
$customerRepository = $objectManager->create(CustomerRepositoryInterface::class);
138+
$customer = $customerRepository->get('[email protected]');
139+
$customerRepository->delete($customer);
140+
141+
$registry->unregister('isSecureArea');
142+
$registry->register('isSecureArea', false);
143+
}
127144
}
128145

129146
/**

dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_product.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_product_rollback.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)