Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / modules / contrib / blazy / tests / src / Kernel / Views / BlazyViewsGridTest.php
1 <?php
2
3 namespace Drupal\Tests\blazy\Kernel\Views;
4
5 use Drupal\Core\Form\FormState;
6 use Drupal\views\Views;
7
8 /**
9  * Test Blazy Views Grid integration.
10  *
11  * @coversDefaultClass \Drupal\blazy\Plugin\views\style\BlazyViews
12  * @group blazy
13  */
14 class BlazyViewsGridTest extends BlazyViewsTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $testViews = ['test_blazy_file'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp($import_test_views = TRUE) {
25     parent::setUp($import_test_views);
26
27     $bundle = $this->bundle;
28     $this->setUpContentTypeTest($bundle);
29
30     $data['settings'] = $this->getFormatterSettings();
31     $this->display = $this->setUpFormatterDisplay($bundle, $data);
32
33     $this->setUpContentWithItems($bundle);
34   }
35
36   /**
37    * Make sure that the HTML list style markup is correct.
38    */
39   public function testBlazyViews() {
40     $view = Views::getView('test_blazy_file');
41     $this->executeView($view);
42     $view->setDisplay('default');
43
44     $style_plugin = $view->style_plugin;
45
46     $style_plugin->options['grid']        = 4;
47     $style_plugin->options['grid_medium'] = 3;
48     $style_plugin->options['grid_small']  = 1;
49
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.');
52
53     $settings = $style_plugin->options;
54
55     $form = [];
56     $form_state = new FormState();
57     $style_plugin->buildOptionsForm($form, $form_state);
58     $this->assertArrayHasKey('closing', $form);
59
60     $style_plugin->submitOptionsForm($form, $form_state);
61     $view->destroy();
62
63     // @todo: Fields.
64     $view = Views::getView('test_blazy_file');
65     $this->executeView($view);
66     $view->setDisplay('default');
67
68     // Render.
69     $render = $view->getStyle()->render();
70     $this->assertArrayHasKey('data-blazy', $render['#attributes']);
71
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.');
75     $view->destroy();
76   }
77
78 }