Commit 0ba8bfe6 authored by alexpott's avatar alexpott

Issue #2541084 by martin107, dawehner: ViewPageController does not need...

Issue #2541084 by martin107, dawehner: ViewPageController does not need $storage nor $executableFactory
parent 767cec25
......@@ -7,54 +7,13 @@
namespace Drupal\views\Routing;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\views\Plugin\views\display\Page;
use Drupal\views\ViewExecutableFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines a page controller to execute and render a view.
*/
class ViewPageController implements ContainerInjectionInterface {
/**
* The entity storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/**
* The view executable factory.
*
* @var \Drupal\views\ViewExecutableFactory
*/
protected $executableFactory;
/**
* Constructs a ViewPageController object.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage.
* @param \Drupal\views\ViewExecutableFactory $executable_factory
* The view executable factory
*/
public function __construct(EntityStorageInterface $storage, ViewExecutableFactory $executable_factory) {
$this->storage = $storage;
$this->executableFactory = $executable_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager')->getStorage('view'),
$container->get('views.executable')
);
}
class ViewPageController {
/**
* Handler a response for a given view and display.
......
......@@ -13,7 +13,6 @@
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
use Symfony\Component\Routing\Route;
/**
......@@ -29,20 +28,6 @@ class ViewPageControllerTest extends UnitTestCase {
*/
public $pageController;
/**
* The mocked view storage.
*
* @var \Drupal\views\ViewStorage|\PHPUnit_Framework_MockObject_MockObject
*/
protected $storage;
/**
* The mocked view executable factory.
*
* @var \Drupal\views\ViewExecutableFactory|\PHPUnit_Framework_MockObject_MockObject
*/
protected $executableFactory;
/**
* A render array expected for every page controller render array result.
*
......@@ -56,23 +41,13 @@ class ViewPageControllerTest extends UnitTestCase {
];
protected function setUp() {
$this->storage = $this->getMockBuilder('Drupal\Core\Config\Entity\ConfigEntityStorage')
->disableOriginalConstructor()
->getMock();
$this->executableFactory = $this->getMockBuilder('Drupal\views\ViewExecutableFactory')
->disableOriginalConstructor()
->getMock();
$this->pageController = new ViewPageController($this->storage, $this->executableFactory);
$this->pageController = new ViewPageController();
}
/**
* Tests the page controller.
*/
public function testPageController() {
$this->storage->expects($this->never())
->method('load');
$build = [
'#type' => 'view',
'#name' => 'test_page_view',
......@@ -102,9 +77,6 @@ public function testPageController() {
* Tests the page controller with arguments on a non overridden page view.
*/
public function testHandleWithArgumentsWithoutOverridden() {
$this->storage->expects($this->never())
->method('load');
$request = new Request();
$request->attributes->set('view_id', 'test_page_view');
$request->attributes->set('display_id', 'page_1');
......@@ -139,9 +111,6 @@ public function testHandleWithArgumentsWithoutOverridden() {
* Note: This test does not care about upcasting for now.
*/
public function testHandleWithArgumentsOnOverriddenRoute() {
$this->storage->expects($this->never())
->method('load');
$request = new Request();
$request->attributes->set('view_id', 'test_page_view');
$request->attributes->set('display_id', 'page_1');
......@@ -179,9 +148,6 @@ public function testHandleWithArgumentsOnOverriddenRoute() {
* are pulled in.
*/
public function testHandleWithArgumentsOnOverriddenRouteWithUpcasting() {
$this->storage->expects($this->never())
->method('load');
$request = new Request();
$request->attributes->set('view_id', 'test_page_view');
$request->attributes->set('display_id', 'page_1');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment