15
15
use Magento \Wishlist \Model \Item ;
16
16
use Magento \Wishlist \Model \ResourceModel \Wishlist \CollectionFactory ;
17
17
use Magento \Wishlist \Model \Wishlist ;
18
+ use Magento \Customer \Api \CustomerRepositoryInterface ;
18
19
19
20
/**
20
21
* Test coverage for customer wishlists
@@ -70,7 +71,7 @@ public function testCustomerWishlist(): void
70
71
71
72
/**
72
73
* @magentoConfigFixture default_store wishlist/general/active 1
73
- * @magentoApiDataFixture Magento/Wishlist /_files/wishlist_product .php
74
+ * @magentoApiDataFixture Magento/Catalog /_files/product_simple_duplicated .php
74
75
* @throws Exception
75
76
*/
76
77
public function testWishlistCreationScenario (): void
@@ -94,8 +95,9 @@ public function testWishlistCreationScenario(): void
94
95
$ this ->assertEquals (0 , $ wishlist ['items_count ' ]);
95
96
$ sku = 'simple-1 ' ;
96
97
$ qty = 1 ;
97
- $ addProductToWishlistQuery =
98
- <<<QUERY
98
+ try {
99
+ $ addProductToWishlistQuery =
100
+ <<<QUERY
99
101
mutation{
100
102
addProductsToWishlist(
101
103
wishlistId: {$ wishlist ['id ' ]}
@@ -116,14 +118,29 @@ public function testWishlistCreationScenario(): void
116
118
}
117
119
118
120
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
+ }
127
144
}
128
145
129
146
/**
0 commit comments