public function GridStackFileFormatterTest::testGridStackFormatter in GridStack 8
Tests the GridStack formatters.
File
- tests/
src/ Kernel/ GridStackFileFormatterTest.php, line 79
Class
- GridStackFileFormatterTest
- Tests the GridStack field rendering using the text field type.
Namespace
Drupal\Tests\gridstack\KernelCode
public function testGridStackFormatter() {
$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->gridstackManager
->getRenderer()
->renderRoot($build);
$this
->assertNotEmpty($render);
$render_empty = $this->gridstackManager
->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);
}