public function GridStackFormatterTest::testGridStackFormatter in GridStack 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/GridStackFormatterTest.php \Drupal\Tests\gridstack\Kernel\GridStackFormatterTest::testGridStackFormatter()
Tests the GridStack formatters.
File
- tests/
src/ Kernel/ GridStackFormatterTest.php, line 87
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']);
$this
->assertEquals($this->testPluginId, $build[$this->testFieldName]['#formatter']);
$scopes = $this->formatterInstance
->getScopedFormElements();
$this
->assertEquals('gridstack', $scopes['namespace']);
$this
->assertArrayHasKey('optionset', $scopes['settings']);
$summary = $this->formatterInstance
->settingsSummary();
$this
->assertNotEmpty($summary);
}