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
|
|
|
class IntegerNet_Anonymizer_Test_Model_Anonymizer extends EcomDev_PHPUnit_Test_Case |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @test |
15
|
|
|
* @loadFixture customers.yaml |
16
|
|
|
*/ |
17
|
|
|
public function testAnonymizeAllCommunity() |
18
|
|
|
{ |
19
|
|
|
$this->_testAnonymizeAll(); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @test |
24
|
|
|
*/ |
25
|
|
|
public function isEnterprise() |
26
|
|
|
{ |
27
|
|
|
if (Mage::getEdition() !== Mage::EDITION_ENTERPRISE) { |
28
|
|
|
$this->markTestSkipped('Skipping test for Magento Enterprise'); |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
/** |
32
|
|
|
* @test |
33
|
|
|
* @depends isEnterprise |
34
|
|
|
* @loadFixture customers.yaml |
35
|
|
|
* @loadFixture enterprise.yaml |
36
|
|
|
*/ |
37
|
|
|
public function testAnonymizeAllEnterprise() |
38
|
|
|
{ |
39
|
|
|
$this->_testAnonymizeAll(); |
40
|
|
|
//TODO EE assertions |
41
|
|
|
$this->markTestIncomplete(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* |
46
|
|
|
*/ |
47
|
|
|
protected function _testAnonymizeAll() |
48
|
|
|
{ |
49
|
|
|
// TEST PRE CONDITIONS |
50
|
|
|
|
51
|
|
|
/** @var Mage_Sales_Model_Resource_Order_Grid_Collection $orderGridCollection */ |
52
|
|
|
$orderGridCollection = Mage::getResourceModel('sales/order_grid_collection'); |
53
|
|
|
$orderGridData = $orderGridCollection->addFieldToFilter('entity_id', 1)->getFirstItem(); |
54
|
|
|
$this->assertEquals('Testname Testname', $orderGridData->getShippingName()); |
55
|
|
|
$this->assertEquals('Testname Testname', $orderGridData->getBillingName()); |
56
|
|
|
$this->assertEquals('1000000001', $orderGridData->getIncrementId(), 'Precondition: Increment ID in grid'); |
57
|
|
|
|
58
|
|
|
// RUN ANONYMIZER |
59
|
|
|
|
60
|
|
|
/** @var IntegerNet_Anonymizer_Model_Anonymizer $anonymizer */ |
61
|
|
|
$anonymizer = Mage::getModel('integernet_anonymizer/anonymizer'); |
62
|
|
|
$anonymizer->anonymizeAll(); |
63
|
|
|
|
64
|
|
|
// TEST POST CONDITIONS |
65
|
|
|
|
66
|
|
|
$customer = Mage::getModel('customer/customer')->load(2); |
67
|
|
|
$this->assertNotEquals('[email protected]', $customer->getData('email')); |
68
|
|
|
$this->assertNotEquals('Testname', $customer->getData('firstname')); |
69
|
|
|
$this->assertNotEquals('Testname', $customer->getData('lastname')); |
70
|
|
|
|
71
|
|
|
$customerAddress = $customer->getDefaultBillingAddress(); |
72
|
|
|
$this->assertNotEquals('Testname', $customerAddress->getData('firstname')); |
73
|
|
|
$this->assertNotEquals('Testname', $customerAddress->getData('lastname')); |
74
|
|
|
$this->assertNotEquals('ACME GmbH', $customerAddress->getData('company')); |
75
|
|
|
$this->assertNotEquals('Buxtehude', $customerAddress->getData('city')); |
76
|
|
|
$this->assertNotEquals('Am Arm 1', $customerAddress->getData('street')); |
77
|
|
|
$this->assertNotEquals('555-12345', $customerAddress->getData('telephone')); |
78
|
|
|
$this->assertNotEquals('555-12345', $customerAddress->getData('fax')); |
79
|
|
|
$this->assertNotEquals('DE 987654321', $customerAddress->getData('vat_id')); |
80
|
|
|
$this->assertEquals('67890', $customerAddress->getData('postcode')); |
81
|
|
|
$this->assertEquals('DE', $customerAddress->getCountryId()); |
82
|
|
|
|
83
|
|
|
$quote = Mage::getModel('sales/quote')->load(1); |
84
|
|
|
$quoteAddress = $quote->getBillingAddress(); |
85
|
|
|
$this->assertEquals($customerAddress->getCustomerId(), $quoteAddress->getCustomerId(), |
86
|
|
|
'Quote address and customer address refer to the same customer'); |
87
|
|
|
$this->assertNotEquals($customerAddress->getData('lastname'), $quoteAddress->getData('lastname'), |
88
|
|
|
'Different values stay different'); |
89
|
|
|
$this->assertNotEquals($customerAddress->getData('lastname'), $quoteAddress->getData('lastname'), |
90
|
|
|
'Different values stay different'); |
91
|
|
|
$this->assertEquals($customerAddress->getData('company'), $quoteAddress->getData('company'), |
92
|
|
|
'Same values stay the same'); |
93
|
|
|
|
94
|
|
|
$this->assertNotEquals('Somebody', $quoteAddress->getData('firstname')); |
95
|
|
|
$this->assertNotEquals('Else', $quoteAddress->getData('lastname')); |
96
|
|
|
$this->assertNotEquals('ACME GmbH', $quoteAddress->getData('company')); |
97
|
|
|
$this->assertNotEquals('Buxtehude', $quoteAddress->getData('city')); |
98
|
|
|
$this->assertNotEquals('Am Arm 1', $quoteAddress->getData('street')); |
99
|
|
|
$this->assertNotEquals('555-12345', $quoteAddress->getData('telephone')); |
100
|
|
|
$this->assertNotEquals('555-12345', $quoteAddress->getData('fax')); |
101
|
|
|
$this->assertNotEquals('DE 987654321', $quoteAddress->getData('vat_id')); |
102
|
|
|
$this->assertEquals('67890', $quoteAddress->getData('postcode')); |
103
|
|
|
$this->assertEquals('DE', $quoteAddress->getCountryId()); |
104
|
|
|
|
105
|
|
|
/** @var Mage_Sales_Model_Order $order */ |
106
|
|
|
$order = Mage::getModel('sales/order')->load(1); |
107
|
|
|
$this->assertEquals('1000000001', $order->getIncrementId(), 'Increment ID should be unchanged'); |
108
|
|
|
$this->assertNotEquals('[email protected]', $order->getCustomerEmail()); |
109
|
|
|
$this->assertNotEquals('Testname', $order->getCustomerFirstname()); |
110
|
|
|
$this->assertNotEquals('J', $order->getCustomerMiddlename()); |
111
|
|
|
$this->assertNotEquals('Testname', $order->getCustomerLastname()); |
112
|
|
|
$this->assertNotEquals('Kaiser', $order->getCustomerPrefix()); |
113
|
|
|
$this->assertNotEquals('der Große', $order->getCustomerSuffix()); |
114
|
|
|
|
115
|
|
|
$orderAddress = $order->getBillingAddress(); |
116
|
|
|
$this->assertEquals($quoteAddress->getCustomerId(), $orderAddress->getCustomerId(), |
117
|
|
|
'Quote address and customer address refer to the same customer'); |
118
|
|
|
$this->assertNotEquals($quoteAddress->getData('lastname'), $orderAddress->getData('lastname'), |
119
|
|
|
'Different values stay different'); |
120
|
|
|
$this->assertNotEquals($quoteAddress->getData('lastname'), $orderAddress->getData('lastname'), |
121
|
|
|
'Different values stay different'); |
122
|
|
|
$this->assertEquals($quoteAddress->getData('company'), $orderAddress->getData('company'), |
123
|
|
|
'Same values stay the same'); |
124
|
|
|
|
125
|
|
|
$this->assertNotEquals('Testname', $orderAddress->getData('firstname')); |
126
|
|
|
$this->assertNotEquals('Testname', $orderAddress->getData('lastname')); |
127
|
|
|
$this->assertNotEquals('ACME GmbH', $orderAddress->getData('company')); |
128
|
|
|
$this->assertNotEquals('Buxtehude', $orderAddress->getData('city')); |
129
|
|
|
$this->assertNotEquals('Am Arm 1', $orderAddress->getData('street')); |
130
|
|
|
$this->assertNotEquals('555-12345', $orderAddress->getData('telephone')); |
131
|
|
|
$this->assertNotEquals('555-12345', $orderAddress->getData('fax')); |
132
|
|
|
$this->assertNotEquals('DE 987654321', $orderAddress->getData('vat_id')); |
133
|
|
|
$this->assertEquals('67890', $orderAddress->getData('postcode')); |
134
|
|
|
$this->assertEquals('DE', $orderAddress->getCountryId()); |
135
|
|
|
|
136
|
|
|
/** @var Mage_Sales_Model_Resource_Order_Grid_Collection $orderGridCollection */ |
137
|
|
|
$orderGridCollection = Mage::getResourceModel('sales/order_grid_collection'); |
138
|
|
|
$orderGridData = $orderGridCollection->addFieldToFilter('entity_id', 1)->getFirstItem(); |
139
|
|
|
$this->assertNotEquals('Testname Testname', $orderGridData->getShippingName()); |
140
|
|
|
$this->assertNotEquals('Testname Testname', $orderGridData->getBillingName()); |
141
|
|
|
$this->assertEquals($orderAddress->getName(), $orderGridData->getBillingName()); |
142
|
|
|
$this->assertEquals('1000000001', $orderGridData->getIncrementId(), 'Increment ID in grid should be unchanged'); |
143
|
|
|
|
144
|
|
|
$subscriber = Mage::getModel('newsletter/subscriber')->load(1); |
145
|
|
|
$this->assertNotEquals('[email protected]', $subscriber->getSubscriberEmail()); |
146
|
|
|
|
147
|
|
|
|
148
|
|
|
$guestQuote = Mage::getModel('sales/quote')->load(2); |
149
|
|
|
$guestQuoteAddress = $guestQuote->getBillingAddress(); |
150
|
|
|
$otherGuestQuote = Mage::getModel('sales/quote')->load(3); |
151
|
|
|
$otherGuestQuoteAddress = $otherGuestQuote->getBillingAddress(); |
152
|
|
|
|
153
|
|
|
$this->assertNotEquals($guestQuoteAddress->getData('firstname'), $otherGuestQuoteAddress->getData('firstname')); |
154
|
|
|
$this->assertNotEquals($guestQuoteAddress->getData('lastname'), $otherGuestQuoteAddress->getData('lastname')); |
155
|
|
|
$this->assertNotEquals($guestQuoteAddress->getData('company'), $otherGuestQuoteAddress->getData('company')); |
156
|
|
|
$this->assertNotEquals($guestQuoteAddress->getData('city'), $otherGuestQuoteAddress->getData('city')); |
157
|
|
|
$this->assertNotEquals($guestQuoteAddress->getData('street'), $otherGuestQuoteAddress->getData('street')); |
158
|
|
|
$this->assertNotEquals($guestQuoteAddress->getData('telephone'), $otherGuestQuoteAddress->getData('telephone')); |
159
|
|
|
$this->assertNotEquals($guestQuoteAddress->getData('fax'), $otherGuestQuoteAddress->getData('fax')); |
160
|
|
|
$this->assertNotEquals($guestQuoteAddress->getData('vat_id'), $otherGuestQuoteAddress->getData('vat_id')); |
161
|
|
|
|
162
|
|
|
} |
163
|
|
|
} |