You are here

public function NumberFieldRdfaTest::testDecimalFormatterWithSettings in Zircon Profile 8.0

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

Tests the decimal formatter with settings.

File

core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php, line 165
Contains \Drupal\rdf\Tests\Field\NumberFieldRdfaTest.

Class

NumberFieldRdfaTest
Tests RDFa output by number field formatters.

Namespace

Drupal\rdf\Tests\Field

Code

public function testDecimalFormatterWithSettings() {
  \Drupal::service('theme_handler')
    ->install([
    'classy',
  ]);
  $this
    ->config('system.theme')
    ->set('default', 'classy')
    ->save();
  $this->fieldType = 'decimal';
  $formatter = array(
    'type' => 'number_decimal',
    'settings' => array(
      'thousand_separator' => 't',
      'decimal_separator' => '#',
      'prefix_suffix' => TRUE,
    ),
  );
  $testValue = 3333333.33;
  $field_settings = array(
    'prefix' => '$',
    'suffix' => ' more.',
  );
  $this
    ->createTestField($field_settings);
  $this
    ->createTestEntity($testValue);
  $this
    ->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array(
    'value' => $testValue,
  ));

  // Test that the content attribute is created.
  $result = $this
    ->xpathContent($this
    ->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(
    ':testValue' => $testValue,
  ));
  $this
    ->assertTrue($result);
}