public function GridStackFormatterTest::testGridStackFormatter in GridStack 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/GridStackFormatterTest.php \Drupal\Tests\gridstack\Kernel\GridStackFormatterTest::testGridStackFormatter()
Tests the GridStack formatters.
File
- tests/
src/ Kernel/ GridStackFormatterTest.php, line 88
Class
- GridStackFormatterTest
- Tests the GridStack field rendering using the image 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);
$render = $this->gridstackManager
->getRenderer()
->renderRoot($build);
$this
->assertNotEmpty($render);
$render_empty = $this->gridstackManager
->getRenderer()
->renderRoot($build_empty[$this->testEmptyName]);
$this
->assertEmpty($render_empty);
$this
->assertInstanceOf('\\Drupal\\Core\\Field\\FieldItemListInterface', $this->testItems);
$this
->assertInstanceOf('\\Drupal\\gridstack\\Form\\GridStackAdminInterface', $this->formatterInstance
->admin());
$this
->assertInstanceOf('\\Drupal\\gridstack\\GridStackFormatterInterface', $this->formatterInstance
->formatter());
$this
->assertInstanceOf('\\Drupal\\gridstack\\GridStackManagerInterface', $this->formatterInstance
->manager());
$component = $this->display
->getComponent($this->testFieldName);
$this
->assertEquals($this->testPluginId, $component['type']);
$scopes = $this->formatterInstance
->getScopedFormElements();
$this
->assertArrayHasKey('optionset', $scopes['settings']);
$summary = $this->formatterInstance
->settingsSummary();
$this
->assertNotEmpty($summary);
}