Commit cfd1c3ae authored by alexpott's avatar alexpott

Issue #2149107 by longwave: "View" area handler in Views gives fatal error.

parent c47f5c70
...@@ -107,7 +107,7 @@ public function render($empty = FALSE) { ...@@ -107,7 +107,7 @@ public function render($empty = FALSE) {
if (!empty($this->options['view_to_insert'])) { if (!empty($this->options['view_to_insert'])) {
list($view_name, $display_id) = explode(':', $this->options['view_to_insert']); list($view_name, $display_id) = explode(':', $this->options['view_to_insert']);
$view = $this->viewStorage->load($view_name); $view = $this->viewStorage->load($view_name)->getExecutable();
if (empty($view) || !$view->access($display_id)) { if (empty($view) || !$view->access($display_id)) {
return array(); return array();
......
<?php
/**
* @file
* Contains \Drupal\views\Tests\Handler\AreaViewTest.
*/
namespace Drupal\views\Tests\Handler;
use Drupal\views\Tests\ViewUnitTestBase;
use Drupal\views\Views;
/**
* Tests the view area handler.
*
* @see \Drupal\views\Plugin\views\area\View
*/
class AreaViewTest extends ViewUnitTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('user');
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_area_view', 'test_simple_argument');
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Area: View',
'description' => 'Tests the view area handler.',
'group' => 'Views Handlers',
);
}
/**
* Tests the view area handler.
*/
public function testViewArea() {
$view = Views::getView('test_area_view');
$this->executeView($view);
$output = $view->render();
$output = drupal_render($output);
$this->assertTrue(strpos($output, 'view-test-simple-argument') !== FALSE, 'The test view is correctly embedded.');
$view->destroy();
$view->setArguments(array(27));
$this->executeView($view);
$output = $view->render();
$output = drupal_render($output);
$this->assertTrue(strpos($output, 'John') === FALSE, 'The test view is correctly embedded with inherited arguments.');
$this->assertTrue(strpos($output, 'George') !== FALSE, 'The test view is correctly embedded with inherited arguments.');
$view->destroy();
}
}
base_table: views_test_data
core: '8'
description: ''
status: '1'
display:
default:
display_options:
defaults:
fields: '0'
pager: '0'
pager_options: '0'
sorts: '0'
fields:
id:
field: id
id: id
relationship: none
table: views_test_data
plugin_id: numeric
provider: views_test_data
pager:
options:
offset: '0'
type: none
pager_options: { }
sorts:
id:
field: id
id: id
order: ASC
relationship: none
table: views_test_data
plugin_id: numeric
provider: views_test_data
header:
view:
field: view
id: view
table: views
view_to_insert: test_simple_argument:default
inherit_arguments: 1
plugin_id: view
provider: views
display_plugin: default
display_title: Master
id: default
position: '0'
label: ''
id: test_area_view
tag: ''
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment