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

8.0.x
Alex Pott 2013-12-30 15:06:09 +00:00
parent e46d6bfa19
commit 2d9295537d
3 changed files with 117 additions and 1 deletions

View File

@ -107,7 +107,7 @@ class View extends AreaPluginBase {
if (!empty($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)) {
return array();

View File

@ -0,0 +1,66 @@
<?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();
}
}

View File

@ -0,0 +1,50 @@
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: ''