function ViewsTest::testGetNonExistentView

Same name and namespace in other branches
  1. 8.9.x core/modules/views/tests/src/Unit/ViewsTest.php \Drupal\Tests\views\Unit\ViewsTest::testGetNonExistentView()
  2. 10 core/modules/views/tests/src/Unit/ViewsTest.php \Drupal\Tests\views\Unit\ViewsTest::testGetNonExistentView()
  3. 11.x 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 81

Class

ViewsTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21views%21src%21Views.php/class/Views/9" title="Static service container wrapper for views." class="local">\Drupal\views\Views</a> @group views

Namespace

Drupal\Tests\views\Unit

Code

public function testGetNonExistentView() {
    $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.