function FieldPluginBaseTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::setUp()
  2. 8.9.x core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::setUp()
  3. 10 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php, line 130

Class

FieldPluginBaseTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21views%21field%21FieldPluginBase.php/class/FieldPluginBase/11.x" title="Base class for views fields." class="local">\Drupal\views\Plugin\views\field\FieldPluginBase</a> @group views

Namespace

Drupal\Tests\views\Unit\Plugin\field

Code

protected function setUp() : void {
    parent::setUp();
    $this->executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')
        ->disableOriginalConstructor()
        ->getMock();
    $this->executable->style_plugin = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\style\\StylePluginBase')
        ->disableOriginalConstructor()
        ->getMock();
    $this->display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
        ->disableOriginalConstructor()
        ->getMock();
    $route_provider = $this->createMock('Drupal\\Core\\Routing\\RouteProviderInterface');
    $route_provider->expects($this->any())
        ->method('getRouteByName')
        ->with('test_route')
        ->willReturn(new Route('/test-path'));
    $this->urlGenerator = $this->createMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
    $this->pathValidator = $this->createMock('Drupal\\Core\\Path\\PathValidatorInterface');
    $this->requestStack = new RequestStack();
    $this->requestStack
        ->push(new Request());
    $this->unroutedUrlAssembler = $this->createMock('Drupal\\Core\\Utility\\UnroutedUrlAssemblerInterface');
    $this->linkGenerator = $this->createMock('Drupal\\Core\\Utility\\LinkGeneratorInterface');
    $this->renderer = $this->createMock('Drupal\\Core\\Render\\RendererInterface');
    $container_builder = new ContainerBuilder();
    $container_builder->set('url_generator', $this->urlGenerator);
    $container_builder->set('path.validator', $this->pathValidator);
    $container_builder->set('unrouted_url_assembler', $this->unroutedUrlAssembler);
    $container_builder->set('request_stack', $this->requestStack);
    $container_builder->set('renderer', $this->renderer);
    \Drupal::setContainer($container_builder);
}

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