function ViewsTest::testGetNonExistentView

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

Tests the getView() method against a non-existent view.

@covers ::getView

File

core/modules/views/tests/src/Unit/ViewsTest.php, line 86

Class

ViewsTest
@coversDefaultClass \Drupal\views\Views @group views

Namespace

Drupal\Tests\views\Unit

Code

public function testGetNonExistentView() : void {
    $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class);
    $storage = $this->prophesize(EntityStorageInterface::class);
    $storage->load('test_view_non_existent')
        ->willReturn(NULL);
    $entity_type_manager->getStorage('view')
        ->willReturn($storage->reveal());
    $this->container
        ->set('entity_type.manager', $entity_type_manager->reveal());
    $executable_does_not_exist = Views::getView('test_view_non_existent');
    $this->assertNull($executable_does_not_exist);
}

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