You are here

public function WrapperClassFormatterTest::testClassFormatter in Element Class Formatter 8

File

tests/src/Functional/WrapperClassFormatterTest.php, line 25

Class

WrapperClassFormatterTest
Functional tests for the mailto link with class formatter.

Namespace

Drupal\Tests\element_class_formatter\Functional

Code

public function testClassFormatter() {
  $formatter_settings = [
    'class' => self::TEST_CLASS,
    'tag' => 'h2',
  ];
  $field_config = $this
    ->createEntityField('wrapper_class', 'string', $formatter_settings);
  $entity = EntityTest::create([
    $field_config
      ->getName() => [
      [
        'value' => 'I am a string',
      ],
    ],
  ]);
  $entity
    ->save();
  $this
    ->drupalGet($entity
    ->toUrl());
  $assert_session = $this
    ->assertSession();
  $assert_session
    ->elementExists('css', 'h2.' . self::TEST_CLASS);
}