Skip to content

Commit f24a329

Browse files
committed
ACP2E-1880: adapt for decimal quantity and allow several decimals on price
1 parent 382ab5b commit f24a329

File tree

1 file changed

+18
-6
lines changed
  • app/code/Magento/GoogleAnalytics/Test/Unit/Block

1 file changed

+18
-6
lines changed

app/code/Magento/GoogleAnalytics/Test/Unit/Block/GaTest.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,18 @@ public function testOrderTrackingCode()
118118
'price': 0.00,
119119
'quantity': 1
120120
});
121+
ga('ec:addProduct', {
122+
'id': 'sku1',
123+
'name': 'testName1',
124+
'price': 1.00,
125+
'quantity': 1.11
126+
});
121127
ga('ec:setAction', 'purchase', {
122128
'id': '100',
123129
'affiliation': 'test',
124130
'revenue': 10.00,
125131
'tax': 2.00,
126-
'shipping': 1.00
132+
'shipping': 2.00
127133
});
128134
ga('send', 'pageview');";
129135

@@ -165,7 +171,7 @@ public function testOrderTrackingData()
165171
'affiliation' => 'test',
166172
'revenue' => 10.00,
167173
'tax' => 2.00,
168-
'shipping' => 1
174+
'shipping' => 2.0
169175
]
170176
],
171177
'products' => [
@@ -174,6 +180,12 @@ public function testOrderTrackingData()
174180
'name' => 'testName0',
175181
'price' => 0.00,
176182
'quantity' => 1
183+
],
184+
[
185+
'id' => 'sku1',
186+
'name' => 'testName1',
187+
'price' => 1.00,
188+
'quantity' => 1.11
177189
]
178190
],
179191
'currency' => 'USD'
@@ -204,7 +216,7 @@ public function testGetPageTrackingData()
204216
* @param int $orderItemCount
205217
* @return Order|MockObject
206218
*/
207-
protected function createOrderMock($orderItemCount = 1)
219+
protected function createOrderMock($orderItemCount = 2)
208220
{
209221
$orderItems = [];
210222
for ($i = 0; $i < $orderItemCount; $i++) {
@@ -213,8 +225,8 @@ protected function createOrderMock($orderItemCount = 1)
213225
->getMockForAbstractClass();
214226
$orderItemMock->expects($this->once())->method('getSku')->willReturn('sku' . $i);
215227
$orderItemMock->expects($this->once())->method('getName')->willReturn('testName' . $i);
216-
$orderItemMock->expects($this->once())->method('getPrice')->willReturn(round((float)($i . '.0000'), 2));
217-
$orderItemMock->expects($this->once())->method('getQtyOrdered')->willReturn($i + 1);
228+
$orderItemMock->expects($this->once())->method('getPrice')->willReturn((float)($i . '.0000'));
229+
$orderItemMock->expects($this->once())->method('getQtyOrdered')->willReturn($i == 1 ? 1.11 : $i + 1);
218230
$orderItems[] = $orderItemMock;
219231
}
220232

@@ -241,7 +253,7 @@ protected function createCollectionMock()
241253

242254
$collectionMock->expects($this->any())
243255
->method('getIterator')
244-
->willReturn(new \ArrayIterator([$this->createOrderMock(1)]));
256+
->willReturn(new \ArrayIterator([$this->createOrderMock(2)]));
245257
return $collectionMock;
246258
}
247259

0 commit comments

Comments
 (0)