You are here

public function ProductLayoutBuilderIntegrationTest::testConfiguringOverrideLayout in Commerce Core 8.2

Tests configuring a layout override for a product.

File

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

Class

ProductLayoutBuilderIntegrationTest
@group commerce

Namespace

Drupal\Tests\commerce_product\FunctionalJavascript

Code

public function testConfiguringOverrideLayout() {
  $this
    ->enableLayoutsForBundle('default', TRUE);
  $this
    ->configureDefaultLayout('default');
  $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()
    ->pageTextNotContains('INJECTION-DEFAULT');
  $this
    ->clickLink('Layout');
  $this
    ->assertSession()
    ->pageTextContains('You are editing the layout for this Default product.');
  $this
    ->addBlockToLayout('SKU');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Save layout');
  $this
    ->assertSession()
    ->pageTextContains('The layout override has been saved.');
  $this
    ->drupalGet($product
    ->toUrl());
  $this
    ->assertSession()
    ->pageTextContains('INJECTION-DEFAULT');
}