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
Right now we aren't taking advantage of mink or phpunit. We should attempt to move the current tests to BTB where possible.
Proposed resolution
Move to BTB.
Remaining tasks
Patch. Possibly test per issue?
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#27 | 2796901_27.patch | 547 bytes | slashrsm |
| |||
#23 | interdiff.txt | 35.95 KB | marcoscano |
#23 | 2796901-23.patch | 81.42 KB | marcoscano |
| |||
#18 | 2796901-17.patch | 78.65 KB | marcoscano |
| |||
#17 | 2796901-17.patch | 75.53 KB | marcoscano |
|
Comments
Comment #2
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedUpdate: I can also see quite a bit of functionality being tested in both MediaUiTest and BasicTest. I think we should move to utility traits for everything common between our tests and try to make them a little more granular. Lots of test classes makes it really obvious where to expand on further testing for a feature and I think encourages more complete coverage, as you're never in a situation where you feel like you are over stepping your mark for a particular test class (ie, how much more complicated should I make "BasicTest" really?).
Comment #3
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThe scope of this is increasing.. probably best to make this a meta.
Comment #4
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedThis would make a lot of sense. We can use this ticket to plan and than create patches for each step in sub-ticket (as @Sam152 already proposed).
Comment #5
marcoscanoworking on this
Comment #6
marcoscanoWIP
Still missing:
- MediaViewsWizardTest
- MediaViewsBulkFormTest
- Any other new test we want to implement to increase coverage (for instance IEF integration, etc)
will be working on this soon
Comment #7
marcoscanoAll existing web tests were converted, and additional tests were created for the IEF integration.
The resulting test classes are:
Do we want anything else to increase coverage?
Comment #10
marcoscanoAll tests pass locally... anyone has any suggestion on what I should look for to try to fix the failure with the testbot?
Thanks!
Comment #11
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedYou can use ->clickLink('some label');
> a[href="/admin/structure/media/manage...
This doesn't work because the bot installs in a sub-directory, so all of the links are not relative to "/".
Comment #12
marcoscanoThanks for the tip @Sam152 !
Comment #13
marcoscanoReviewing the diff I realized that for some reason (probably copy/paste fail) I had left out a good chunk of the previous MediaUITest, sorry about that. Now it includes everything.
There was some duplicated code in MediaUITest (covered also in the ViewsWizardTest), and also this test is quite big, we could probably split it into smaller ones, but I left everything in a single file to make reviewing of the patch (comparing with the previous test) easier.
Comment #14
marcoscanoRe-rolled and chased changes in 2806611-12
Comment #15
marcoscanoCreated a PR for the same patch in #14 for easier review on github:
https://github.com/drupal-media/media_entity/pull/81
Comment #16
CTaPByK CreditAttribution: CTaPByK at MD Systems GmbH commentedGreat work @marcoscano.
Patch is huge and i tried to focus on main functionality and compare test methods with original test methods, just to make sure we don't miss something.
So, here we are:
This test method from old test is merged somewhere or we miss him?
Same here. I don't see this method in new tests.
We missing filter for second bundle in new test. Yes it's same as the first, but we need to keep him i think.
Why we changed those messages? :) Original messages are not clear?
Comment #17
marcoscanoThanks @CTaPByK for reviewing!
Another copy/paste fail! :( Sorry about that. Corrected in the attached patch.
This code duplicated some of the code in the old WizardTest.php, so there is only one test after the conversion.
I'm not sure to completely understand your feedback here. The new version of the mentioned code is testing whether the filtered value is present (first item), and that the second value (filtered out) is not present in the page. What else should we test?
In phpunit, differently from simpletest assertion messages, the optional messages that most asserts accept will be printed in case of failure, not on success. That's why we need to update the message strings, at least to negate the sentence.
Just for reference, the current test classes after the conversion are:
Comment #18
marcoscanointerdiffed correctly but messed up generating the actual patch... #facepalm
Comment #19
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedComment #21
CTaPByK CreditAttribution: CTaPByK at MD Systems GmbH commentedJust one nutpick:
Unused variables.
Other then that, looks great.
Comment #22
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedGreat work! Just a few suggestions for performance improvements and things related to plans for core:
This could be a kernel test, which would speed it up significantly.
This can be browser test. It doesn't need JS it seems.
This could be BrowserTest as well.
Let's add storage as a class member. Then this becomes
$this->storage->loadUnchanged()
and we can remove the helper function.Since this wraps a one-liner lets just remove it.
Taking plans to move ME to core into consideraton I think that we need to remove this.
Let's move this to setUp().
I think that this two don't need JS. Since the other test function in this class does it would make sense to split and move this two into a BrowserTest.
Comment #23
marcoscanoThanks for reviewing!
It is true that after re-organizing the tests in Kernel/Browser/Javascript, some of the previous code distribution changed a bit (base classes, traits, etc). I hope the result makes sense, more or less...
The final structure of the test classes after the re-organization is:
Comment #24
marcoscanoComment #26
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedCommitted. Thanks!
Comment #27
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedNoticed a nit.
Comment #29
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commented