You are here

public function GridStackViewsTest::testViews in GridStack 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/Views/GridStackViewsTest.php \Drupal\Tests\gridstack\Kernel\Views\GridStackViewsTest::testViews()

Make sure that the HTML list style markup is correct.

File

tests/src/Kernel/Views/GridStackViewsTest.php, line 64

Class

GridStackViewsTest
Test GridStack Views integration.

Namespace

Drupal\Tests\gridstack\Kernel\Views

Code

public function testViews() {
  $view = Views::getView('test_gridstack');
  $this
    ->executeView($view);
  $view
    ->setDisplay('default');
  $style_plugin = $view->style_plugin;
  $style_plugin->options['id'] = 'gridstack-hotdamn';
  $this
    ->assertInstanceOf('\\Drupal\\gridstack\\GridStackManagerInterface', $style_plugin
    ->manager(), 'GridStackManager implements interface.');
  $this
    ->assertInstanceOf('\\Drupal\\gridstack\\Form\\GridStackAdminInterface', $style_plugin
    ->admin(), 'GridStackAdmin implements interface.');
  $form = [];
  $form_state = new FormState();
  $style_plugin
    ->buildOptionsForm($form, $form_state);
  $this
    ->assertArrayHasKey('closing', $form);
  $style_plugin
    ->submitOptionsForm($form, $form_state);

  // Render.
  $render = $view
    ->getStyle()
    ->render();
  $this
    ->assertEquals('gridstack', $render['#theme']);
  $style_plugin->options['vanilla'] = TRUE;
  $render = $view
    ->getStyle()
    ->render();
  $this
    ->assertEquals('gridstack', $render['#theme']);
  $output = $view
    ->preview();
  $output = $this->blazyManager
    ->getRenderer()
    ->renderRoot($output);
  $this
    ->assertTrue(strpos($output, 'gridstack-hotdamn') !== FALSE, 'GridStack ID attribute is added to DIV.');
  $view
    ->destroy();
}