public function SlickFileFormatterTest::testSlickFormatter in Slick Carousel 8
Tests the Slick formatters.
File
- tests/
src/ Kernel/ SlickFileFormatterTest.php, line 79
Class
- SlickFileFormatterTest
- Tests the Slick field rendering using the text field type.
Namespace
Drupal\Tests\slick\KernelCode
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']);
$settings = $this->formatterInstance
->buildSettings();
$this
->assertEquals(TRUE, $settings['blazy']);
$form = [];
$form_state = new FormState();
$element = $this->formatterInstance
->settingsForm($form, $form_state);
$this
->assertArrayHasKey('optionset', $element);
}