You are here

public function ViewsTest::testGetNonExistentView in Drupal 8

Same name and namespace in other branches
  1. 9 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()

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 \Drupal\views\Views @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);
}