function ViewsLocalTaskTest::testGetDerivativeDefinitionsWithoutLocalTask

Same name and namespace in other branches
  1. 8.9.x core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php \Drupal\Tests\views\Unit\Plugin\Derivative\ViewsLocalTaskTest::testGetDerivativeDefinitionsWithoutLocalTask()
  2. 10 core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php \Drupal\Tests\views\Unit\Plugin\Derivative\ViewsLocalTaskTest::testGetDerivativeDefinitionsWithoutLocalTask()
  3. 11.x core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php \Drupal\Tests\views\Unit\Plugin\Derivative\ViewsLocalTaskTest::testGetDerivativeDefinitionsWithoutLocalTask()

Tests fetching the derivatives on a view with without a local task.

File

core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php, line 79

Class

ViewsLocalTaskTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21Derivative%21ViewsLocalTask.php/class/ViewsLocalTask/9" title="Provides local task definitions for all views configured as local tasks." class="local">\Drupal\views\Plugin\Derivative\ViewsLocalTask</a> @group views

Namespace

Drupal\Tests\views\Unit\Plugin\Derivative

Code

public function testGetDerivativeDefinitionsWithoutLocalTask() {
    $executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')
        ->disableOriginalConstructor()
        ->getMock();
    $display_plugin = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\PathPluginBase')
        ->onlyMethods([
        'getOption',
    ])
        ->disableOriginalConstructor()
        ->getMockForAbstractClass();
    $display_plugin->expects($this->once())
        ->method('getOption')
        ->with('menu')
        ->willReturn([
        'type' => 'normal',
    ]);
    $executable->display_handler = $display_plugin;
    $storage = $this->getMockBuilder('Drupal\\views\\Entity\\View')
        ->disableOriginalConstructor()
        ->getMock();
    $storage->expects($this->any())
        ->method('id')
        ->willReturn('example_view');
    $storage->expects($this->any())
        ->method('getExecutable')
        ->willReturn($executable);
    $this->viewStorage
        ->expects($this->any())
        ->method('load')
        ->with('example_view')
        ->willReturn($storage);
    $result = [
        [
            'example_view',
            'page_1',
        ],
    ];
    $this->localTaskDerivative
        ->setApplicableMenuViews($result);
    $definitions = $this->localTaskDerivative
        ->getDerivativeDefinitions($this->baseDefinition);
    $this->assertEquals([], $definitions);
}

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