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_GiftregistryPerson |
|
|
|
|
15
|
|
|
extends IntegerNet_Anonymizer_Test_Model_Bridge_Entity_Abstract |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @test |
19
|
|
|
*/ |
20
|
|
|
public function isEnterprise() |
21
|
|
|
{ |
22
|
|
|
if (Mage::getEdition() !== Mage::EDITION_ENTERPRISE) { |
23
|
|
|
$this->markTestSkipped('Skipping test for Magento Enterprise'); |
24
|
|
|
} |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param $personId |
29
|
|
|
* @test |
30
|
|
|
* @depends isEnterprise |
31
|
|
|
* @dataProvider dataProvider |
32
|
|
|
* @dataProviderFile testGiftregistryPersonBridge.yaml |
33
|
|
|
* @loadExpectation bridge.yaml |
34
|
|
|
* @loadFixture customers.yaml |
35
|
|
|
* @loadFixture enterprise.yaml |
36
|
|
|
*/ |
37
|
|
|
public function testGetValues($personId) |
38
|
|
|
{ |
39
|
|
|
/** @var IntegerNet_Anonymizer_Model_Bridge_Entity_Enterprise_GiftregistryPerson $bridge */ |
40
|
|
|
$bridge = Mage::getModel('integernet_anonymizer/bridge_entity_enterprise_giftregistryPerson'); |
41
|
|
|
/** @var Enterprise_GiftRegistry_Model_Person $person */ |
42
|
|
|
$person = $this->_loadEntityByCollection('person_id', $personId, $bridge); |
43
|
|
|
$expected = $this->expected('giftregistry_person_%d', $personId); |
44
|
|
|
|
45
|
|
|
$this->_testGetValues($bridge, $person, $expected); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param $registryId |
50
|
|
|
* @test |
51
|
|
|
* @depends isEnterprise |
52
|
|
|
* @dataProvider dataProvider |
53
|
|
|
* @dataProviderFile testGiftregistryPersonBridge.yaml |
54
|
|
|
* @loadFixture customers.yaml |
55
|
|
|
* @loadFixture enterprise.yaml |
56
|
|
|
*/ |
57
|
|
|
public function testUpdateValues($registryId) |
58
|
|
|
{ |
59
|
|
|
static $changedEmail = '[email protected]'; |
60
|
|
|
|
61
|
|
|
/** @var IntegerNet_Anonymizer_Model_Bridge_Entity_Enterprise_GiftregistryPerson $bridge */ |
62
|
|
|
$bridge = Mage::getModel('integernet_anonymizer/bridge_entity_enterprise_giftregistryPerson'); |
63
|
|
|
|
64
|
|
|
$dataProvider = Mage::getModel('enterprise_giftregistry/person');; |
65
|
|
|
$bridge->setRawData($dataProvider->load($registryId)->setId($registryId)->getData()); |
66
|
|
|
$bridge->getValues()['email']->setValue($changedEmail); |
67
|
|
|
|
68
|
|
|
$this->_updateValues($bridge); |
69
|
|
|
|
70
|
|
|
$person = Mage::getModel('enterprise_giftregistry/person')->load($registryId); |
71
|
|
|
$this->assertEquals($changedEmail, $person->getEmail()); |
72
|
|
|
} |
73
|
|
|
} |
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.