You are here

protected function FieldsTest::createLayoutPluginManagerMock in Layout Plugin Views 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/FieldsTest.php \Drupal\Tests\layout_plugin_views\Unit\FieldsTest::createLayoutPluginManagerMock()

Return value

\PHPUnit_Framework_MockObject_MockObject

1 call to FieldsTest::createLayoutPluginManagerMock()
FieldsTest::containerGetCallback in tests/src/Unit/FieldsTest.php
Callback for the get method of the mocked container. Creates and returns a mock for every relevant service.

File

tests/src/Unit/FieldsTest.php, line 312

Class

FieldsTest
@coversDefaultClass \Drupal\layout_plugin_views\Plugin\views\row\Fields @group Panels

Namespace

Drupal\Tests\layout_plugin_views\Unit

Code

protected function createLayoutPluginManagerMock() {
  $layoutMock = $this
    ->getMockForAbstractClass(LayoutInterface::class);
  $layoutMock
    ->method('build')
    ->willReturnArgument(0);
  $mock = $this
    ->getMockBuilder(LayoutPluginManager::class)
    ->disableOriginalConstructor()
    ->getMock();
  $mock
    ->method('getLayoutOptions')
    ->willReturn($this
    ->availableLayoutOptions());
  $mock
    ->method('createInstance')
    ->willReturn($layoutMock);
  $mock
    ->method('getDefinition')
    ->willReturn($this
    ->createLayoutDefinition());
  $mock
    ->method('getDefinitions')
    ->willReturn([
    'something that is not empty',
  ]);
  $mock
    ->method('hasDefinition')
    ->willReturn(TRUE);
  return $mock;
}