function ViewsBlockTest::setUp

Same name in this branch
  1. 8.9.x core/modules/views/tests/src/Kernel/Plugin/ViewsBlockTest.php \Drupal\Tests\views\Kernel\Plugin\ViewsBlockTest::setUp()
Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php \Drupal\Tests\views\Unit\Plugin\Block\ViewsBlockTest::setUp()
  2. 9 core/modules/views/tests/src/Kernel/Plugin/ViewsBlockTest.php \Drupal\Tests\views\Kernel\Plugin\ViewsBlockTest::setUp()
  3. 10 core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php \Drupal\Tests\views\Unit\Plugin\Block\ViewsBlockTest::setUp()
  4. 10 core/modules/views/tests/src/Kernel/Plugin/ViewsBlockTest.php \Drupal\Tests\views\Kernel\Plugin\ViewsBlockTest::setUp()
  5. 11.x core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php \Drupal\Tests\views\Unit\Plugin\Block\ViewsBlockTest::setUp()
  6. 11.x core/modules/views/tests/src/Kernel/Plugin/ViewsBlockTest.php \Drupal\Tests\views\Kernel\Plugin\ViewsBlockTest::setUp()
  7. 10 core/modules/views_ui/tests/src/Kernel/ViewsBlockTest.php \Drupal\Tests\views_ui\Kernel\ViewsBlockTest::setUp()
  8. 11.x core/modules/views_ui/tests/src/Kernel/ViewsBlockTest.php \Drupal\Tests\views_ui\Kernel\ViewsBlockTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php, line 60

Class

ViewsBlockTest
@coversDefaultClass \Drupal\views\Plugin\block\ViewsBlock @group views

Namespace

Drupal\Tests\views\Unit\Plugin\Block

Code

protected function setUp() {
    // TODO: Change the autogenerated stub.
    parent::setUp();
    $condition_plugin_manager = $this->createMock('Drupal\\Core\\Executable\\ExecutableManagerInterface');
    $condition_plugin_manager->expects($this->any())
        ->method('getDefinitions')
        ->will($this->returnValue([]));
    $container = new ContainerBuilder();
    $container->set('plugin.manager.condition', $condition_plugin_manager);
    \Drupal::setContainer($container);
    $this->executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')
        ->disableOriginalConstructor()
        ->setMethods([
        'buildRenderable',
        'setDisplay',
        'setItemsPerPage',
        'getShowAdminLinks',
    ])
        ->getMock();
    $this->executable
        ->expects($this->any())
        ->method('setDisplay')
        ->with('block_1')
        ->will($this->returnValue(TRUE));
    $this->executable
        ->expects($this->any())
        ->method('getShowAdminLinks')
        ->willReturn(FALSE);
    $this->executable->display_handler = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\Block')
        ->disableOriginalConstructor()
        ->setMethods(NULL)
        ->getMock();
    $this->view = $this->getMockBuilder('Drupal\\views\\Entity\\View')
        ->disableOriginalConstructor()
        ->getMock();
    $this->view
        ->expects($this->any())
        ->method('id')
        ->willReturn('test_view');
    $this->executable->storage = $this->view;
    $this->executableFactory = $this->getMockBuilder('Drupal\\views\\ViewExecutableFactory')
        ->disableOriginalConstructor()
        ->getMock();
    $this->executableFactory
        ->expects($this->any())
        ->method('get')
        ->with($this->view)
        ->will($this->returnValue($this->executable));
    $this->displayHandler = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\Block')
        ->disableOriginalConstructor()
        ->getMock();
    $this->displayHandler
        ->expects($this->any())
        ->method('blockSettings')
        ->willReturn([]);
    $this->displayHandler
        ->expects($this->any())
        ->method('getPluginId')
        ->willReturn('block');
    $this->displayHandler
        ->expects($this->any())
        ->method('getHandlers')
        ->willReturn([]);
    $this->executable->display_handler = $this->displayHandler;
    $this->storage = $this->getMockBuilder('Drupal\\Core\\Config\\Entity\\ConfigEntityStorage')
        ->disableOriginalConstructor()
        ->getMock();
    $this->storage
        ->expects($this->any())
        ->method('load')
        ->with('test_view')
        ->will($this->returnValue($this->view));
    $this->account = $this->createMock('Drupal\\Core\\Session\\AccountInterface');
}

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