user = $this->getMock('Drupal\Core\Session\AccountInterface'); $this->requestStack = new RequestStack(); $this->view = $this->getMock('Drupal\views\ViewEntityInterface'); $this->viewsData = $this->getMockBuilder('Drupal\views\ViewsData') ->disableOriginalConstructor() ->getMock(); $this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface'); $this->viewExecutableFactory = new ViewExecutableFactory($this->user, $this->requestStack, $this->viewsData, $this->routeProvider); } /** * Tests the get method. * * @covers ::get */ public function testGet() { $request_1 = new Request(); $request_2 = new Request(); $this->requestStack->push($request_1); $executable = $this->viewExecutableFactory->get($this->view); $this->assertInstanceOf('Drupal\views\ViewExecutable', $executable); $this->assertSame($executable->getRequest(), $request_1); $this->assertSame($executable->getUser(), $this->user); // Call get() again to ensure a new executable is created with the other // request object. $this->requestStack->push($request_2); $executable = $this->viewExecutableFactory->get($this->view); $this->assertInstanceOf('Drupal\views\ViewExecutable', $executable); $this->assertSame($executable->getRequest(), $request_2); $this->assertSame($executable->getUser(), $this->user); } }