You are here

public function ProductLayoutBuilderIntegrationTest::testFieldInjectionDisabled in Commerce Core 8.2

Tests that enabling Layout Builder for a display disables field injection.

File

modules/product/tests/src/FunctionalJavascript/ProductLayoutBuilderIntegrationTest.php, line 46

Class

ProductLayoutBuilderIntegrationTest
@group commerce

Namespace

Drupal\Tests\commerce_product\FunctionalJavascript

Code

public function testFieldInjectionDisabled() {
  $variation_view_display = commerce_get_entity_display('commerce_product_variation', 'default', 'view');
  $variation_view_display
    ->setComponent('sku', [
    'label' => 'hidden',
    'type' => 'string',
  ]);
  $variation_view_display
    ->save();
  $product = $this
    ->createEntity('commerce_product', [
    'type' => 'default',
    'title' => $this
      ->randomMachineName(),
    'stores' => $this->stores,
    'body' => [
      'value' => 'Testing product variation field injection!',
    ],
    'variations' => [
      $this
        ->createEntity('commerce_product_variation', [
        'type' => 'default',
        'sku' => 'INJECTION-DEFAULT',
        'price' => [
          'number' => '9.99',
          'currency_code' => 'USD',
        ],
      ]),
    ],
  ]);
  $this
    ->drupalGet($product
    ->toUrl());
  $this
    ->assertSession()
    ->pageTextContains('$9.99');
  $this
    ->assertSession()
    ->pageTextContains('INJECTION-DEFAULT');
  $this
    ->enableLayoutsForBundle('default');
  $this
    ->drupalGet($product
    ->toUrl());
  $this
    ->assertSession()
    ->pageTextNotContains('$9.99');
  $this
    ->assertSession()
    ->pageTextNotContains('INJECTION-DEFAULT');
}