protected function FieldPluginBaseTest::setUp in Drupal 9
Same name and namespace in other branches
- 8 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 133 - Contains \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest.
Class
- FieldPluginBaseTest
- @coversDefaultClass \Drupal\views\Plugin\views\field\FieldPluginBase @group views
Namespace
Drupal\Tests\views\Unit\Plugin\fieldCode
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);
}