You are here

public function MeasurementElementTest::testLocalFormat in Physical Fields 8

Tests the element with a non-English number format.

File

tests/src/Functional/MeasurementElementTest.php, line 87

Class

MeasurementElementTest
Tests the physical_measurement form element.

Namespace

Drupal\Tests\physical\Functional

Code

public function testLocalFormat() {

  // French uses a comma as a decimal separator.
  ConfigurableLanguage::createFromLangcode('fr')
    ->save();
  $this
    ->config('system.site')
    ->set('default_langcode', 'fr')
    ->save();
  $this
    ->drupalGet('/physical/measurement_test_form');
  $this
    ->assertSession()
    ->fieldExists('height[number]');

  // Default value.
  $this
    ->assertSession()
    ->fieldValueEquals('height[number]', '1,92');

  // Valid submit.
  $edit = [
    'height[number]' => '10,99',
  ];
  $this
    ->submitForm($edit, 'Submit');
  $this
    ->assertSession()
    ->pageTextContains('The number is "10.99" and the unit is "m".');
}