Follow-up to #2472323: Move modal / dialog to query parameters
Problem/Motivation
As noted in the issue this follows up, "we use accept headers both for routing, but also for a way to convert the result of the current controller into a different format like a modal, dialog or ajax". The issue was closed without all of the problems fixed, notably the third item:
- Convert the various tests to use query parameters ...
AJAX Views tests in core/modules/views/src/Tests/ViewAjaxTest.php need to be updated so that any AJAX responses with an accept header of "application/vnd.drupal-ajax" are replaced with the query parameter _wrapper_format. As of this writing, there is only one response request that needs the fix.
Proposed resolution
In core/modules/views/src/Tests/ViewAjaxTest.php, look for "application/vnd.drupal-ajax." (grep -Ern "vnd\.drupal" core). Then do the following:
1. Replace 'application/vnd-drupal-ajax' with an empty string:
(e.g.)
$response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post);
becomes
$response = $this->drupalPost($quickedit_uri, '', $post);
2. Add query string array to the end of drupalPost. e.g.
$response = $this->drupalPost($quickedit_uri, '', $post);
becomes
$response = $this->drupalPost($quickedit_uri, '', $post, array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax')));
Remaining tasks
| Task | Novice task? | Contributor instructions | Complete? |
|---|---|---|---|
| Create a patch | Novice | Instructions | No |
| Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Novice | Instructions | No |
User interface changes
None
API changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | reroll-2488710-19.patch | 934 bytes | vg3095 |
| #3 | views-update_test_in_views_module-2488710-3.patch | 728 bytes | greendemiurge |
Comments
Comment #1
wheatpenny commentedCurrent line number: core/modules/views/src/Tests/ViewAjaxTest.php:54:
Comment #2
greendemiurge commentedI will begin work on this as part of the Drupalcon 2015 Core mentored sprint.
Comment #3
greendemiurge commentedThis patch implements the solution detailed above.
Comment #4
jasonmce commentedI'm going to take a swing at reviewing this as part of the Drupalcon 2015 Core mentored sprint.
Comment #5
ericski commentedRTBC
Patch applies cleanly on current HEAD, fixes issue as described in proposed solution.
Comment #7
ericski commentedWaiting on information coming from issue #2488696: Update tests in editor module before revisiting this issue
Comment #8
ericski commentedOriginal patch was close, just needed to add a use statement for MainContentViewSubscriber class
Comment #10
ericski commentedOops! did a reverse patch, sorry about that, here's the right one!
Comment #11
greendemiurge commentedI am going to update this to make it conform to coding standards.
Comment #12
greendemiurge commentedThis re-rolls #2488710-10: Update AJAX requests in views module tests to put the array on multiple lines in according with the coding standards: https://www.drupal.org/coding-standards#array.
Comment #13
jasonmce commentedPatch at #2488710-12: Update AJAX requests in views module tests performed as expected. Waiting for Testbot to agree, and then I will mark it RTBC.
Comment #15
jasonmce commentedWhitebox tested : stepped through execution with @greendemiurge. Verified that new code passes more appropriate values to drupalPost(). Response matched expected results and passed final validation.
Comment #17
xjmThanks for the patch and also especially for documenting your testing steps.
The issue summary here doesn't entirely help me understand why this change is needed. I also checked the parent issue in #2472323: Move modal / dialog to query parameters and didn't see anything there about this issue being filed. So tagging for an issue summary update.
I showed this to @dawehner and he is also not sure it is the correct fix.
Also, in general, it would be better to make all the fixes for one conceptual scope in one patch, rather than splitting up patches per module (as is being done with the related issues #2488696: Update tests in editor module and #2488448: Update tests in QuickEdit module). Would it make sense to merge these into one patch, since they're all essentially the same change and would have the same summary?
Finally, the title of this issue is terrifying. ;) Let's update it for what specifically we need to update.
Comment #18
xjmSomething like that maybe.
Comment #19
vg3095 commentedPatch did not apply
So I updated the patch.
Comment #21
petedussin commentedUpdating the Issues summary as per xim's request. The parent issue was already closed, and the work for parallel issue Update tests in editor module (2488696) is in progress as well.
Comment #24
zeip commentedSeems to me that these changes have already been done in commit 22c915f3 for issue #2502865: Remove all remaining usages of the drupal_ajax accept header. Closing as duplicate.