Commit c9698fb0 authored by xjm's avatar xjm

Issue #2727545 by Lendude, Sagar Ramgade, dawehner, yvesmarie, xjm: Missing...

Issue #2727545 by Lendude, Sagar Ramgade, dawehner, yvesmarie, xjm: Missing return value in ViewExecutable execute() methods
parent 43f4378d
......@@ -1421,7 +1421,7 @@ public function execute($display_id = NULL) {
// Let modules modify the view just after executing it.
$module_handler->invokeAll('views_post_execute', array($this));
$this->executed = TRUE;
return $this->executed = TRUE;
}
/**
......
......@@ -21,6 +21,16 @@
*/
class ViewExecutableTest extends UnitTestCase {
/**
* Indicates that a display is enabled.
*/
const DISPLAY_ENABLED = TRUE;
/**
* Indicates that a display is disabled.
*/
const DISPLAY_DISABLED = FALSE;
/**
* A mocked display collection.
*
......@@ -632,4 +642,52 @@ public function testCacheIsIgnoredDuringPreview() {
$view->execute();
}
/**
* Tests the return values for the execute() method.
*
* @param bool $display_enabled
* Whether the display to test should be enabled.
* @param bool $expected_result
* The expected result when calling execute().
*
* @covers ::execute
* @dataProvider providerExecuteReturn
*/
public function testExecuteReturn($display_enabled, $expected_result) {
/** @var \Drupal\views\ViewExecutable|\PHPUnit_Framework_MockObject_MockObject $view */
/** @var \Drupal\views\Plugin\views\display\DisplayPluginBase|\PHPUnit_Framework_MockObject_MockObject $display */
list($view, $display) = $this->setupBaseViewAndDisplay();
$display->expects($this->any())
->method('isEnabled')
->willReturn($display_enabled);
// Pager needs to be set to avoid false test failures.
$view->pager = $this->getMockBuilder(NonePager::class)
->disableOriginalConstructor()
->getMock();
$query = $this->getMockBuilder(QueryPluginBase::class)
->disableOriginalConstructor()
->getMock();
$view->query = $query;
$view->built = TRUE;
$this->assertEquals($expected_result, $view->execute());
}
/**
* Provider for testExecuteReturn().
*
* @return array[]
* An array of arrays containing the display state and expected value.
*/
public function providerExecuteReturn() {
return [
'enabled' => [static::DISPLAY_ENABLED, TRUE],
'disabled' => [static::DISPLAY_DISABLED, FALSE],
];
}
}
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