You are here

public function SlickTextFormatterTest::testSlickFormatter in Slick Carousel 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/SlickTextFormatterTest.php \Drupal\Tests\slick\Kernel\SlickTextFormatterTest::testSlickFormatter()

Tests the Slick formatters.

File

tests/src/Kernel/SlickTextFormatterTest.php, line 76

Class

SlickTextFormatterTest
Tests the Slick field rendering using the text field type.

Namespace

Drupal\Tests\slick\Kernel

Code

public function testSlickFormatter() {
  $entity = $this->entity;

  // Generate the render array to verify if the cache tags are as expected.
  $build = $this->display
    ->build($entity);
  $build_empty = $this->displayEmpty
    ->build($entity);
  $component = $this->display
    ->getComponent($this->testFieldName);
  $this
    ->assertEquals($this->testPluginId, $component['type']);
  $render = $this->slickManager
    ->getRenderer()
    ->renderRoot($build);
  $this
    ->assertNotEmpty($render);
  $render_empty = $this->slickManager
    ->getRenderer()
    ->renderRoot($build_empty[$this->testEmptyName]);
  $this
    ->assertEmpty($render_empty);
  $scopes = $this->formatterInstance
    ->getScopedFormElements();
  $this
    ->assertEquals($this->testPluginId, $scopes['plugin_id']);
  $form = [];
  $form_state = new FormState();
  $element = $this->formatterInstance
    ->settingsForm($form, $form_state);
  $this
    ->assertArrayHasKey('optionset', $element);
}