1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* integer_net Magento Module |
4
|
|
|
* |
5
|
|
|
* @category IntegerNet |
6
|
|
|
* @package IntegerNet_Anonymizer |
7
|
|
|
* @copyright Copyright (c) 2015 integer_net GmbH (http://www.integer-net.de/) |
8
|
|
|
* @author Fabian Schmengler <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @group IntegerNet_Anonymizer |
13
|
|
|
*/ |
14
|
|
View Code Duplication |
class IntegerNet_Anonymizer_Test_Model_Bridge_Entity_CustomerAddress |
|
|
|
|
15
|
|
|
extends IntegerNet_Anonymizer_Test_Model_Bridge_Entity_Abstract |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @param $customerAddressId |
19
|
|
|
* @test |
20
|
|
|
* @dataProvider dataProvider |
21
|
|
|
* @dataProviderFile testCustomerAddressBridge.yaml |
22
|
|
|
* @loadExpectation bridge.yaml |
23
|
|
|
* @loadFixture customers.yaml |
24
|
|
|
*/ |
25
|
|
|
public function testGetValues($customerAddressId) |
26
|
|
|
{ |
27
|
|
|
/** @var IntegerNet_Anonymizer_Model_Bridge_Entity_CustomerAddress $bridge */ |
28
|
|
|
$bridge = Mage::getModel('integernet_anonymizer/bridge_entity_address_customerAddress'); |
29
|
|
|
/** @var Mage_Customer_Model_Address $customerAddress */ |
30
|
|
|
$customerAddress = $this->_loadEntityByCollection('entity_id', $customerAddressId, $bridge); |
31
|
|
|
$expected = $this->expected('customer_address_%d', $customerAddressId); |
32
|
|
|
|
33
|
|
|
$this->_testGetValues($bridge, $customerAddress, $expected); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param $customerAddressId |
38
|
|
|
* @test |
39
|
|
|
* @dataProvider dataProvider |
40
|
|
|
* @dataProviderFile testCustomerAddressBridge.yaml |
41
|
|
|
* @loadFixture customers.yaml |
42
|
|
|
*/ |
43
|
|
|
public function testUpdateValues($customerAddressId) |
44
|
|
|
{ |
45
|
|
|
static $changedMiddlename = 'trouble', |
46
|
|
|
$changedStreet = "New Street\nSecond Line"; |
47
|
|
|
|
48
|
|
|
/** @var IntegerNet_Anonymizer_Model_Bridge_Entity_Address_CustomerAddress $bridge */ |
49
|
|
|
$bridge = Mage::getModel('integernet_anonymizer/bridge_entity_address_customerAddress'); |
50
|
|
|
|
51
|
|
|
/** @var Mage_Customer_Model_Address $customerAddress */ |
52
|
|
|
$dataProvider = Mage::getModel('customer/address')->load($customerAddressId); |
53
|
|
|
$bridge->setRawData($dataProvider->load($customerAddressId)->getData()); |
54
|
|
|
$bridge->getValues()['middlename']->setValue($changedMiddlename); |
55
|
|
|
$bridge->getValues()['street']->setValue($changedStreet); |
56
|
|
|
|
57
|
|
|
$this->_updateValues($bridge); |
58
|
|
|
|
59
|
|
|
$customerAddress = Mage::getModel('customer/address')->load($customerAddressId); |
60
|
|
|
$this->assertEquals($changedMiddlename, $customerAddress->getMiddlename()); |
61
|
|
|
$this->assertEquals($changedStreet, $customerAddress->getStreetFull()); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.