Skip to content

Commit 7fa5420

Browse files
committed
Fix missing increment id
1 parent e61a28d commit 7fa5420

8 files changed

Lines changed: 56 additions & 16 deletions

File tree

phpunit.xml.dist

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
processIsolation="false"
9+
stopOnFailure="false"
10+
syntaxCheck="false"
11+
bootstrap="test/bootstrap.php"
12+
>
13+
<testsuites>
14+
<testsuite name="Unit">
15+
<directory>./test/</directory>
16+
</testsuite>
17+
</testsuites>
18+
19+
<filter>
20+
<whitelist>
21+
<directory>./src/</directory>
22+
<exclude>
23+
</exclude>
24+
</whitelist>
25+
</filter>
26+
</phpunit>

src/app/code/community/IntegerNet/Anonymizer/Model/Bridge/Entity/Abstract.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class IntegerNet_Anonymizer_Model_Bridge_Entity_Abstract
3030
*/
3131
protected $_formattersByAttribute = array();
3232
/**
33-
* @var string[]
33+
* @var string[] Specifies attributes that will be loaded
3434
*/
3535
protected $_attributesUsedForIdentifier = array();
3636
/**
@@ -153,8 +153,10 @@ public function getCollectionIterator()
153153
{
154154
/** @var Varien_Data_Collection_Db $collection */
155155
$collection = $this->_entity->getCollection();
156-
//TODO add columns used by identifier to select
157-
$fields = array_unique(array_merge(array_keys($this->_formattersByAttribute), $this->_attributesUsedForIdentifier));
156+
$fields = array_unique(array_merge(
157+
array_keys($this->_formattersByAttribute),
158+
$this->_attributesUsedForIdentifier
159+
));
158160
if ($collection instanceof Mage_Eav_Model_Entity_Collection_Abstract) {
159161
$collection->addAttributeToSelect($fields, 'left');
160162
} elseif ($collection instanceof Mage_Core_Model_Resource_Db_Collection_Abstract) {

src/app/code/community/IntegerNet/Anonymizer/Model/Bridge/Entity/Order.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class IntegerNet_Anonymizer_Model_Bridge_Entity_Order extends IntegerNet_Anonymi
1212
protected $_entityType = 'order';
1313

1414
protected $_attributesUsedForIdentifier = array(
15-
'customer_id'
15+
'customer_id', 'increment_id'
1616
);
1717

1818
protected $_formattersByAttribute = array(

src/app/code/community/IntegerNet/Anonymizer/Test/Model/Anonymizer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ protected function _testAnonymizeAll()
5353
$orderGridData = $orderGridCollection->addFieldToFilter('entity_id', 1)->getFirstItem();
5454
$this->assertEquals('Testname Testname', $orderGridData->getShippingName());
5555
$this->assertEquals('Testname Testname', $orderGridData->getBillingName());
56+
$this->assertEquals('1000000001', $orderGridData->getIncrementId(), 'Precondition: Increment ID in grid');
5657

5758
// RUN ANONYMIZER
5859

@@ -103,6 +104,7 @@ protected function _testAnonymizeAll()
103104

104105
/** @var Mage_Sales_Model_Order $order */
105106
$order = Mage::getModel('sales/order')->load(1);
107+
$this->assertEquals('1000000001', $order->getIncrementId(), 'Increment ID should be unchanged');
106108
$this->assertNotEquals('test2@test.de', $order->getCustomerEmail());
107109
$this->assertNotEquals('Testname', $order->getCustomerFirstname());
108110
$this->assertNotEquals('J', $order->getCustomerMiddlename());
@@ -137,6 +139,7 @@ protected function _testAnonymizeAll()
137139
$this->assertNotEquals('Testname Testname', $orderGridData->getShippingName());
138140
$this->assertNotEquals('Testname Testname', $orderGridData->getBillingName());
139141
$this->assertEquals($orderAddress->getName(), $orderGridData->getBillingName());
142+
$this->assertEquals('1000000001', $orderGridData->getIncrementId(), 'Increment ID in grid should be unchanged');
140143

141144
$subscriber = Mage::getModel('newsletter/subscriber')->load(1);
142145
$this->assertNotEquals('guest1@example.com', $subscriber->getSubscriberEmail());

src/app/code/community/IntegerNet/Anonymizer/Test/Model/Bridge/Entity/Order.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,35 @@ public function testGetValues($orderId)
3434
}
3535

3636
/**
37+
* @param $orderId
3738
* @param $customerId
3839
* @test
3940
* @dataProvider dataProvider
40-
* @dataProviderFile testCustomerBridge.yaml
41+
* @dataProviderFile testOrderBridge.yaml
4142
* @loadFixture customers.yaml
4243
*/
43-
public function testUpdateValues($customerId)
44+
public function testUpdateValues($orderId, $customerId)
4445
{
4546
static $changedEmail = 'changed@example.com',
4647
$changedMiddlename = 'trouble';
4748

48-
/** @var IntegerNet_Anonymizer_Model_Bridge_Entity_Customer $bridge */
49-
$bridge = Mage::getModel('integernet_anonymizer/bridge_entity_customer');
49+
/** @var IntegerNet_Anonymizer_Model_Bridge_Entity_Order $bridge */
50+
$bridge = Mage::getModel('integernet_anonymizer/bridge_entity_order');
5051

5152
$bridge->setRawData(array(
52-
'entity_id' => $customerId,
53-
'email' => $changedEmail,
54-
'middlename' => $changedMiddlename
53+
'entity_id' => $orderId,
54+
'increment_id' => '1000000001',
55+
'customer_id' => $customerId,
56+
'customer_email' => $changedEmail,
57+
'customer_middlename' => $changedMiddlename
5558
));
5659

5760
$this->_updateValues($bridge);
5861

59-
$customer = Mage::getModel('customer/customer')->load($customerId);
60-
$this->assertEquals($changedMiddlename, $customer->getMiddlename());
61-
$this->assertEquals($changedEmail, $customer->getEmail());
62+
$order = Mage::getModel('sales/order')->load($orderId);
63+
$this->assertEquals($changedMiddlename, $order->getCustomerMiddlename());
64+
$this->assertEquals($changedEmail, $order->getCustomerEmail());
65+
$this->assertNotEmpty($order->getIncrementId(), 'Increment ID should not be empty');
6266
}
6367

6468
}

src/app/code/community/IntegerNet/Anonymizer/Test/Model/Bridge/Entity/expectations/bridge.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ giftregistry_1:
133133
- formatter: address
134134
value: Something something somewhere
135135
- formatter: 'null'
136-
value: 'a:1:{s:3:"foo";s:3:"bar";}'
136+
value:
137+
foo: 'bar'
137138
giftregistry_person_1:
138139
identifier: 'b.schenkter@example.com'
139140
values:
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
order_1:
2-
id: 1
2+
id: 1
3+
customer_id: 1

src/app/code/community/IntegerNet/Anonymizer/Test/fixtures/customers.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ tables:
111111
customer_id: null
112112
sales/order:
113113
- entity_id: 1
114+
increment_id: 1000000001
114115
quote_id: 1
115116
billing_address_id: 1
116117
customer_id: 2
@@ -122,13 +123,15 @@ tables:
122123
customer_suffix: III
123124
customer_taxvat: DE 987654321
124125
- entity_id: 2
126+
increment_id: 1000000002
125127
quote_id: 2
126128
billing_address_id: 2
127129
customer_email: guest@guest.de
128130
customer_firstname: Gast
129131
customer_lastname: Gast
130132
sales/order_grid:
131133
- entity_id: 1
134+
increment_id: 1000000001
132135
customer_id: 2
133136
shipping_name: Testname Testname
134137
billing_name: Testname Testname

0 commit comments

Comments
 (0)