You are here

public function AddToCartMultilingualTest::testProductVariationTitleWidgetFromUrl in Commerce Core 8.2

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

File

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

Class

AddToCartMultilingualTest
Tests the add to cart form for multilingual.

Namespace

Drupal\Tests\commerce_cart\FunctionalJavascript

Code

public function testProductVariationTitleWidgetFromUrl() {
  $order_item_form_display = EntityFormDisplay::load('commerce_order_item.default.add_to_cart');
  $order_item_form_display
    ->setComponent('purchased_entity', [
    'type' => 'commerce_product_variation_title',
  ]);
  $order_item_form_display
    ->save();
  $variation = $this->variations[5];
  $this
    ->drupalGet($variation
    ->toUrl());
  $this
    ->assertSession()
    ->selectExists('purchased_entity[0][variation]');
  $this
    ->assertAttributeSelected('purchased_entity[0][variation]', 'My Super Product - Blue, Medium');

  // Change the site language.
  $this
    ->config('system.site')
    ->set('default_langcode', 'fr')
    ->save();
  $this
    ->rebuildContainer();
  $variation = $variation
    ->getTranslation('fr');
  $this
    ->drupalGet($variation
    ->toUrl());
  $this
    ->assertSession()
    ->selectExists('purchased_entity[0][variation]');
  $this
    ->assertAttributeSelected('purchased_entity[0][variation]', 'Mon super produit - FR Blue, FR Medium');
}