function NumberFieldRdfaTest::testFloatFormatterWithSettings

Same name and namespace in other branches
  1. 8.9.x core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php \Drupal\Tests\rdf\Kernel\Field\NumberFieldRdfaTest::testFloatFormatterWithSettings()

Tests the float formatter with settings.

File

core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php, line 76

Class

NumberFieldRdfaTest
Tests RDFa output by number field formatters.

Namespace

Drupal\Tests\rdf\Kernel\Field

Code

public function testFloatFormatterWithSettings() {
  \Drupal::service('theme_installer')->install([
    'starterkit_theme',
  ]);
  $this->config('system.theme')
    ->set('default', 'starterkit_theme')
    ->save();
  $this->fieldType = 'float';
  $formatter = [
    'type' => 'number_decimal',
    'settings' => [
      'thousand_separator' => '.',
      'decimal_separator' => ',',
      'prefix_suffix' => TRUE,
    ],
  ];
  $testValue = 3333333.33;
  $field_settings = [
    'prefix' => '$',
    'suffix' => ' more.',
  ];
  $this->createTestField($field_settings);
  $this->createTestEntity($testValue);
  $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', [
    'value' => $testValue,
  ]);
  // Test that the content attribute is created.
  $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', [
    ':testValue' => $testValue,
  ]);
  $this->assertNotEmpty($result);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.