This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,789 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\GraphQl\App;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\GraphQl\App\State\GraphQlStateDiff;
use Magento\Quote\Test\Fixture\GuestCart as GuestCartFixture;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Fixture\DataFixtureStorage;
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
use Magento\TestFramework\Helper\Bootstrap;
/**
* Tests the dispatch method in the GraphQl Controller class using a simple product query
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @magentoDbIsolation disabled
* @magentoAppIsolation enabled
* @magentoAppArea graphql
*/
class GraphQlCheckoutMutationsStateTest extends \PHPUnit\Framework\TestCase
{
/**
* @var GraphQlStateDiff|null
*/
private ?GraphQlStateDiff $graphQlStateDiff = null;
/**
* @inheritDoc
*/
protected function setUp(): void
{
if (!class_exists(GraphQlStateDiff::class)) {
$this->markTestSkipped('GraphQlStateDiff class is not available on this version of Magento.');
}
$this->graphQlStateDiff = new GraphQlStateDiff($this);
parent::setUp();
}
/**
* @inheritDoc
*/
protected function tearDown(): void
{
$this->graphQlStateDiff->tearDown();
$this->graphQlStateDiff = null;
parent::tearDown();
}
/**
* @return void
*/
public function testCreateEmptyCart() : void
{
$this->graphQlStateDiff->testState(
$this->getEmptyCart(),
[],
[],
[],
'createEmptyCart',
'"data":{"createEmptyCart":',
$this
);
}
/**
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @return void
*/
#[
DataFixture(GuestCartFixture::class, as: 'cart1'),
DataFixture(GuestCartFixture::class, as: 'cart2'),
]
public function testAddSimpleProductToCart(): void
{
$fixtures = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage();
$cartId1 = $fixtures->get('cart1')->getId();
$cartId2 = $fixtures->get('cart2')->getId();
$query = $this->getAddProductToCartQuery();
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId1, 'qty' => 1, 'sku' => 'simple_product'],
['cartId' => $cartId2, 'qty' => 1, 'sku' => 'simple_product'],
[],
'addSimpleProductsToCart',
'"data":{"addSimpleProductsToCart":',
$this
);
}
/**
* @magentoDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
* @magentoDataFixture Magento/SalesRule/_files/coupon_cart_fixed_discount.php
* @return void
*/
public function testAddCouponToCart()
{
$cartId = $this->graphQlStateDiff->getCartIdHash('test_quote');
$query = $this->getAddCouponToCartQuery();
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId, 'couponCode' => '2?ds5!2d'],
['cartId' => $cartId, 'couponCode' => 'CART_FIXED_DISCOUNT_15'],
[],
'applyCouponToCart',
'"data":{"applyCouponToCart":',
$this
);
}
/**
* @magentoDataFixture Magento/GraphQl/Catalog/_files/virtual_product.php
* @return void
*/
#[
DataFixture(GuestCartFixture::class, as: 'cart1'),
DataFixture(GuestCartFixture::class, as: 'cart2'),
]
public function testAddVirtualProductToCart()
{
$fixtures = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage();
$cartId1 = $fixtures->get('cart1')->getId();
$cartId2 = $fixtures->get('cart2')->getId();
$query = $this->getAddVirtualProductToCartQuery();
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId1, 'quantity' => 1, 'sku' => 'virtual_product'],
['cartId' => $cartId2, 'quantity' => 1, 'sku' => 'virtual_product'],
[],
'addVirtualProductsToCart',
'"data":{"addVirtualProductsToCart":',
$this
);
}
/**
* @magentoDataFixture Magento/Bundle/_files/product.php
* @return void
*/
#[
DataFixture(GuestCartFixture::class, as: 'cart1'),
DataFixture(GuestCartFixture::class, as: 'cart2'),
]
public function testAddBundleProductToCart()
{
$fixtures = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage();
$cartId1 = $fixtures->get('cart1')->getId();
$cartId2 = $fixtures->get('cart2')->getId();
$query = $this->getAddBundleProductToCartQuery('bundle-product');
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId1],
['cartId' => $cartId2],
[],
'addBundleProductsToCart',
'"data":{"addBundleProductsToCart":',
$this
);
}
/**
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
* @return void
*/
#[
DataFixture(GuestCartFixture::class, as: 'cart1'),
DataFixture(GuestCartFixture::class, as: 'cart2'),
]
public function testAddConfigurableProductToCart(): void
{
$fixtures = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage();
$cartId1 = $fixtures->get('cart1')->getId();
$cartId2 = $fixtures->get('cart2')->getId();
$query = $this->getAddConfigurableProductToCartQuery();
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId1, 'quantity' => 2, 'parentSku' => 'configurable', 'childSku' => 'simple_20'],
['cartId' => $cartId2, 'quantity' => 2, 'parentSku' => 'configurable', 'childSku' => 'simple_20'],
[],
'addConfigurableProductsToCart',
'"data":{"addConfigurableProductsToCart":',
$this
);
}
/**
* @magentoDataFixture Magento/Downloadable/_files/product_downloadable_with_purchased_separately_links.php
* @return void
*/
#[
DataFixture(GuestCartFixture::class, as: 'cart1'),
DataFixture(GuestCartFixture::class, as: 'cart2'),
]
public function testAddDownloadableProductToCart(): void
{
$fixtures = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage();
$cartId1 = $fixtures->get('cart1')->getId();
$cartId2 = $fixtures->get('cart2')->getId();
$sku = 'downloadable-product-with-purchased-separately-links';
$links = $this->getProductsLinks($sku);
$linkId = key($links);
$query = $this->getAddDownloadableProductToCartQuery();
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId1, 'qty' => 1, 'sku' => $sku, 'linkId' => $linkId],
['cartId' => $cartId2, 'qty' => 1, 'sku' => $sku, 'linkId' => $linkId],
[],
'addDownloadableProductsToCart',
'"data":{"addDownloadableProductsToCart":',
$this
);
}
/**
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @return void
*/
public function testSetShippingAddressOnCart(): void
{
$cartId = $this->graphQlStateDiff->getCartIdHash('test_quote');
$query = $this->getShippingAddressQuery();
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId],
[],
[],
'setShippingAddressesOnCart',
'"data":{"setShippingAddressesOnCart":',
$this
);
}
/**
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
* @return void
*/
public function testSetBillingAddressOnCart(): void
{
$cartId = $this->graphQlStateDiff->getCartIdHash('test_quote');
$query = $this->getBillingAddressQuery();
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId],
[],
[],
'setBillingAddressOnCart',
'"data":{"setBillingAddressOnCart":',
$this
);
}
/**
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
* @return void
*/
public function testSetShippingMethodsOnCart(): void
{
$cartId = $this->graphQlStateDiff->getCartIdHash('test_quote');
$query = $this->getShippingMethodsQuery();
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId, 'shippingMethod' => 'flatrate'],
[],
[],
'setShippingMethodsOnCart',
'"data":{"setShippingMethodsOnCart":',
$this
);
}
/**
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
*/
public function testSetPaymentMethodOnCart(): void
{
$cartId = $this->graphQlStateDiff->getCartIdHash('test_quote');
$query = $this->getPaymentMethodQuery();
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId],
[],
[],
'setPaymentMethodOnCart',
'"data":{"setPaymentMethodOnCart":',
$this
);
}
/**
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_checkmo_payment_method.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/guest/set_guest_email.php
*/
public function testPlaceOrder(): void
{
$cartId = $this->graphQlStateDiff->getCartIdHash('test_quote');
$query = $this->getPlaceOrderQuery();
$this->graphQlStateDiff->testState(
$query,
['cartId' => $cartId],
[],
[],
'placeOrder',
'"data":{"placeOrder":',
$this
);
}
private function getBillingAddressQuery(): string
{
return <<<'QUERY'
mutation($cartId: String!) {
setBillingAddressOnCart(
input: {
cart_id: $cartId
billing_address: {
address: {
firstname: "John"
lastname: "Doe"
street: ["123 Main Street"]
city: "New York"
region: "NY"
postcode: "10001"
country_code: "US"
telephone: "555-555-5555"
}
}
}
) {
cart {
id
billing_address {
firstname
lastname
street
city
region {
code
label
}
postcode
country {
code
label
}
telephone
}
}
}
}
QUERY;
}
private function getShippingAddressQuery(): string
{
return <<<'QUERY'
mutation($cartId: String!) {
setShippingAddressesOnCart(
input: {
cart_id: $cartId
shipping_addresses: [
{
address: {
firstname: "John"
lastname: "Doe"
street: ["123 Main Street"]
city: "New York"
region: "NY"
postcode: "10001"
country_code: "US"
telephone: "555-555-5555"
}
}
]
}
) {
cart {
id
shipping_addresses {
firstname
lastname
street
city
region {
code
label
}
postcode
country {
code
label
}
telephone
available_shipping_methods {
carrier_code
method_code
amount {
value
}
}
}
}
}
}
QUERY;
}
/**
* Function returns array of all product's links
*
* @param string $sku
* @return array
*/
private function getProductsLinks(string $sku) : array
{
$result = [];
$productRepository = $this->graphQlStateDiff->getTestObjectManager()
->get(ProductRepositoryInterface::class);
$product = $productRepository->get($sku, false, null, true);
foreach ($product->getDownloadableLinks() as $linkObject) {
$result[$linkObject->getLinkId()] = [
'title' => $linkObject->getTitle(),
'link_type' => null, //deprecated field
'price' => $linkObject->getPrice(),
];
}
return $result;
}
private function getAddDownloadableProductToCartQuery(): string
{
return <<<'MUTATION'
mutation($cartId: String!, $qty: Float!, $sku: String!, $linkId: Int!) {
addDownloadableProductsToCart(
input: {
cart_id: $cartId,
cart_items: [
{
data: {
quantity: $qty,
sku: $sku
},
downloadable_product_links: [
{
link_id: $linkId
}
]
}
]
}
) {
cart {
items {
quantity
... on DownloadableCartItem {
links {
title
link_type
price
}
samples {
id
title
}
}
}
}
}
}
MUTATION;
}
private function getAddConfigurableProductToCartQuery(): string
{
return <<<'QUERY'
mutation($cartId: String!, $quantity: Float!, $parentSku: String!, $childSku: String!) {
addConfigurableProductsToCart(
input:{
cart_id: $cartId
cart_items:{
parent_sku: $parentSku
data:{
sku: $childSku
quantity:$quantity
}
}
}
) {
cart {
id
items {
id
quantity
product {
sku
}
... on ConfigurableCartItem {
configurable_options {
id
option_label
value_id
value_label
}
}
}
}
}
}
QUERY;
}
private function getAddBundleProductToCartQuery(string $sku)
{
$productRepository = $this->graphQlStateDiff->getTestObjectManager()->get(ProductRepositoryInterface::class);
$product = $productRepository->get($sku);
/** @var $typeInstance \Magento\Bundle\Model\Product\Type */
$typeInstance = $product->getTypeInstance();
$typeInstance->setStoreFilter($product->getStoreId(), $product);
/** @var $option \Magento\Bundle\Model\Option */
$option = $typeInstance->getOptionsCollection($product)->getFirstItem();
/** @var \Magento\Catalog\Model\Product $selection */
$selection = $typeInstance->getSelectionsCollection([$option->getId()], $product)->getFirstItem();
$optionId = $option->getId();
$selectionId = $selection->getSelectionId();
return <<<QUERY
mutation(\$cartId: String!) {
addBundleProductsToCart(input:{
cart_id:\$cartId
cart_items:[
{
data:{
sku:"{$sku}"
quantity:1
}
bundle_options:[
{
id:{$optionId}
quantity:1
value:[
"{$selectionId}"
]
}
]
}
]
}) {
cart {
items {
id
uid
quantity
product {
sku
}
... on BundleCartItem {
bundle_options {
id
uid
label
type
values {
id
uid
label
price
quantity
}
}
}
}
}
}
}
QUERY;
}
/**
* @return string
*/
private function getAddProductToCartQuery(): string
{
return <<<'QUERY'
mutation($cartId: String!, $qty: Float!, $sku: String!) {
addSimpleProductsToCart(
input: {
cart_id: $cartId
cart_items: [
{
data: {
quantity: $qty
sku: $sku
}
}
]
}
) {
cart {
items {
quantity
product {
sku
}
}
}
}
}
QUERY;
}
/**
* @return string
*/
private function getAddVirtualProductToCartQuery(): string
{
return <<<'QUERY'
mutation($cartId: String!, $quantity: Float!, $sku: String!) {
addVirtualProductsToCart(
input: {
cart_id: $cartId
cart_items: [
{
data: {
quantity: $quantity
sku: $sku
}
}
]
}
) {
cart {
id
items {
quantity
product {
sku
}
}
}
}
}
QUERY;
}
/**
* @return string
*/
private function getEmptyCart(): string
{
return <<<QUERY
mutation {
createEmptyCart
}
QUERY;
}
/**
* @return string
*/
private function getShippingMethodsQuery()
{
return <<<'QUERY'
mutation($cartId: String!, $shippingMethod: String!) {
setShippingMethodsOnCart(
input: {
cart_id: $cartId
shipping_methods: [
{
carrier_code: $shippingMethod
method_code: $shippingMethod
}
]
}
) {
cart {
id
shipping_addresses {
selected_shipping_method {
carrier_code
method_code
carrier_title
method_title
}
}
}
}
}
QUERY;
}
/**
* @return string
*/
private function getPaymentMethodQuery()
{
return <<<'QUERY'
mutation($cartId: String!) {
setPaymentMethodOnCart(
input: {
cart_id: $cartId
payment_method: {
code: "checkmo"
}
}
) {
cart {
id
selected_payment_method {
code
title
}
}
}
}
QUERY;
}
/**
* @return string
*/
private function getPlaceOrderQuery(): string
{
return <<<'QUERY'
mutation($cartId: String!) {
placeOrder(
input: {
cart_id: $cartId
}
) {
order {
order_number
}
}
}
QUERY;
}
/**
* @return string
*/
private function getAddCouponToCartQuery(): string
{
return <<<'QUERY'
mutation($cartId: String!, $couponCode: String!) {
applyCouponToCart(
input: {
cart_id: $cartId
coupon_code: $couponCode
}
) {
cart {
id
applied_coupons {
code
}
}
}
}
QUERY;
}
}
@@ -0,0 +1,506 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\GraphQl\App;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Registry;
use Magento\GraphQl\App\State\GraphQlStateDiff;
/**
* Tests the dispatch method in the GraphQl Controller class using a simple product query
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @magentoDbIsolation disabled
* @magentoAppIsolation enabled
* @magentoAppArea graphql
*/
class GraphQlCustomerMutationsTest extends \PHPUnit\Framework\TestCase
{
/**
* @var GraphQlStateDiff|null
*/
private ?GraphQlStateDiff $graphQlStateDiff = null;
/**
* @inheritDoc
*/
protected function setUp(): void
{
if (!class_exists(GraphQlStateDiff::class)) {
$this->markTestSkipped('GraphQlStateDiff class is not available on this version of Magento.');
}
$this->graphQlStateDiff = new GraphQlStateDiff($this);
parent::setUp();
}
/**
* @inheritDoc
*/
protected function tearDown(): void
{
$this->graphQlStateDiff->tearDown();
$this->graphQlStateDiff = null;
parent::tearDown();
}
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoDataFixture Magento/Customer/_files/customer_address.php
* @dataProvider customerDataProvider
* @return void
*/
public function testCustomerState(
string $query,
array $variables,
array $variables2,
array $authInfo,
string $operationName,
string $expected,
) : void {
if ($operationName === 'createCustomer') {
$emails = [$variables['email'], $variables2['email']];
$this->clearCustomerBeforeTest($emails);
}
$this->graphQlStateDiff->
testState($query, $variables, $variables2, $authInfo, $operationName, $expected, $this);
}
/**
* @param array $emails
* @return void
*/
private function clearCustomerBeforeTest(array $emails): void
{
$customerRepository = $this->graphQlStateDiff->getTestObjectManager()
->get(CustomerRepositoryInterface::class);
$registry = $this->graphQlStateDiff->getTestObjectManager()->get(Registry::class);
$registry->register('isSecureArea', true);
foreach ($emails as $email) {
try {
$customer = $customerRepository->get($email);
$customerRepository->delete($customer);
} catch (NoSuchEntityException $e) {
// Customer does not exist
}
}
$registry->unregister('isSecureArea', false);
}
/**
*
* @magentoDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*/
public function testMergeCarts(): void
{
$cartId1 = $this->graphQlStateDiff->getCartIdHash('test_order_with_virtual_product_without_address');
$cartId2 = $this->graphQlStateDiff->getCartIdHash('test_quote');
$query = $this->getCartMergeMutation();
$this->graphQlStateDiff->testState(
$query,
['cartId1' => $cartId1, 'cartId2' => $cartId2],
[],
['email' => 'customer@example.com', 'password' => 'password'],
'mergeCarts',
'"data":{"mergeCarts":',
$this
);
}
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
* @return void
*/
public function testRequestPasswordResetEmail(): void
{
$query = $this->getRequestPasswordResetEmailMutation();
$this->graphQlStateDiff->testState(
$query,
['email' => 'customer@example.com'],
[],
[],
'requestPasswordResetEmail',
'"data":{"requestPasswordResetEmail":',
$this
);
}
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
* @return void
*/
public function testResetPassword(): void
{
$query = $this->getResetPasswordMutation();
$email = 'customer@example.com';
$this->graphQlStateDiff->testState(
$query,
['email' => $email, 'newPassword' => 'new_password123', 'resetPasswordToken' =>
$this->graphQlStateDiff->getResetPasswordToken($email)],
[],
[],
'resetPassword',
'"data":{"resetPassword":',
$this
);
}
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
* @return void
*/
public function testChangePassword(): void
{
$query = $this->getChangePasswordMutation();
$this->graphQlStateDiff->testState(
$query,
['currentPassword' => 'password', 'newPassword' => 'new_password123'],
['currentPassword' => 'new_password123', 'newPassword' => 'password_new123'],
[['email'=>'customer@example.com', 'password' => 'password'],
['email'=>'customer@example.com', 'password' => 'new_password123']],
'changeCustomerPassword',
'"data":{"changeCustomerPassword":',
$this
);
}
/**
* @magentoDataFixture Magento/Customer/_files/customer_without_addresses.php
* @return void
*/
public function testCreateCustomerAddress(): void
{
$query = $this->getCreateCustomerAddressMutation();
$this->graphQlStateDiff->testState(
$query,
[],
[],
['email' => 'customer@example.com', 'password' => 'password'],
'createCustomerAddress',
'"data":{"createCustomerAddress":',
$this
);
}
/**
* Queries, variables, operation names, and expected responses for test
*
* @return array[]
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function customerDataProvider(): array
{
return [
'Create Customer' => [
<<<'QUERY'
mutation($firstname: String!, $lastname: String!, $email: String!, $password: String!) {
createCustomerV2(
input: {
firstname: $firstname,
lastname: $lastname,
email: $email,
password: $password
}
) {
customer {
created_at
prefix
firstname
middlename
lastname
suffix
email
default_billing
default_shipping
date_of_birth
taxvat
is_subscribed
gender
allow_remote_shopping_assistance
}
}
}
QUERY,
[
'firstname' => 'John',
'lastname' => 'Doe',
'email' => 'email1@example.com',
'password' => 'Password-1',
],
[
'firstname' => 'John',
'lastname' => 'Doe',
'email' => 'email2@adobe.com',
'password' => 'Password-2',
],
[],
'createCustomer',
'"email":"',
],
'Update Customer' => [
<<<'QUERY'
mutation($allow: Boolean!) {
updateCustomerV2(
input: {
allow_remote_shopping_assistance: $allow
}
)
{
customer {
allow_remote_shopping_assistance
}
}
}
QUERY,
['allow' => true],
['allow' => false],
['email' => 'customer@example.com', 'password' => 'password'],
'updateCustomer',
'allow_remote_shopping_assistance'
],
'Update Customer Address' => [
<<<'QUERY'
mutation($addressId: Int!, $city: String!) {
updateCustomerAddress(id: $addressId, input: {
region: {
region: "Alberta"
region_id: 66
region_code: "AB"
}
country_code: CA
street: ["Line 1 Street","Line 2"]
company: "Company Name"
telephone: "123456789"
fax: "123123123"
postcode: "7777"
city: $city
firstname: "Adam"
lastname: "Phillis"
middlename: "A"
prefix: "Mr."
suffix: "Jr."
vat_id: "1"
default_shipping: true
default_billing: true
}) {
id
customer_id
region {
region
region_id
region_code
}
country_code
street
company
telephone
fax
postcode
city
firstname
lastname
middlename
prefix
suffix
vat_id
default_shipping
default_billing
}
}
QUERY,
['addressId' => 1, 'city' => 'New York'],
['addressId' => 1, 'city' => 'Austin'],
['email' => 'customer@example.com', 'password' => 'password'],
'updateCustomerAddress',
'city'
],
'Update Customer Email' => [
<<<'QUERY'
mutation($email: String!, $password: String!) {
updateCustomerEmail(
email: $email
password: $password
) {
customer {
email
}
}
}
QUERY,
['email' => 'customer2@example.com', 'password' => 'password'],
['email' => 'customer@example.com', 'password' => 'password'],
[
['email' => 'customer@example.com', 'password' => 'password'],
['email' => 'customer2@example.com', 'password' => 'password'],
],
'updateCustomerEmail',
'email',
],
'Generate Customer Token' => [
<<<'QUERY'
mutation($email: String!, $password: String!) {
generateCustomerToken(email: $email, password: $password) {
token
}
}
QUERY,
['email' => 'customer@example.com', 'password' => 'password'],
['email' => 'customer@example.com', 'password' => 'password'],
[],
'generateCustomerToken',
'token'
],
'Get Customer' => [
<<<'QUERY'
query {
customer {
created_at
date_of_birth
default_billing
default_shipping
date_of_birth
email
firstname
gender
id
is_subscribed
lastname
middlename
prefix
suffix
taxvat
}
}
QUERY,
[],
[],
['email' => 'customer@example.com', 'password' => 'password'],
'getCustomer',
'"data":{"customer":{"created_at"'
],
];
}
private function getCartMergeMutation(): string
{
return <<<'QUERY'
mutation($cartId1: String!, $cartId2: String!) {
mergeCarts(
source_cart_id: $cartId1
destination_cart_id: $cartId2
) {
items {
quantity
product {
sku
}
}
}
}
QUERY;
}
private function getRequestPasswordResetEmailMutation(): string
{
return <<<'QUERY'
mutation($email: String!) {
requestPasswordResetEmail(email: $email)
}
QUERY;
}
private function getResetPasswordMutation()
{
return <<<'QUERY'
mutation($email: String!, $newPassword: String!, $resetPasswordToken: String!) {
resetPassword(
email: $email
resetPasswordToken: $resetPasswordToken
newPassword: $newPassword
)
}
QUERY;
}
private function getChangePasswordMutation()
{
return <<<'QUERY'
mutation($currentPassword: String!, $newPassword: String!) {
changeCustomerPassword(
currentPassword: $currentPassword
newPassword: $newPassword
) {
id
email
firstname
lastname
}
}
QUERY;
}
private function getCreateCustomerAddressMutation(): string
{
return <<<'QUERY'
mutation {
createCustomerAddress(
input: {
region: {
region: "Alberta"
region_id: 66
region_code: "AB"
}
country_code: CA
street: ["Line 1 Street","Line 2"]
company: "Company Name"
telephone: "123456789"
fax: "123123123"
postcode: "7777"
city: "New York"
firstname: "Adam"
lastname: "Phillis"
middlename: "A"
prefix: "Mr."
suffix: "Jr."
vat_id: "1"
default_shipping: true
default_billing: true
}
) {
id
customer_id
region {
region
region_id
region_code
}
country_code
street
company
telephone
fax
postcode
city
firstname
lastname
middlename
prefix
suffix
vat_id
default_shipping
default_billing
}
}
QUERY;
}
}
@@ -0,0 +1,562 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\GraphQl\App;
use Magento\GraphQl\App\State\GraphQlStateDiff;
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
/**
* Tests the dispatch method in the GraphQl Controller class using a simple product query
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @magentoDbIsolation disabled
* @magentoAppIsolation enabled
* @magentoAppArea graphql
*/
class GraphQlStateTest extends \PHPUnit\Framework\TestCase
{
/**
* @var GetMaskedQuoteIdByReservedOrderId
*/
private $getMaskedQuoteIdByReservedOrderId;
/**
* @var GraphQlStateDiff|null
*/
private ?GraphQlStateDiff $graphQlStateDiff;
/**
* @inheritDoc
*/
protected function setUp(): void
{
if (!class_exists(GraphQlStateDiff::class)) {
$this->markTestSkipped('GraphQlStateDiff class is not available on this version of Magento.');
}
$this->graphQlStateDiff = new GraphQlStateDiff($this);
parent::setUp();
}
/**
* @inheritDoc
*/
protected function tearDown(): void
{
$this->graphQlStateDiff->tearDown();
$this->graphQlStateDiff = null;
parent::tearDown();
}
/**
* Runs various GraphQL queries and checks if state of shared objects in Object Manager have changed
* @dataProvider queryDataProvider
* @param string $query
* @param array $variables
* @param array $variables2 This is the second set of variables to be used in the second request
* @param array $authInfo
* @param string $operationName
* @param string $expected
* @magentoDataFixture Magento/Store/_files/store.php
* @magentoDataFixture Magento/Catalog/_files/multiple_mixed_products.php
* @magentoDataFixture Magento/Catalog/_files/categories.php
* @return void
* @throws \Exception
*/
public function testState(
string $query,
array $variables,
array $variables2,
array $authInfo,
string $operationName,
string $expected,
): void {
$this->graphQlStateDiff
->testState($query, $variables, $variables2, $authInfo, $operationName, $expected, $this);
}
/**
* @magentoConfigFixture default_store catalog/seo/product_url_suffix test_product_suffix
* @magentoConfigFixture default_store catalog/seo/category_url_suffix test_category_suffix
* @magentoConfigFixture default_store catalog/seo/title_separator ___
* @magentoConfigFixture default_store catalog/frontend/list_mode 2
* @magentoConfigFixture default_store catalog/frontend/grid_per_page_values 16
* @magentoConfigFixture default_store catalog/frontend/list_per_page_values 8
* @magentoConfigFixture default_store catalog/frontend/grid_per_page 16
* @magentoConfigFixture default_store catalog/frontend/list_per_page 8
* @magentoConfigFixture default_store catalog/frontend/default_sort_by asc
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
* @dataProvider cartQueryProvider
* @param string $query
* @param array $variables
* @param array $variables2
* @param array $authInfo
* @param string $operationName
* @param string $expected
* @return void
*/
public function testCartState(
string $query,
array $variables,
array $variables2,
array $authInfo,
string $operationName,
string $expected
): void {
if ($operationName == 'getCart') {
$this->getMaskedQuoteIdByReservedOrderId =
$this->graphQlStateDiff->getTestObjectManager()->get(GetMaskedQuoteIdByReservedOrderId::class);
$variables['id'] = $this->getMaskedQuoteIdByReservedOrderId->execute($variables['id']);
}
$this->graphQlStateDiff
->testState($query, $variables, $variables2, $authInfo, $operationName, $expected, $this);
}
/**
* Queries, variables, operation names, and expected responses for test
*
* @return array[]
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
*/
private function queryDataProvider(): array
{
return [
'Get Navigation Menu by category_id' => [
<<<'QUERY'
query navigationMenu($id: Int!) {
category(id: $id) {
id
name
product_count
path
children {
id
name
position
level
url_key
url_path
product_count
children_count
path
productImagePreview: products(pageSize: 1) {
items {
small_image {
label
url
}
}
}
}
}
}
QUERY,
['id' => 4],
[],
[],
'navigationMenu',
'"id":4,"name":"Category 1.1","product_count":2,'
],
'Get Product Search by product_name' => [
<<<'QUERY'
query productDetailByName($name: String, $onServer: Boolean!) {
products(filter: { name: { match: $name } }) {
items {
id
sku
name
... on ConfigurableProduct {
configurable_options {
attribute_code
attribute_id
id
label
values {
default_label
label
store_label
use_default_value
value_index
}
}
variants {
product {
#fashion_color
#fashion_size
id
media_gallery_entries {
disabled
file
label
position
}
sku
stock_status
}
}
}
meta_title @include(if: $onServer)
meta_keyword @include(if: $onServer)
meta_description @include(if: $onServer)
}
}
}
QUERY,
['name' => 'Configurable%20Product', 'onServer' => false],
[],
[],
'productDetailByName',
'"sku":"configurable","name":"Configurable Product"'
],
'Get List of Products by category_id' => [
<<<'QUERY'
query category($id: Int!, $currentPage: Int, $pageSize: Int) {
category(id: $id) {
product_count
description
url_key
name
id
breadcrumbs {
category_name
category_url_key
__typename
}
products(pageSize: $pageSize, currentPage: $currentPage) {
total_count
items {
id
name
# small_image
# short_description
url_key
special_price
special_from_date
special_to_date
price {
regularPrice {
amount {
value
currency
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
}
QUERY,
['id' => 4, 'currentPage' => 1, 'pageSize' => 12],
[],
[],
'category',
'"url_key":"category-1-1","name":"Category 1.1"'
],
'Get Simple Product Details by name' => [
<<<'QUERY'
query productDetail($name: String, $onServer: Boolean!) {
productDetail: products(filter: { name: { match: $name } }) {
items {
sku
name
price {
regularPrice {
amount {
currency
value
}
}
}
description {html}
media_gallery_entries {
label
position
disabled
file
}
... on ConfigurableProduct {
configurable_options {
attribute_code
attribute_id
id
label
values {
default_label
label
store_label
use_default_value
value_index
}
}
variants {
product {
id
media_gallery_entries {
disabled
file
label
position
}
sku
stock_status
}
}
}
meta_title @include(if: $onServer)
# Yes, Products have `meta_keyword` and
# everything else has `meta_keywords`.
meta_keyword @include(if: $onServer)
meta_description @include(if: $onServer)
}
}
}
QUERY,
['name' => 'Simple Product1', 'onServer' => false],
[],
[],
'productDetail',
'"sku":"simple1","name":"Simple Product1"'
],
'Get Url Info by url_key' => [
<<<'QUERY'
query resolveUrl($urlKey: String!) {
urlResolver(url: $urlKey) {
type
id
}
}
QUERY,
['urlKey' => 'no-route'],
[],
[],
'resolveUrl',
'"type":"CMS_PAGE","id":1'
],
'Get available Stores' => [
<<<'QUERY'
query availableStores($currentGroup: Boolean!) {
availableStores(useCurrentGroup:$currentGroup) {
id,
code,
store_code,
store_name,
store_sort_order,
is_default_store,
store_group_code,
store_group_name,
is_default_store_group,
website_id,
website_code,
website_name,
locale,
base_currency_code,
default_display_currency_code,
timezone,
weight_unit,
base_url,
base_link_url,
base_media_url,
secure_base_url,
secure_base_link_url,
secure_base_static_url,
secure_base_media_url,
store_name
use_store_in_url
}
}
QUERY,
['currentGroup' => true],
[],
[],
'availableStores',
'"store_code":"default"'
],
'Get store config' => [
<<<'QUERY'
query {
storeConfig {
product_url_suffix,
category_url_suffix,
title_separator,
list_mode,
grid_per_page_values,
list_per_page_values,
grid_per_page,
list_per_page,
catalog_default_sort_by,
root_category_id
root_category_uid
}
}
QUERY,
[],
[],
[],
'storeConfig',
'"storeConfig":{"product_url_suffix":".html"'
],
'Get Categories by name' => [
<<<'QUERY'
query categories($name: String!) {
categories(filters: {name: {match: $name}}
pageSize: 3
currentPage: 3
) {
total_count
page_info {
current_page
page_size
total_pages
}
items {
name
}
}
}
QUERY,
['name' => 'Category'],
[],
[],
'categories',
'"data":{"categories"'
],
'Get Products by name' => [
<<<'QUERY'
query products($name: String!) {
products(
search: $name
filter: {}
pageSize: 1000
currentPage: 1
sort: {name: ASC}
) {
items {
name
image
{
url
}
attribute_set_id
canonical_url
color
country_of_manufacture
created_at
gift_message_available
id
manufacturer
meta_description
meta_keyword
meta_title
new_from_date
new_to_date
only_x_left_in_stock
options_container
rating_summary
review_count
sku
special_price
special_to_date
stock_status
swatch_image
uid
updated_at
url_key
url_path
url_suffix
}
page_info {
current_page
page_size
total_pages
}
sort_fields {
default
}
suggestions {
search
}
total_count
}
}
QUERY,
['name' => 'Simple Product1'],
[],
[],
'products',
'"data":{"products":{"items":[{'
],
];
}
public function cartQueryProvider(): array
{
return [
'Get Cart' => [
<<<'QUERY'
query cart($id: String!) {
cart(cart_id: $id) {
applied_coupons {
code
}
available_payment_methods {
code
is_deferred
title
}
billing_address {
city
company
firstname
lastname
postcode
street
telephone
uid
vat_id
}
email
id
is_virtual
items {
id
quantity
uid
}
selected_payment_method {
code
purchase_order_number
title
}
total_quantity
}
}
QUERY,
['id' => 'test_quote'],
[],
[],
'getCart',
'"cart":{"applied_coupons":null,"available_payment_methods":[{"code":"checkmo"'
],
];
}
}
@@ -0,0 +1,336 @@
<?php
/**
* Copyright 2023 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);
namespace Magento\GraphQl\App\State;
use Magento\Customer\Api\AccountManagementInterface;
use Magento\Customer\Model\AccountManagement;
use Magento\Customer\Model\CustomerRegistry;
use Magento\Framework\App\Area;
use Magento\Framework\App\Http as HttpApp;
use Magento\Framework\App\ObjectManager as AppObjectManager;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Response\Http as HttpResponse;
use Magento\Framework\App\State;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\ApplicationStateComparator\Comparator;
use Magento\Framework\TestFramework\ApplicationStateComparator\ObjectManager;
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\Quote\Model\MaskedQuoteIdToQuoteIdInterface;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
/**
* Tests the dispatch method in the GraphQl Controller class using a simple product query
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class GraphQlStateDiff
{
private const CONTENT_TYPE = 'application/json';
/**
* @var ObjectManagerInterface
*
* phpcs:disable Magento2.Commenting.ClassPropertyPHPDocFormatting
*/
private readonly ObjectManagerInterface $objectManagerBeforeTest;
/**
* @var ObjectManager
*
* phpcs:disable Magento2.Commenting.ClassPropertyPHPDocFormatting
*/
private readonly ObjectManager $objectManagerForTest;
/**
* @var Comparator
*
* phpcs:disable Magento2.Commenting.ClassPropertyPHPDocFormatting
*/
private readonly Comparator $comparator;
/**
* @var State
*/
private State $appState;
/**
* @var string|null
*/
private ?string $currentArea;
/**
* Constructor
*
* @param TestCase $test
*/
public function __construct(TestCase $test)
{
if (8 == PHP_MAJOR_VERSION && 3 == PHP_MINOR_VERSION && PHP_RELEASE_VERSION < 5) {
$test->markTestSkipped(
"This test isn't compatible with PHP 8.3 versions less than PHP 8.3.5 because of "
. "bug in garbage collector. https://github.com/php/php-src/issues/13569"
. " will roll back in AC-11491"
);
}
$this->objectManagerBeforeTest = Bootstrap::getObjectManager();
$this->objectManagerForTest = new ObjectManager($this->objectManagerBeforeTest);
$this->objectManagerForTest->getFactory()->setObjectManager($this->objectManagerForTest);
AppObjectManager::setInstance($this->objectManagerForTest);
Bootstrap::setObjectManager($this->objectManagerForTest);
$this->comparator = $this->objectManagerForTest->create(Comparator::class);
$this->appState = $this->objectManagerForTest->get(State::class);
$this->currentArea = $this->appState->getAreaCode();
$this->appState->setAreaCode(Area::AREA_GRAPHQL);
$this->objectManagerForTest->_resetState();
}
/**
* Gets test object manager
*
* @return ObjectManager
*/
public function getTestObjectManager()
{
return $this->objectManagerForTest;
}
/**
* Tear Down
*
* @return void
*/
public function tearDown(): void
{
$this->objectManagerBeforeTest->getFactory()->setObjectManager($this->objectManagerBeforeTest);
AppObjectManager::setInstance($this->objectManagerBeforeTest);
Bootstrap::setObjectManager($this->objectManagerBeforeTest);
}
/**
* Tests state
*
* @param string $query
* @param array $variables
* @param array $variables2
* @param array $authInfo
* @param string $operationName
* @param string $expected
* @param TestCase $test
* @return void
* @throws LocalizedException
* @throws NoSuchEntityException
* @throws \Magento\Framework\Exception\AuthenticationException
* @throws \Magento\Framework\Exception\CouldNotDeleteException
*/
public function testState(
string $query,
array $variables,
array $variables2,
array $authInfo,
string $operationName,
string $expected,
TestCase $test
): void {
if (array_key_exists(1, $authInfo)) {
$authInfo1 = $authInfo[0];
$authInfo2 = $authInfo[1];
} else {
$authInfo1 = $authInfo;
$authInfo2 = $authInfo;
}
$jsonEncodedRequest = json_encode([
'query' => $query,
'variables' => $variables,
'operationName' => $operationName
]);
$output1 = $this->request($jsonEncodedRequest, $operationName, $authInfo1, $test, true);
$test->assertStringContainsString($expected, $output1);
if ($operationName === 'placeOrder' || $operationName === 'mergeCarts') {
foreach ($variables as $cartId) {
$this->reactivateCart($cartId);
}
} elseif ($operationName==='applyCouponToCart') {
$this->removeCouponFromCart($variables);
} elseif ($operationName==='resetPassword') {
$variables2['resetPasswordToken'] = $this->getResetPasswordToken($variables['email']);
$variables2['email'] = $variables['email'];
$variables2['newPassword'] = $variables['newPassword'];
}
if ($variables2) {
$jsonEncodedRequest = json_encode([
'query' => $query,
'variables' => $variables2,
'operationName' => $operationName
]);
}
$output2 = $this->request($jsonEncodedRequest, $operationName, $authInfo2, $test);
$test->assertStringContainsString($expected, $output2);
}
/**
* Makes request
*
* @param string $query
* @param string $operationName
* @param array $authInfo
* @param TestCase $test
* @param bool $firstRequest
* @return string
* @throws LocalizedException
* @throws \Magento\Framework\Exception\AuthenticationException
*/
private function request(
string $query,
string $operationName,
array $authInfo,
TestCase $test,
bool $firstRequest = false
): string {
$this->objectManagerForTest->_resetState();
$this->comparator->rememberObjectsStateBefore($firstRequest);
$response = $this->doRequest($query, $authInfo);
$this->objectManagerForTest->_resetState();
$this->comparator->rememberObjectsStateAfter($firstRequest);
$result = $this->comparator->compareBetweenRequests($operationName);
$test->assertEmpty(
$result,
sprintf(
'%d objects changed state during request. Details: %s',
count($result),
var_export($result, true)
)
);
$result = $this->comparator->compareConstructedAgainstCurrent($operationName);
$test->assertEmpty(
$result,
sprintf(
'%d objects changed state since constructed. Details: %s',
count($result),
var_export($result, true)
)
);
return $response;
}
/**
* Process the GraphQL request
*
* @param string $query
* @param array $authInfo
* @return mixed|string
* @throws LocalizedException
* @throws \Magento\Framework\Exception\AuthenticationException
*/
private function doRequest(string $query, array $authInfo)
{
$request = $this->objectManagerForTest->get(RequestInterface::class);
$request->setContent($query);
$request->setMethod('POST');
$request->setPathInfo('/graphql');
$request->getHeaders()->addHeaders(['content_type' => self::CONTENT_TYPE]);
if ($authInfo) {
$email = $authInfo['email'];
$password = $authInfo['password'];
$customerToken = $this->objectManagerForTest->get(CustomerTokenServiceInterface::class)
->createCustomerAccessToken($email, $password);
$request->getHeaders()->addHeaders(['Authorization' => 'Bearer ' . $customerToken]);
}
$unusedResponse = $this->objectManagerForTest->create(HttpResponse::class);
$httpApp = $this->objectManagerForTest->create(
HttpApp::class,
['request' => $request, 'response' => $unusedResponse]
);
$actualResponse = $httpApp->launch();
return $actualResponse->getContent();
}
/**
* Removes coupon from cart
*
* @param array $variables
* @return void
* @throws NoSuchEntityException
* @throws \Magento\Framework\Exception\CouldNotDeleteException
*/
private function removeCouponFromCart(array $variables)
{
$couponManagement = $this->objectManagerForTest->get(\Magento\Quote\Api\CouponManagementInterface::class);
$cartId = $this->getCartId($variables['cartId']);
$couponManagement->remove($cartId);
}
/**
* Reactivates cart
*
* @param string $cartId
* @return void
* @throws NoSuchEntityException
*/
private function reactivateCart(string $cartId)
{
$cartId = $this->getCartId($cartId);
$cart = $this->objectManagerForTest->get(\Magento\Quote\Model\Quote::class);
$cart->load($cartId);
$cart->setIsActive(true);
$cart->save();
}
/**
* Gets cart id
*
* @param string $cartId
* @return int
* @throws NoSuchEntityException
*/
private function getCartId(string $cartId)
{
$maskedQuoteIdToQuoteId = $this->objectManagerForTest->get(MaskedQuoteIdToQuoteIdInterface::class);
return $maskedQuoteIdToQuoteId->execute($cartId);
}
/**
* Gets cart id hash
*
* @param string $cartId
* @return string
* @throws NoSuchEntityException
*/
public function getCartIdHash(string $cartId): string
{
$getMaskedQuoteIdByReservedOrderId = $this->getTestObjectManager()
->get(GetMaskedQuoteIdByReservedOrderId::class);
return $getMaskedQuoteIdByReservedOrderId->execute($cartId);
}
/**
* Get reset password token
*
* @param string $email
* @return string
* @throws LocalizedException
* @throws NoSuchEntityException
*/
public function getResetPasswordToken(string $email): string
{
$accountManagement = $this->objectManagerForTest->get(AccountManagementInterface::class);
$customerRegistry = $this->objectManagerForTest->get(CustomerRegistry::class);
$accountManagement->initiatePasswordReset(
$email,
AccountManagement::EMAIL_RESET,
1
);
$customerSecure = $customerRegistry->retrieveSecureData(1);
return $customerSecure->getRpToken();
}
}