public function GridStackManagerTest::testBuild in GridStack 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/GridStackManagerTest.php \Drupal\Tests\gridstack\Kernel\GridStackManagerTest::testBuild()
Tests for GridStack build.
@covers ::build @covers ::preRenderGridStack @dataProvider providerTestGridStackBuild
Parameters
bool $items: Whether to provide items, or not.
array $settings: The settings being tested.
mixed|bool|string $expected: The expected output.
File
- tests/
src/ Kernel/ GridStackManagerTest.php, line 125
Class
- GridStackManagerTest
- Tests the GridStack manager methods.
Namespace
Drupal\Tests\gridstack\KernelCode
public function testBuild($items, array $settings, $expected) {
$manager = $this->gridstackManager;
$defaults = $this
->getFormatterSettings() + GridStackDefault::htmlSettings();
$settings = array_merge($defaults, $settings) + GridStackDefault::imageSettings();
$settings['optionset'] = 'test';
$build = $this->display
->build($this->entity);
$items = !$items ? [] : $build[$this->testFieldName]['#build']['items'];
$build = [
'items' => $items,
'settings' => $settings,
'optionset' => GridStack::loadWithFallback($settings['optionset']),
];
$gridstack = $manager
->build($build);
$this
->assertEquals($expected, !empty($gridstack));
}