Skip to content

Commit ec4c985

Browse files
author
Valeriy Nayda
committed
GraphQL-57: Manage Address Book
-- Refactoring
1 parent cbe1ea3 commit ec4c985

File tree

4 files changed

+31
-33
lines changed

4 files changed

+31
-33
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CustomerChangePasswordTest.php renamed to dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/ChangeCustomerPasswordTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Magento\TestFramework\Helper\Bootstrap;
1515
use Magento\TestFramework\TestCase\GraphQlAbstract;
1616

17-
class CustomerChangePasswordTest extends GraphQlAbstract
17+
class ChangeCustomerPasswordTest extends GraphQlAbstract
1818
{
1919
/**
2020
* @var AccountManagementInterface

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CustomerAddressCreateTest.php renamed to dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
use Magento\TestFramework\ObjectManager;
1313
use Magento\TestFramework\TestCase\GraphQlAbstract;
1414
use Magento\Integration\Api\CustomerTokenServiceInterface;
15-
use PHPUnit\Framework\TestResult;
1615

17-
class CustomerAddressCreateTest extends GraphQlAbstract
16+
class CreateCustomerAddressTest extends GraphQlAbstract
1817
{
19-
2018
/**
2119
* Verify customers with valid credentials create new address
2220
*
@@ -53,7 +51,7 @@ public function testAddCustomerAddressWithValidCredentials()
5351
$mutation
5452
= <<<MUTATION
5553
mutation {
56-
customerAddressCreate(input: {
54+
createCustomerAddress(input: {
5755
region: {
5856
region: "{$newAddress['region']['region']}"
5957
region_id: {$newAddress['region']['region_id']}
@@ -112,16 +110,16 @@ public function testAddCustomerAddressWithValidCredentials()
112110
$customerRepository = ObjectManager::getInstance()->get(CustomerRepositoryInterface::class);
113111
$customer = $customerRepository->get($userName);
114112
$response = $this->graphQlQuery($mutation, [], '', $headerMap);
115-
$this->assertArrayHasKey('customerAddressCreate', $response);
116-
$this->assertArrayHasKey('customer_id', $response['customerAddressCreate']);
117-
$this->assertEquals($customer->getId(), $response['customerAddressCreate']['customer_id']);
118-
$this->assertArrayHasKey('id', $response['customerAddressCreate']);
113+
$this->assertArrayHasKey('createCustomerAddress', $response);
114+
$this->assertArrayHasKey('customer_id', $response['createCustomerAddress']);
115+
$this->assertEquals($customer->getId(), $response['createCustomerAddress']['customer_id']);
116+
$this->assertArrayHasKey('id', $response['createCustomerAddress']);
119117
/** @var AddressRepositoryInterface $addressRepository */
120118
$addressRepository = ObjectManager::getInstance()->get(AddressRepositoryInterface::class);
121-
$addressId = $response['customerAddressCreate']['id'];
119+
$addressId = $response['createCustomerAddress']['id'];
122120
$address = $addressRepository->getById($addressId);
123-
$this->assertEquals($address->getId(), $response['customerAddressCreate']['id']);
124-
$this->assertCustomerAddressesFields($address, $response['customerAddressCreate']);
121+
$this->assertEquals($address->getId(), $response['createCustomerAddress']['id']);
122+
$this->assertCustomerAddressesFields($address, $response['createCustomerAddress']);
125123
$this->assertCustomerAddressesFields($address, $newAddress);
126124
}
127125

@@ -136,8 +134,8 @@ public function testAddCustomerAddressWithoutCredentials()
136134
$mutation
137135
= <<<MUTATION
138136
mutation{
139-
customerAddressCreate(input: {
140-
prefix: "Mr."
137+
createCustomerAddress(input: {
138+
prefix: "Mr."
141139
firstname: "John"
142140
middlename: "A"
143141
lastname: "Smith"
@@ -175,7 +173,7 @@ public function testAddCustomerAddressWithMissingAttributeWithValidCredentials()
175173
$mutation
176174
= <<<MUTATION
177175
mutation {
178-
customerAddressCreate(input: {
176+
createCustomerAddress(input: {
179177
region_id: 4
180178
country_id: US
181179
street: ["Line 1 Street","Line 2"]

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CustomerAddressDeleteTest.php renamed to dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/DeleteCustomerAddressTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Magento\Integration\Api\CustomerTokenServiceInterface;
1515
use PHPUnit\Framework\TestResult;
1616

17-
class CustomerAddressDeleteTest extends GraphQlAbstract
17+
class DeleteCustomerAddressTest extends GraphQlAbstract
1818
{
1919
/**
2020
* Verify customers with valid credentials with a customer bearer token
@@ -38,16 +38,16 @@ public function testDeleteCustomerAddressWithValidCredentials()
3838
$mutation
3939
= <<<MUTATION
4040
mutation {
41-
customerAddressDelete(id: {$addressId})
41+
deleteCustomerAddress(id: {$addressId})
4242
}
4343
MUTATION;
4444
/** @var CustomerTokenServiceInterface $customerTokenService */
4545
$customerTokenService = ObjectManager::getInstance()->get(CustomerTokenServiceInterface::class);
4646
$customerToken = $customerTokenService->createCustomerAccessToken($userName, $password);
4747
$headerMap = ['Authorization' => 'Bearer ' . $customerToken];
4848
$response = $this->graphQlQuery($mutation, [], '', $headerMap);
49-
$this->assertArrayHasKey('customerAddressDelete', $response);
50-
$this->assertEquals(true, $response['customerAddressDelete']);
49+
$this->assertArrayHasKey('deleteCustomerAddress', $response);
50+
$this->assertEquals(true, $response['deleteCustomerAddress']);
5151
}
5252

5353
/**
@@ -71,7 +71,7 @@ public function testDeleteCustomerAddressWithoutCredentials()
7171
$mutation
7272
= <<<MUTATION
7373
mutation {
74-
customerAddressDelete(id: {$addressId})
74+
deleteCustomerAddress(id: {$addressId})
7575
}
7676
MUTATION;
7777
$this->expectException(\Exception::class);
@@ -105,7 +105,7 @@ public function testDeleteDefaultShippingCustomerAddressWithValidCredentials()
105105
$mutation
106106
= <<<MUTATION
107107
mutation {
108-
customerAddressDelete(id: {$addressId})
108+
deleteCustomerAddress(id: {$addressId})
109109
}
110110
MUTATION;
111111
/** @var CustomerTokenServiceInterface $customerTokenService */
@@ -143,7 +143,7 @@ public function testDeleteDefaultBillingCustomerAddressWithValidCredentials()
143143
$mutation
144144
= <<<MUTATION
145145
mutation {
146-
customerAddressDelete(id: {$addressId})
146+
deleteCustomerAddress(id: {$addressId})
147147
}
148148
MUTATION;
149149
/** @var CustomerTokenServiceInterface $customerTokenService */
@@ -169,7 +169,7 @@ public function testDeleteNonExistCustomerAddressWithValidCredentials()
169169
$mutation
170170
= <<<MUTATION
171171
mutation {
172-
customerAddressDelete(id: 9999)
172+
deleteCustomerAddress(id: 9999)
173173
}
174174
MUTATION;
175175
/** @var CustomerTokenServiceInterface $customerTokenService */

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CustomerAddressUpdateTest.php renamed to dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Magento\Integration\Api\CustomerTokenServiceInterface;
1515
use PHPUnit\Framework\TestResult;
1616

17-
class CustomerAddressUpdateTest extends GraphQlAbstract
17+
class UpdateCustomerAddressTest extends GraphQlAbstract
1818
{
1919
/**
2020
* Verify customers with valid credentials update address
@@ -63,7 +63,7 @@ public function testUpdateCustomerAddressWithValidCredentials()
6363
$mutation
6464
= <<<MUTATION
6565
mutation {
66-
customerAddressUpdate(id: {$addressId}, input: {
66+
updateCustomerAddress(id: {$addressId}, input: {
6767
region: {
6868
region: "{$updateAddress['region']['region']}"
6969
region_id: {$updateAddress['region']['region_id']}
@@ -120,15 +120,15 @@ public function testUpdateCustomerAddressWithValidCredentials()
120120
$customerRepository = ObjectManager::getInstance()->get(CustomerRepositoryInterface::class);
121121
$customer = $customerRepository->get($userName);
122122
$response = $this->graphQlQuery($mutation, [], '', $headerMap);
123-
$this->assertArrayHasKey('customerAddressUpdate', $response);
124-
$this->assertArrayHasKey('customer_id', $response['customerAddressUpdate']);
125-
$this->assertEquals($customer->getId(), $response['customerAddressUpdate']['customer_id']);
126-
$this->assertArrayHasKey('id', $response['customerAddressUpdate']);
123+
$this->assertArrayHasKey('updateCustomerAddress', $response);
124+
$this->assertArrayHasKey('customer_id', $response['updateCustomerAddress']);
125+
$this->assertEquals($customer->getId(), $response['updateCustomerAddress']['customer_id']);
126+
$this->assertArrayHasKey('id', $response['updateCustomerAddress']);
127127
/** @var AddressRepositoryInterface $addressRepository */
128128
$addressRepository = ObjectManager::getInstance()->get(AddressRepositoryInterface::class);
129129
$address = $addressRepository->getById($addressId);
130-
$this->assertEquals($address->getId(), $response['customerAddressUpdate']['id']);
131-
$this->assertCustomerAddressesFields($address, $response['customerAddressUpdate']);
130+
$this->assertEquals($address->getId(), $response['updateCustomerAddress']['id']);
131+
$this->assertCustomerAddressesFields($address, $response['updateCustomerAddress']);
132132
$this->assertCustomerAddressesFields($address, $updateAddress);
133133
}
134134

@@ -153,7 +153,7 @@ public function testUpdateCustomerAddressWithoutCredentials()
153153
$mutation
154154
= <<<MUTATION
155155
mutation {
156-
customerAddressUpdate(id:{$addressId}, input: {
156+
updateCustomerAddress(id:{$addressId}, input: {
157157
city: "New City"
158158
postcode: "5555"
159159
}) {
@@ -192,7 +192,7 @@ public function testUpdateCustomerAddressWithMissingAttributeWithValidCredential
192192
$mutation
193193
= <<<MUTATION
194194
mutation {
195-
customerAddressUpdate(id: {$addressId}, input: {
195+
updateCustomerAddress(id: {$addressId}, input: {
196196
firstname: ""
197197
lastname: "Phillis"
198198
}) {

0 commit comments

Comments
 (0)