public function BlazyViewsFileTest::todoTestBlazyViews in Blazy 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/Views/BlazyViewsFileTest.php \Drupal\Tests\blazy\Kernel\Views\BlazyViewsFileTest::todoTestBlazyViews()
Make sure that the HTML list style markup is correct.
@todo enable this once corrected, likely broken since Drupal 8.4+. @requires module video_embed_media
File
- tests/
src/ Kernel/ Views/ BlazyViewsFileTest.php, line 90
Class
- BlazyViewsFileTest
- Test Blazy Views integration.
Namespace
Drupal\Tests\blazy\Kernel\ViewsCode
public function todoTestBlazyViews() {
$this
->buildContents();
$view = Views::getView('test_blazy_entity');
$this
->executeView($view);
$view
->setDisplay('default');
$style_plugin = $view->style_plugin;
$this
->assertInstanceOf('\\Drupal\\blazy\\BlazyManagerInterface', $style_plugin
->blazyManager(), 'BlazyManager implements interface.');
$this
->assertInstanceOf('\\Drupal\\blazy_test\\Form\\BlazyAdminTestInterface', $style_plugin
->admin(), 'BlazyAdmin implements interface.');
$style_plugin->options = array_merge($style_plugin->options, $this
->getDefaultFields(TRUE));
$style_plugin->options['grid'] = 0;
$style_plugin->options['grid_medium'] = 3;
$style_plugin->options['grid_small'] = 1;
$style_plugin->options['image'] = 'field_image';
$style_plugin->options['media_switch'] = 'blazy_test';
$style_plugin->options['overlay'] = $this->testFieldName;
$style_plugin->options['caption']['title'] = 'title';
$style_plugin->options['caption']['field_teaser'] = 'field_teaser';
$settings = $style_plugin->options;
// Forms.
$fields = [
'captions',
'layouts',
'images',
'links',
'titles',
'classes',
'overlays',
'thumbnails',
'layouts',
];
$definition = $style_plugin
->getDefinedFieldOptions($fields);
$this
->assertEquals('blazy_test', $definition['plugin_id']);
$form = [];
$form_state = new FormState();
$style_plugin
->buildOptionsForm($form, $form_state);
$this
->assertArrayHasKey('closing', $form);
$style_plugin
->submitOptionsForm($form, $form_state);
// @todo: Fields.
$image = [];
$index = 0;
$row = $view->result[$index];
// Render.
$render = $view
->getStyle()
->render();
$this
->assertArrayHasKey('data-blazy', $render['#attributes']);
$output = $view
->preview();
$output = $this->blazyManager
->getRenderer()
->renderRoot($output);
$this
->assertTrue(strpos($output, 'data-blazy') !== FALSE, 'Blazy attribute is added to DIV.');
$element = [
'settings' => $settings,
];
$view
->getStyle()
->buildElement($element, $row, $index);
try {
$output = $view
->getStyle()
->getImageRenderable($settings, $row, $index);
} catch (\PHPUnit_Framework_Exception $e) {
}
$this
->assertTrue(TRUE);
$image = $view
->getStyle()
->getImageRenderable($settings, $row, $index);
$this
->assertArrayHasKey('image', $settings);
$output = $view
->getStyle()
->getImageItem($image);
$this
->assertArrayHasKey('image', $settings);
$output = $view
->getStyle()
->isImageRenderable($row, $index, $this->testFieldName);
$this
->assertArrayHasKey('image', $settings);
$output = $view
->getStyle()
->getCaption($index, $settings);
$this
->assertArrayHasKey('caption', $settings);
$view
->getStyle()
->getLayout($settings, $index);
$this
->assertArrayHasKey('layout', $settings);
$output = FALSE;
try {
$output = $view
->getStyle()
->getFieldRenderable($row, $index, '');
} catch (\PHPUnit_Framework_Exception $e) {
}
$this
->assertTrue(TRUE);
$output = $view
->getStyle()
->getFieldRendered($index, $this->testFieldName);
$this
->assertArrayHasKey('image', $settings);
$output = $view
->getStyle()
->getFieldRenderable($row, $index, $this->testFieldName);
$this
->assertArrayHasKey('image', $settings);
$output = $view
->getStyle()
->getFieldString($row, 'title', $index);
$this
->assertNotEmpty($output[0]);
if ($blazy = BlazyViews::viewsField($view)) {
$scopes = $blazy
->getScopedFormElements();
$this
->assertArrayHasKey('settings', $scopes);
$form = [];
$form_state = new FormState();
$blazy
->buildOptionsForm($form, $form_state);
$this
->assertArrayHasKey('image_style', $form);
$this
->assertInstanceOf('\\Drupal\\blazy\\Form\\BlazyAdminInterface', $blazy
->blazyAdmin(), 'BlazyAdmin implements interface.');
}
$view
->destroy();
}