You are here

public function AddToCartMultilingualTest::testProductVariationAttributesWidgetFromUrl in Commerce Core 8.2

Tests the attribute widget default values with a variation url (?v=).

File

modules/cart/tests/src/FunctionalJavascript/AddToCartMultilingualTest.php, line 208

Class

AddToCartMultilingualTest
Tests the add to cart form for multilingual.

Namespace

Drupal\Tests\commerce_cart\FunctionalJavascript

Code

public function testProductVariationAttributesWidgetFromUrl() {
  $variation = $this->variations[5];
  $this
    ->drupalGet($variation
    ->toUrl());
  $this
    ->assertAttributeSelected('purchased_entity[0][attributes][attribute_color]', 'Blue');
  $this
    ->assertAttributeSelected('purchased_entity[0][attributes][attribute_size]', 'Medium');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Add to cart');

  // Change the site language.
  $this
    ->config('system.site')
    ->set('default_langcode', 'fr')
    ->save();
  $this
    ->rebuildContainer();
  $variation = $variation
    ->getTranslation('fr');
  $this
    ->drupalGet($variation
    ->toUrl());
  $this
    ->assertAttributeSelected('purchased_entity[0][attributes][attribute_color]', 'FR Blue');
  $this
    ->assertAttributeSelected('purchased_entity[0][attributes][attribute_size]', 'FR Medium');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Add to cart');
}