Skip to content

Commit 5409dfa

Browse files
author
Yu Tang
committed
MAGETWO-33120: Refactor code that uses customer builders in integration tests
- Fixed build errors and renamed method name
1 parent c05c39a commit 5409dfa

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

dev/tests/integration/testsuite/Magento/Customer/Api/AddressRepositoryTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ protected function setUp()
5555
->setCity('CityM')
5656
->setFirstname('John')
5757
->setLastname('Smith')
58-
->setCompany('CompanyName');
58+
->setCompany('CompanyName')
59+
->setCustomAttributes([]);
5960

6061
/* XXX: would it be better to have a clear method for this? */
6162
$address2 = $this->_addressFactory->create()
@@ -68,7 +69,8 @@ protected function setUp()
6869
->setCity('CityX')
6970
->setTelephone('3234676')
7071
->setFirstname('John')
71-
->setLastname('Smith');
72+
->setLastname('Smith')
73+
->setCustomAttributes([]);
7274

7375
$this->_expectedAddresses = [$address, $address2];
7476
}
@@ -111,7 +113,7 @@ public function testSaveAddressChanges()
111113
*/
112114
public function testSaveAddressesIdSetButNotAlreadyExisting()
113115
{
114-
$proposedAddress = $this->_createSecondAddressBuilder()->setId(4200);
116+
$proposedAddress = $this->_createSecondAddress()->setId(4200);
115117
$this->repository->save($proposedAddress);
116118
}
117119

@@ -145,7 +147,7 @@ public function testGetAddressByIdBadAddressId()
145147
*/
146148
public function testSaveNewAddress()
147149
{
148-
$proposedAddress = $this->_createSecondAddressBuilder()->setCustomerId(1);
150+
$proposedAddress = $this->_createSecondAddress()->setCustomerId(1);
149151

150152
$returnedAddress = $this->repository->save($proposedAddress);
151153
$this->assertNotNull($returnedAddress->getId());
@@ -209,7 +211,7 @@ public function testSaveNewInvalidAddress()
209211

210212
public function testSaveAddressesCustomerIdNotExist()
211213
{
212-
$proposedAddress = $this->_createSecondAddressBuilder()->setCustomerId(4200);
214+
$proposedAddress = $this->_createSecondAddress()->setCustomerId(4200);
213215
try {
214216
$this->repository->save($proposedAddress);
215217
$this->fail('Expected exception not thrown');
@@ -220,7 +222,7 @@ public function testSaveAddressesCustomerIdNotExist()
220222

221223
public function testSaveAddressesCustomerIdInvalid()
222224
{
223-
$proposedAddress = $this->_createSecondAddressBuilder()->setCustomerId('this_is_not_a_valid_id');
225+
$proposedAddress = $this->_createSecondAddress()->setCustomerId('this_is_not_a_valid_id');
224226
try {
225227
$this->repository->save($proposedAddress);
226228
$this->fail('Expected exception not thrown');
@@ -403,7 +405,7 @@ private function _createFirstAddress()
403405
*
404406
* @return \Magento\Customer\Api\Data\AddressInterface
405407
*/
406-
private function _createSecondAddressBuilder()
408+
private function _createSecondAddress()
407409
{
408410
$address = $this->_addressFactory->create();
409411
$this->dataObjectHelper->mergeDataObjects(

dev/tests/integration/testsuite/Magento/Customer/Model/Resource/AddressRepositoryTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ protected function setUp()
5656
->setCity('CityM')
5757
->setFirstname('John')
5858
->setLastname('Smith')
59-
->setCompany('CompanyName');
59+
->setCompany('CompanyName')
60+
->setCustomAttributes([]);
6061
$address2 = $this->_addressFactory->create()
6162
->setId('2')
6263
->setCountryId('US')
@@ -67,7 +68,8 @@ protected function setUp()
6768
->setCity('CityX')
6869
->setTelephone('3234676')
6970
->setFirstname('John')
70-
->setLastname('Smith');
71+
->setLastname('Smith')
72+
->setCustomAttributes([]);
7173

7274
$this->_expectedAddresses = [$address, $address2];
7375
}
@@ -111,7 +113,7 @@ public function testSaveAddressChanges()
111113
*/
112114
public function testSaveAddressesIdSetButNotAlreadyExisting()
113115
{
114-
$proposedAddress = $this->_createSecondAddressBuilder()->setId(4200);
116+
$proposedAddress = $this->_createSecondAddress()->setId(4200);
115117
$this->repository->save($proposedAddress);
116118
}
117119

@@ -145,7 +147,7 @@ public function testGetAddressByIdBadAddressId()
145147
*/
146148
public function testSaveNewAddress()
147149
{
148-
$proposedAddress = $this->_createSecondAddressBuilder()->setCustomerId(1);
150+
$proposedAddress = $this->_createSecondAddress()->setCustomerId(1);
149151

150152
$returnedAddress = $this->repository->save($proposedAddress);
151153
$this->assertNotNull($returnedAddress->getId());
@@ -209,7 +211,7 @@ public function testSaveNewInvalidAddress()
209211

210212
public function testSaveAddressesCustomerIdNotExist()
211213
{
212-
$proposedAddress = $this->_createSecondAddressBuilder()->setCustomerId(4200);
214+
$proposedAddress = $this->_createSecondAddress()->setCustomerId(4200);
213215
try {
214216
$this->repository->save($proposedAddress);
215217
$this->fail('Expected exception not thrown');
@@ -220,7 +222,7 @@ public function testSaveAddressesCustomerIdNotExist()
220222

221223
public function testSaveAddressesCustomerIdInvalid()
222224
{
223-
$proposedAddress = $this->_createSecondAddressBuilder()->setCustomerId('this_is_not_a_valid_id');
225+
$proposedAddress = $this->_createSecondAddress()->setCustomerId('this_is_not_a_valid_id');
224226
try {
225227
$this->repository->save($proposedAddress);
226228
$this->fail('Expected exception not thrown');
@@ -403,7 +405,7 @@ private function _createFirstAddress()
403405
*
404406
* @return \Magento\Customer\Api\Data\AddressInterface
405407
*/
406-
private function _createSecondAddressBuilder()
408+
private function _createSecondAddress()
407409
{
408410
$address = $this->_addressFactory->create();
409411
$this->dataObjectHelper->mergeDataObjects(

0 commit comments

Comments
 (0)