You are here

public function EventTrackerServiceTest::testBuildProductFromProductVariation in Commerce Google Tag Manager 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/EventTrackerServiceTest.php \Drupal\Tests\commerce_google_tag_manager\Kernel\EventTrackerServiceTest::testBuildProductFromProductVariation()

@covers ::buildProductFromProductVariation

File

tests/src/Kernel/EventTrackerServiceTest.php, line 65

Class

EventTrackerServiceTest
@coversDefaultClass \Drupal\commerce_google_tag_manager\EventTrackerService

Namespace

Drupal\Tests\commerce_google_tag_manager\Kernel

Code

public function testBuildProductFromProductVariation() {

  // 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();
  $result = $this
    ->invokeMethod($this->eventTracker, 'buildProductFromProductVariation', [
    $variation,
  ]);
  $this
    ->assertInstanceOf(Product::class, $result);
  $this
    ->assertEquals($result
    ->getPrice(), 11);
}