You are here

public function ProductVariationFieldRendererTest::testNoVariations in Commerce Core 8.2

Tests that viewing a product without variations does not throw fatal error.

See also

commerce_product_commerce_product_view()

File

modules/product/tests/src/Kernel/ProductVariationFieldRendererTest.php, line 346

Class

ProductVariationFieldRendererTest
Tests the product variation field renderer.

Namespace

Drupal\Tests\commerce_product\Kernel

Code

public function testNoVariations() {
  $product = Product::create([
    'type' => 'default',
    'variations' => [],
  ]);
  $product
    ->save();

  // The test will fail if we get a fatal error.
  $product_view_builder = $this->container
    ->get('entity_type.manager')
    ->getViewBuilder('commerce_product');
  $product_build = $product_view_builder
    ->view($product);
  $this
    ->render($product_build);
}