You are here

public function AddressPlainFormatterTest::testRender in Address 8

Tests the rendered output.

File

tests/src/Kernel/Formatter/AddressPlainFormatterTest.php, line 42

Class

AddressPlainFormatterTest
Tests the address_plain formatter.

Namespace

Drupal\Tests\address\Kernel\Formatter

Code

public function testRender() {
  $this
    ->renderEntityFields($this->entity, $this->display);

  // Confirm the expected elements, including the predefined locality
  // (properly escaped), country name.
  $expected_elements = [
    'C. Prat de la Creu, 62-64',
    'AD500',
    'Canillo',
    'Andorra',
  ];
  foreach ($expected_elements as $expected_element) {
    $this
      ->assertRaw($expected_element);
  }

  // Confirm that an unrecognized locality is shown unmodified.
  $this->entity->{$this->fieldName}->locality = 'FAKE_LOCALITY';
  $this
    ->renderEntityFields($this->entity, $this->display);
  $this
    ->assertRaw('FAKE_LOCALITY');
}