function ViewExecutableTest::testExecuteReturn

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::testExecuteReturn()
  2. 10 core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::testExecuteReturn()
  3. 11.x core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::testExecuteReturn()

Tests the return values for the execute() method.

@covers ::execute @dataProvider providerExecuteReturn

Parameters

bool $display_enabled: Whether the display to test should be enabled.

bool $expected_result: The expected result when calling execute().

File

core/modules/views/tests/src/Unit/ViewExecutableTest.php, line 713

Class

ViewExecutableTest
@coversDefaultClass \Drupal\views\ViewExecutable @group views

Namespace

Drupal\Tests\views\Unit

Code

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 */
    [
        $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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.