Issue #2727545 by Lendude, Sagar Ramgade, dawehner, yvesmarie, xjm: Missing return value in ViewExecutable execute() methods
parent
43f4378dc5
commit
c9698fb0f4
|
@ -1421,7 +1421,7 @@ class ViewExecutable implements \Serializable {
|
|||
// 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 @@ use Symfony\Component\Routing\Route;
|
|||
*/
|
||||
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 @@ class ViewExecutableTest extends UnitTestCase {
|
|||
$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],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue