You are here

public function NumberFieldRdfaTest::testIntegerFormatterWithSettings in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php \Drupal\Tests\rdf\Kernel\Field\NumberFieldRdfaTest::testIntegerFormatterWithSettings()
  2. 9 core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php \Drupal\Tests\rdf\Kernel\Field\NumberFieldRdfaTest::testIntegerFormatterWithSettings()

Tests the integer formatter with settings.

File

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

Class

NumberFieldRdfaTest
Tests RDFa output by number field formatters.

Namespace

Drupal\Tests\rdf\Kernel\Field

Code

public function testIntegerFormatterWithSettings() {
  \Drupal::service('theme_installer')
    ->install([
    'classy',
  ]);
  $this
    ->config('system.theme')
    ->set('default', 'classy')
    ->save();
  $this->fieldType = 'integer';
  $formatter = [
    'type' => 'number_integer',
    'settings' => [
      'thousand_separator' => '.',
      'prefix_suffix' => TRUE,
    ],
  ];
  $testValue = 3333333.33;
  $field_settings = [
    'prefix' => '#',
    'suffix' => ' llamas.',
  ];
  $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);
}