class GridStackViewsTest in GridStack 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/Views/GridStackViewsTest.php \Drupal\Tests\gridstack\Kernel\Views\GridStackViewsTest
Test GridStack Views integration.
@coversDefaultClass \Drupal\gridstack\Plugin\views\style\GridStackViews @group gridstack
Hierarchy
- class \Drupal\Tests\gridstack\Kernel\Views\GridStackViewsTest extends \Drupal\Tests\blazy\Kernel\Views\BlazyViewsTestBase
Expanded class hierarchy of GridStackViewsTest
File
- tests/src/ Kernel/ Views/ GridStackViewsTest.php, line 15 
Namespace
Drupal\Tests\gridstack\Kernel\ViewsView source
class GridStackViewsTest extends BlazyViewsTestBase {
  /**
   * {@inheritdoc}
   */
  public static $testViews = [
    'test_gridstack',
  ];
  /**
   * {@inheritdoc}
   */
  public static $modules = [
    'system',
    'user',
    'field',
    'file',
    'image',
    'filter',
    'link',
    'node',
    'text',
    'options',
    'entity_test',
    'views',
    'views_test_config',
    'views_test_data',
    'blazy',
    'blazy_test',
    'gridstack',
    'gridstack_test',
  ];
  /**
   * {@inheritdoc}
   */
  protected function setUp($import_test_views = TRUE) {
    parent::setUp($import_test_views);
    $bundle = $this->bundle;
    $this
      ->setUpContentTypeTest($bundle);
    $data['settings'] = $this
      ->getFormatterSettings();
    $this->display = $this
      ->setUpFormatterDisplay($bundle, $data);
    $this
      ->setUpContentWithItems($bundle);
  }
  /**
   * Make sure that the HTML list style markup is correct.
   */
  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();
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| GridStackViewsTest:: | public static | property | ||
| GridStackViewsTest:: | public static | property | ||
| GridStackViewsTest:: | protected | function | ||
| GridStackViewsTest:: | public | function | Make sure that the HTML list style markup is correct. | 
