function ViewTest::testCalculateDependencies

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

@covers ::calculateDependencies

File

core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php, line 43

Class

ViewTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21views%21area%21View.php/class/View/9" title="Views area handlers. Insert a view inside of an area." class="local">\Drupal\views\Plugin\views\area\View</a> @group views

Namespace

Drupal\Tests\views\Unit\Plugin\area

Code

public function testCalculateDependencies() {
    
    /** @var \Drupal\views\Entity\View $view_this */
    
    /** @var \Drupal\views\Entity\View $view_other */
    $view_this = $this->createMock('Drupal\\views\\ViewEntityInterface');
    $view_this->expects($this->any())
        ->method('getConfigDependencyKey')
        ->willReturn('config');
    $view_this->expects($this->any())
        ->method('getConfigDependencyName')
        ->willReturn('view.this');
    $view_this->expects($this->any())
        ->method('id')
        ->willReturn('this');
    $view_other = $this->createMock('Drupal\\views\\ViewEntityInterface');
    $view_other->expects($this->any())
        ->method('getConfigDependencyKey')
        ->willReturn('config');
    $view_other->expects($this->any())
        ->method('getConfigDependencyName')
        ->willReturn('view.other');
    $this->entityStorage
        ->expects($this->any())
        ->method('load')
        ->willReturnMap([
        [
            'this',
            $view_this,
        ],
        [
            'other',
            $view_other,
        ],
    ]);
    $this->viewHandler->view->storage = $view_this;
    $this->viewHandler->options['view_to_insert'] = 'other:default';
    $this->assertEquals([
        'config' => [
            'view.other',
        ],
    ], $this->viewHandler
        ->calculateDependencies());
    $this->viewHandler->options['view_to_insert'] = 'this:default';
    $this->assertSame([], $this->viewHandler
        ->calculateDependencies());
}

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