public function EventTrackerServicePurchaseTest::testPurchaseOrderWithTaxExclusiveOnOrder in Commerce Google Tag Manager 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/EventTrackerServicePurchaseTest.php \Drupal\Tests\commerce_google_tag_manager\Kernel\EventTrackerServicePurchaseTest::testPurchaseOrderWithTaxExclusiveOnOrder()
@covers ::purchase
File
- tests/
src/ Kernel/ EventTrackerServicePurchaseTest.php, line 294
Class
- EventTrackerServicePurchaseTest
- @coversDefaultClass \Drupal\commerce_google_tag_manager\EventTrackerService
Namespace
Drupal\Tests\commerce_google_tag_manager\KernelCode
public function testPurchaseOrderWithTaxExclusiveOnOrder() {
$this->store
->set('prices_include_tax', FALSE);
$this->store
->save();
$order = Order::create([
'type' => 'default',
'state' => 'draft',
'mail' => $this->user
->getEmail(),
'uid' => $this->user
->id(),
'ip_address' => '127.0.0.1',
'order_number' => '6',
'billing_profile' => $this->profile,
'store_id' => $this->store
->id(),
'order_items' => [
$this->orderItem,
],
]);
$order
->save();
$this
->assertEquals(new Price('13.2', 'USD'), $order
->getTotalPrice());
$this
->assertEquals(new Price('13.2', 'USD'), $order
->getSubtotalPrice());
$order
->recalculateTotalPrice();
$this
->assertEquals(new Price('13.2', 'USD'), $order
->getTotalPrice());
$this
->assertEquals(new Price('13.2', 'USD'), $order
->getSubtotalPrice());
$this
->invokeMethod($this->eventTracker, 'purchase', [
$order,
]);
$data = $this->tempStore
->get('events');
$this
->assertSame([
'32c4a9a074bd51142074d965d89398a4' => [
'event' => 'purchase',
'ecommerce' => [
'purchase' => [
'actionField' => [
'id' => '6',
'affiliation' => 'Default store',
'revenue' => '13.20',
'shipping' => '0',
'tax' => '2.20',
'coupon' => '',
],
'products' => [
0 => [
'name' => 'Lorem Ipsum',
'id' => '1',
'price' => '11.00',
'variant' => 'Lorem Ipsum',
'quantity' => 1,
],
],
],
],
],
], $data);
}