You are here

public function ViewsTest::testGetView in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/tests/src/Unit/ViewsTest.php \Drupal\Tests\views\Unit\ViewsTest::testGetView()

Tests the getView() method.

@covers ::getView

File

core/modules/views/tests/src/Unit/ViewsTest.php, line 56
Contains \Drupal\Tests\views\Unit\ViewsTest.

Class

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

Namespace

Drupal\Tests\views\Unit

Code

public function testGetView() {
  $view = new View([
    'id' => 'test_view',
  ], 'view');
  $view_storage = $this
    ->getMockBuilder('Drupal\\Core\\Config\\Entity\\ConfigEntityStorage')
    ->disableOriginalConstructor()
    ->getMock();
  $view_storage
    ->expects($this
    ->once())
    ->method('load')
    ->with('test_view')
    ->will($this
    ->returnValue($view));
  $entity_manager = $this
    ->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
  $entity_manager
    ->expects($this
    ->once())
    ->method('getStorage')
    ->with('view')
    ->will($this
    ->returnValue($view_storage));
  $this->container
    ->set('entity.manager', $entity_manager);
  $executable = Views::getView('test_view');
  $this
    ->assertInstanceOf('Drupal\\views\\ViewExecutable', $executable);
  $this
    ->assertEquals($view
    ->id(), $executable->storage
    ->id());
  $this
    ->assertEquals(spl_object_hash($view), spl_object_hash($executable->storage));
}