Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There are two fake mocks used in AjaxCommandsTest
that can be completely removed if PHPUnit mocks are used instead.
Proposed resolution
Remove the fake mock classes:
Drupal\Core\Ajax\OpenDialogCommand
Drupal\Core\Ajax\OpenModalDialogCommand
and replace with PHPUnit mocks.
Remaining tasks
None.
User interface changes
No.
API changes
No.
Beta phase evaluation
Issue category | Task |
---|---|
Unfrozen changes | Unfrozen because it only changes internal unit test code. |
Prioritized changes | The main goal of this issue is to clean up some code in unit tests, and it removes custom objects that are not needed. |
Comment | File | Size | Author |
---|---|---|---|
#12 | 2250165-ajaxcommandtest-native-stub.patch | 3.09 KB | neclimdul |
#11 | 2250165-interdiff.txt | 906 bytes | neclimdul |
Comments
Comment #1
YesCT CreditAttribution: YesCT commentedComment #2
YesCT CreditAttribution: YesCT commentedComment #3
cs_shadow CreditAttribution: cs_shadow commentedReplaced {@inheritdoc} on the two classes with actual documentation.
Comment #4
cs_shadow CreditAttribution: cs_shadow commentedComment #5
YesCT CreditAttribution: YesCT commentedmaybe we should look at the usages of TestOpenDialogCommand to help us know what it does and why. (and/or use git blame or git log -S to help us find the issue that put it there. that might also help with it's summary)
We might actually just be able to delete the {@inheritdoc} (and the newline), if the Wraps .... line is sufficient to tell us a one line summary of what this class is doing.
Although the classes it is extending does more than just provide the drupalAttachLibrary()
Since the class is Test...
I kind of expected the docs to mention Tests or testing.
Comment #6
andriyun CreditAttribution: andriyun commentedComment #7
tetranz CreditAttribution: tetranz commentedComment #8
neclimdulHere's a patch using phpunit's native stubs to null the method.
Comment #9
neclimdulComment #10
tetranz CreditAttribution: tetranz commentedComment #11
neclimdulnice, thanks tetranz. Based on that discussion, documentation on why we are faking those methods.
Comment #12
neclimdulbah, interdiff is correct, patch missing changes though.
Comment #13
YesCT CreditAttribution: YesCT commentedthe test says it tests if they can be rendered... but the comment sounds like we are not testing that.
Maybe we should update the comment and open an issue to add render testing?
Comment #14
YesCT CreditAttribution: YesCT commentedtagging phpunit
Comment #15
tvn CreditAttribution: tvn commentedComment #16
jhodgdonThis is no longer a Docs issue.
Comment #17
neclimdulI've struggled with how to document this. The drupal_render() call being nulled here is not really about rendering but passing things into drupal_process_attached(). I'm not familiar enough with the code to say why it isn't relevant to this test or how to document it.
Comment #18
jhedstromMocking methods that call other code is pretty typical. I don't think our unit test here needs to also test rendering.
Replacing these placeholder objects with mocks removes a bunch of code we don't have to maintain. I've added a beta evaluation to the summary.
Comment #19
alexpottThe issue summary and the patch don't agree...
Comment #20
jhedstromIt looks like the summary was never updated after the change in direction in #7. I've updated the summary.
Comment #21
jhedstromComment #22
alexpottCommitted 1f43f1b and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation for to the issue summary.
Comment #23
tim.plunkettThis didn't make it to d.o
Comment #24
webchickLet's try that again...