3 namespace Drupal\Tests\blazy\Kernel\Views;
5 use Drupal\Core\Form\FormState;
6 use Drupal\views\Views;
9 * Test Blazy Views Grid integration.
11 * @coversDefaultClass \Drupal\blazy\Plugin\views\style\BlazyViews
14 class BlazyViewsGridTest extends BlazyViewsTestBase {
19 public static $testViews = ['test_blazy_file'];
24 protected function setUp($import_test_views = TRUE) {
25 parent::setUp($import_test_views);
27 $bundle = $this->bundle;
28 $this->setUpContentTypeTest($bundle);
30 $data['settings'] = $this->getFormatterSettings();
31 $this->display = $this->setUpFormatterDisplay($bundle, $data);
33 $this->setUpContentWithItems($bundle);
37 * Make sure that the HTML list style markup is correct.
39 public function testBlazyViews() {
40 $view = Views::getView('test_blazy_file');
41 $this->executeView($view);
42 $view->setDisplay('default');
44 $style_plugin = $view->style_plugin;
46 $style_plugin->options['grid'] = 4;
47 $style_plugin->options['grid_medium'] = 3;
48 $style_plugin->options['grid_small'] = 1;
50 $this->assertInstanceOf('\Drupal\blazy\BlazyManagerInterface', $style_plugin->blazyManager(), 'BlazyManager implements interface.');
51 $this->assertInstanceOf('\Drupal\blazy\Form\BlazyAdminInterface', $style_plugin->admin(), 'BlazyAdmin implements interface.');
53 $settings = $style_plugin->options;
56 $form_state = new FormState();
57 $style_plugin->buildOptionsForm($form, $form_state);
58 $this->assertArrayHasKey('closing', $form);
60 $style_plugin->submitOptionsForm($form, $form_state);
64 $view = Views::getView('test_blazy_file');
65 $this->executeView($view);
66 $view->setDisplay('default');
69 $render = $view->getStyle()->render();
70 $this->assertArrayHasKey('data-blazy', $render['#attributes']);
72 $output = $view->preview();
73 $output = $this->blazyManager->getRenderer()->renderRoot($output);
74 $this->assertTrue(strpos($output, 'data-blazy') !== FALSE, 'Blazy attribute is added to DIV.');