Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
views.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 May 2014 at 16:40 UTC
Updated:
29 Jul 2014 at 23:36 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerHere is a patch.
Comment #2
tim.plunkettAny reason to not pass it the request stack itself? Just curious.
Comment #3
dawehnerI kinda prefer to use the stack for service which live longer and the request for classes which will be destroyed relative early.
Comment #4
damiankloip commentedYes, I think I agree with that concept too. Makes sense.
How about a unit test for the factory whilst we are here.
Comment #5
dawehnerIf you want to extend the test coverage it would be cool to push a new request onto the stack and ensure it is reflecting in new views.
Comment #6
damiankloip commentedSure, let's do that.
Comment #7
dawehnerAwesome!
Comment #8
znerol commenteds/VIew/View/
In my opinion it is not necessary to mock
RequestandRequestStack.Generally looks good to me. Given that it touches
ViewsExecutable, I suggest to also updategetExposedInput()and use$this->requestinstead of\Drupal::request(). Also do not forget to update the documentation ofsetExposedInput().It seems that this issue will allow us to remove a great deal of request-service dependencies from views handlers. The candidates (including a couple of false positives):
For the reference
Drupal\views\Plugin\views\area\HTTPStatusCodeis an example of how the request is accessed properly.Comment #9
znerol commented#2059003: Remove try/catch around getRequest() in DisplayPluginBase::getHandlers() looks related.
Comment #10
dawehnerContinued to work on that.
Comment #12
damiankloip commentedYou might want to rename this issue then because you guys just blew up the scope massively.
Yeah, we added that class so we are familiar with it.. :)
Also, I think we should still mock the request stack etc... The view executable factory is the class under test here.
Comment #13
znerol commentedSorry for that. The last part of my comment was meant as a pointer for a follow-up, but I failed to state that explicitely.
I disagree. We do not have to expect any side effects from using them directly.
Comment #14
damiankloip commentedWell you mock things so you can set up expectations etc... too, but whatever.
Looks like we are going with the bigger issue now :)
Comment #15
znerol commentedgetRequest()->requestI agree in general. In this case the expectations do not contribute to the test coverage. On the other hand using
RequestandRequestStackdirectly improves readability a lot.Comment #16
dawehner@damian
Would you recommend to split up the issue and not convert all the request instances?
I kind of like to not use mocking for request/request-stack as they are kind of a value object, not external dependencies.
Comment #17
damiankloip commentedOK, let's move on from the test issue. It was just meant to be a small/quick test.
We might as well just carry on with this conversion now I guess!
Comment #18
damiankloip commented10: vdc-2261181-10.patch queued for re-testing.
Comment #20
damiankloip commentedReroll.
Comment #21
znerol commentedThere is still
$this->view->getRequest()->request->get('form_id')incore/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php(see #15). It should be$this->view->getRequest()->get('form_id').Comment #22
znerol commentedOh, ignore #21, I'm blind.
Comment #24
damiankloip commentedI think we have a problem with cloned views. No request gets set on those.
Comment #26
damiankloip commentedAh! destroy.
Comment #28
damiankloip commentedComment #29
dawehnerAwesome!!
Comment #30
catchCommitted/pushed to 8.x, thanks!