protected function EventTrackerServicePurchaseTest::setUp 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::setUp()
Overrides CommerceKernelTestBase::setUp
File
- tests/
src/ Kernel/ EventTrackerServicePurchaseTest.php, line 95
Class
- EventTrackerServicePurchaseTest
- @coversDefaultClass \Drupal\commerce_google_tag_manager\EventTrackerService
Namespace
Drupal\Tests\commerce_google_tag_manager\KernelCode
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('profile');
$this
->installSchema('system', [
'key_value_expire',
]);
$this
->installConfig([
'commerce_tax',
]);
$this->eventTracker = $this->container
->get('commerce_google_tag_manager.event_tracker');
$this->tempStore = $this->container
->get('tempstore.private')
->get('commerce_google_tag_manager');
$this->user = $this
->createUser([
'mail' => $this
->randomString() . '@example.com',
]);
$this->profile = Profile::create([
'type' => 'customer',
'address' => [
'country_code' => 'US',
'administrative_area' => 'SC',
],
]);
$this->profile
->save();
// The default store is US-WI, so imagine that the US has VAT.
$this->taxType = TaxType::create([
'id' => 'us_vat',
'label' => 'US VAT',
'plugin' => 'custom',
'configuration' => [
'display_inclusive' => TRUE,
'rates' => [
[
'id' => 'standard',
'label' => 'Standard',
'percentage' => '0.2',
],
],
'territories' => [
[
'country_code' => 'US',
'administrative_area' => 'WI',
],
[
'country_code' => 'US',
'administrative_area' => 'SC',
],
],
],
]);
$this->taxType
->save();
$this->product = CommerceProduct::create([
'type' => 'default',
'title' => 'Lorem Ipsum',
]);
$this->product
->save();
// The variations to test with.
$variation = ProductVariation::create([
'type' => 'default',
'sku' => $this
->randomString(10),
'status' => TRUE,
'price' => new Price('11.00', 'USD'),
]);
$variation
->save();
$this->product
->addVariation($variation)
->save();
/** @var \Drupal\commerce_order\OrderItemStorageInterface $order_item_storage */
$order_item_storage = $this->container
->get('entity_type.manager')
->getStorage('commerce_order_item');
$this->orderItem = $order_item_storage
->createFromPurchasableEntity($variation);
$this->orderItem
->save();
$this->orderItemAlt = $order_item_storage
->createFromPurchasableEntity($variation);
$this->orderItemAlt
->save();
}