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.
See #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase).
Extensive testing was done for dealing with the image uploads by @vaplas in #51-#61 and the most lightweight solution was chosen.
Out of Scope:
#2959466: Convert web tests to browser tests for image module (Part 2)
- ImageAdminStylesTest should be split into JTB and BTB
- ImageFieldValidateTest should be split into JTB and BTB
Comment | File | Size | Author |
---|---|---|---|
#85 | interdiff-71-85.txt | 2.82 KB | Anonymous (not verified) |
#85 | 2863626-85.patch | 86.12 KB | Anonymous (not verified) |
#74 | 2863626-71-only-for-compare.txt | 34.34 KB | Anonymous (not verified) |
#71 | 2863626-71.patch | 87.07 KB | mondrake |
#71 | interdiff_69-71.txt | 1.21 KB | mondrake |
Comments
Comment #2
scuba_flyComment #3
jofitz CreditAttribution: jofitz at ComputerMinds commentedComment #4
scuba_flyThis patch is not finnished yet.
I'm running into some issues, which I will list once the patch is tested.
Comment #5
scuba_flyStarting the test.
Comment #7
nlisgo CreditAttribution: nlisgo commentedThe namespace needs to be changed to:
Comment #8
nlisgo CreditAttribution: nlisgo commentedComment #9
nlisgo CreditAttribution: nlisgo commentedComment #11
jofitz CreditAttribution: jofitz at ComputerMinds commentedAdded methods to replicate WTB's method drupalGetJSON().
Comment #13
claudiu.cristeaAt least fix the
::drupalBuildEntityView()
problem.Comment #15
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #16
naveenvalechaComment #17
naveenvalechaHere's the straight reroll of the #13. Removed EntityTestTrait as drupalbuildEntityView is already added as part of #2795051: Move \Drupal\simpletest\WebTestBase::drupalBuildEntityView into a trait and make it available in BTB
//Naveen
Comment #18
naveenvalechaComment #20
naveenvalecha- ImageAdminStylesTest should be split into JTB and BTB
//Naveen
Comment #22
scuba_flyComment #24
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedMany of the test failures are
which is easy to fix, because the patch was created before #2068063: Change "Save and keep un-/published" buttons to a "Published" checkbox and an included "Save" button. Is anyone working on this? If not I will re-roll, as this issue is holding up #2864035: Convert web tests to browser tests for rdf module
Comment #25
wengerkI'm working on it with @gido during the DrupalConEu at Vienna.
Comment #26
dawehner@wengerk
In this case please assign the issue to yourself :) Thank you.
Comment #27
wengerkassign to myself as suggested :D.
Comment #28
wengerkI re-roll the patch in #20 to works on Drupal 8.5.x and the publish/save buttons as mentioned in #24.
But now, I'm facing an issue with the next test, when running locally, which can't found some field to remove the default image.
When debugging it seems the user don't get the correct form, Field Image storage, but only the Log In one :/ very strange.
Comment #29
wengerkComment #30
wengerkIt looks like the CI make the tests pass, it was maybe an error on my local env.
Comment #31
wengerkComment #32
dawehner@wengerk
Do you mind configuring your local git to detect renames, see https://www.drupal.org/node/1666604
This can dramatically reduce the size of the patch file.
Comment #33
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commented@wengerk - as an alternative you can use
-M80% --find-copies
in yourgit diff
command instead of doing the config change. The % number after M allows the copied file to vary by this percentage and git will still recognise it as a copy. For an example, see the start of https://www.drupal.org/files/issues/2870439-42.patchComment #34
wengerkI just re-read the previous patch in #20 & I figured out I completely messed it up with mine in #28.
I re-rerolled the patch, using the
[diff] renames = copies
for renaming Thanks @dawehner & @jonathan1055..The test on my local env. didn't works with an issue:
I unfortunately no time to work on this now, maybe someone could ?
Run using:
SIMPLETEST_DB="sqlite://localhost//tmp/test.sqlite" SIMPLETEST_BASE_URL='http://d8.dev' ./vendor/bin/phpunit -c core --group image --printer="\Drupal\Tests\Listeners\HtmlOutputPrinter" --stop-on-error
Comment #36
wengerkComment #37
wengerkI fixed the tests, it crash but intended by design of Mink.
The tests try to fill a hidden field but Mink is user+browser emulator. It emulates everything, that real user can do in real browser. And user surely can't fill hidden fields on the page - he just don't see them.
It now fail on another tests, I still upload my "wip" patch and I'm now working on the new failling one.
Comment #38
wengerkComment #39
wengerkComment #40
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHi wengerk,
Disregarding patch #28 which you told us to ignore, I have compared the previous patch #20 with yours in #34. I found that the only changes were:
There were no actual coding changes, which is good. So, starting from #34 (which is essentially at the same state of review as #20) could you provide an interdiff text file of what you have changed, so that reviewers can see what we should be looking for, and how the changes impact the result. It is confusing for reviewers that your patch in #37 passes, then with no further comment your patch in #39 (which you also named 37) fails.
Thanks for working on this. These are just suggestions to help make our reviews easier, and speed the progress of the issue.
Jonathan
Comment #41
wengerk@jonathan1055 thanks for your suggestion, here my explaination for the 2 same patch name :/ sorry.
In #37 I have made a first patch which was a broken one (I mean whitout the new files moved so the tests pass because they wasn't in the patch :/) I try to remove it from the issue but it seems the issue keep file in the history.
When I try to remove it I also re-upload a new one with the same name, I though it would be easier to have only 1 files with the name 37, I didn't know it was impossible to remove a previous posted patch).
I finally do some works and the patch has more tests which pass but still not all of them.
I'm now stuck cause some very old tests use legacy function
setRawContent
which has been deprecated & we have to rework the whole tests of/core/modules/image/tests/src/Functional/ImageThemeFunctionTest.php
.I have no time to work on it now, maybe some will continue.
Comment #42
wengerkThe patch #42 fix 2 new tests in the
core/modules/image/tests/src/Functional/QuickEditImageControllerTest.php
.Comment #43
wengerkComment #44
wengerkHere fixes for the
setRawContent
of/core/modules/image/tests/src/Functional/ImageThemeFunctionTest.php
.Comment #45
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHi wengerk,
Thank you for continuing to work on this.
Just an observation - your interdiffs are actually comparisions of the patch files. This is not actually what an interdiff is meant to be, it should show the change in source code line. The changes can be inferred from looking at yout interdiff, but it is much more complicated than it should be. Have a look at https://www.drupal.org/documentation/git/interdiff
If you want me to, I will make an interdiff from the above patches, to show you what they should look like. Let me know if that would help.
Jonathan
Comment #46
wengerkHi @jonathan1055,
Thanks for you help, I re-create the interdiff.
Comment #47
wengerkI don't understand why both tests testInvalidUpload & testValidImageUpload didn't works on the Drupal CI.
They run whitout probleme on my dev environment.
I run them using the
--filter
of phpunit such as:testInvalidUpload
SIMPLETEST_DB="sqlite://localhost//tmp/test.sqlite" SIMPLETEST_BASE_URL='http://d8.dev' ./vendor/bin/phpunit -c core --group image --printer="\Drupal\Tests\Listeners\HtmlOutputPrinter" --stop-on-error --filter testInvalidUpload
testValidImageUpload
SIMPLETEST_DB="sqlite://localhost//tmp/test.sqlite" SIMPLETEST_BASE_URL='http://d8.dev' ./vendor/bin/phpunit -c core --group image --printer="\Drupal\Tests\Listeners\HtmlOutputPrinter" --stop-on-error --filter testValidImageUpload
The dispatcher says:
testInvalidUpload
testValidImageUpload
It seems the
$response->getBody()->getContents()
in the/core/modules/image/tests/src/Functional/QuickEditImageControllerTest.php
return empty, but how is that possible ? If someone has a clue it would be great !edit:
Is that possible the following code would cause issue in the Drupal CI ?
Should I have to do something such as :
Comment #48
dawehner@wengerk
For these kind of issues I access Drupal also from a folder like
http://localhost/d8
or so.This way you have an environment which works more like the testbot.
Just some other random comments:
Note: You can use
assertNotContains
hereIs there a reason we cannot use the previous pattern aka. using
xpath
and counting the result?Comment #49
wengerk@dawehner
Thanks for you help !
It's not possible to use
assertNotContains
in the case N°1 cause I want to assert some binary string andassertNotContains
needs an UTF-8 string. So it crash when assertingchr()
.For the second case, It didn't work anymore with the old syntax
$this->xpath()
is not anymore available.Plus, the markup change & now when alt is NULL, the attribute is not anymore empty but missing so I fix it with a
not(alt)
.Comment #50
wizonesolutionsI use this class in contrib, and I'm getting the errors as well. It seems like that is not what's holding up this patch. What is the current issue? @wengerk @dawehner
Comment #51
LendudeThanks for the great work on this so far!
Needed a reroll, so no interdiff
ImageThemeFunctionTest had no business being a Functional test so converted that to a Kernel test, that takes care of #48.2
Ran QuickEditImageControllerTest locally on a $base_path different then '/', but still green. So haven't figured out what's going on there.
Comment #53
Anonymous (not verified) CreditAttribution: Anonymous commentedMaybe this?
Comment #55
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #57
Anonymous (not verified) CreditAttribution: Anonymous commentedThe last attempt, and I go to ignore issue :)
Comment #59
Anonymous (not verified) CreditAttribution: Anonymous commentedI started working on this in #2651860-19: Ignore, testing issue. Mink performs these requests correctly. But while I could not understand the reasons for this.
Comment #60
Lendude@vaplas++ great as always
Last thing I could see here was the Views tests not getting converted. Converted to a Kernel test here.
Comment #61
Anonymous (not verified) CreditAttribution: Anonymous commented@Lendude, thank you very much!
And found! The reason is end of stream!
Mr. Bot somewhere reads the stream, as result
$response->getBody()->getContents()
starts from end.String casting or seek(0) read the stream from startfirst and this solves the problem! (I steal it from Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase(), so @Wim Leers++)
Patch with demostration. I not sure what varaints better Mink or pure Guzzle request here.
Clever! We also have #2917885: Add drupalPostFormWithInvalidOptions() to BrowserTestBase, that can be useful for this.
And #2911915: Add getHttpClient() to BrowserTestBase, if we choose variant with guzzle client.
Comment #64
nlisgo CreditAttribution: nlisgo commentedComment #65
mohit1604 CreditAttribution: mohit1604 at Google Summer of Code commentedRerolled patch #60.
Comment #67
mondrakeRerolled #60, split
ImageFieldValidateTest
in a new functional test and 2 methods (testAJAXValidationMessage
andtestFriendlyAjaxValidation
) that remain in the W2B test that will have to be converted to FunctionalJavascript. Fixed 3 PHPCS errors.If this passes, I'd suggest to split
ImageAdminStylesTest
also in a B2B test and a part remaining in WTB that can be addressed as a separate FunctionalJavascript migration in a follow-up.Comment #68
mondrakeComment #69
mondrakeSplitting
ImageAdminStylesTest
in a B2B test and a part remaining in WTB. Fixed a couple oh PHPCS nits.Comment #71
mondrakeThis should fix the 2 xpath related failures.
Comment #72
Anonymous (not verified) CreditAttribution: Anonymous commented#71: Looks cool! RTBC +1. Also opened #2959466: Convert web tests to browser tests for image module (Part 2) for the remaining tests.
Comment #73
dawehnerMaybe it is just me, but I'd have kept about these helper functions. They might be used by a subclass.
Comment #74
Anonymous (not verified) CreditAttribution: Anonymous commentedThese methods were not affected :) But due to the fact that the #71 patch partially preserves the WTB test, it is not very readable.
Those they are removed at the beginning, and added later:
I attached version of #71 if remove all the remaining WTB tests and make
diff -M1
.Comment #75
LendudeFeedback has been addressed, followups have been created, this looks good to me. I think we've done everything possible to make this conversion as clean as possible.
Comment #76
dawehnerOh I see. Thank you for clarifying that.
Comment #77
alexpott\Drupal\Tests\BrowserTestBase::drupalGetJSON() and \Drupal\Tests\BrowserTestBase::drupalGetWithFormat()
I'm not sure about adding - the only usage of drupalGetWithFormat in either WTB or BTB is the respective drupalGetJSON function so at the very least I don't think we should be adding that.
drupalGetJson is used in \Drupal\Tests\image\Functional\QuickEditImageControllerTest::testFieldInfo() and \Drupal\taxonomy\Tests\TermAutocompleteTest::testAutocompleteCountResults(). I'm not sure these wrappers are really adding too much. Let's just do:
And not add the methods.
Comment #78
jibranThis change might break some contrib tests.
Comment #79
alexpott@jibran which change and why?
Comment #80
jibranI was just trying to point out that having
\Drupal\Tests\BrowserTestBase::drupalGetJSON()
and\Drupal\Tests\BrowserTestBase::drupalGetWithFormat()
will make the converstion of exsiting WTB tests in contrib a lot easier. OTOH not adding these methods to BTB and just creating a change notice will also suffice IMO.Comment #81
Anonymous (not verified) CreditAttribution: Anonymous commentedWhat if we adding
drupalGetJSON/drupalGetWithFormat
to special new Trait? This trait will be usefull for #2795041: BrowserTestBase: Add drupalPostWithFormat too. Because it is really unnecessary to give up the usual sugar, which can be a part of the conrib-test dishes :)Comment #82
alexpott@jibran so nothing is broken.
@vaplas / @jibran do you know how widely used WTB::drupalGetJSON() and WTB::drupalGetWithFormat() are in contrib? Also I have no idea why a change notice would be needed if we're not adding any methods to BrowserTestBase. Sugar is costly and needs to be maintained.
Comment #83
dawehnerThat is for sure a good point. I think though that it is not "a lot". Sometimes explicit code is better than implicit code :)
Comment #84
Anonymous (not verified) CreditAttribution: Anonymous commented#82:
If this is not a rhetorical question here is precise data right now in official contrib repositories:
WTB::drupalGetJSON():
WTB::drupalGetWithFormat():
#83:
It seems really so.
Comment #85
Anonymous (not verified) CreditAttribution: Anonymous commentedA hint from #77 is used. Thanks!
Comment #86
LendudeThanks for digging around and finding numbers on the usage of those methods, looks like not converting them makes sense.
All feedback has been addressed and we have a follow up for the remaining two tests in /core/modules/image/src/Tests
Comment #87
alexpottCommitted and pushed b89bd0c978 to 8.6.x and a3d45a6e1e to 8.5.x. Thanks!
Comment #91
gordon CreditAttribution: gordon at Heydon Consulting commentedReroll patch for work with 8.5.4
Comment #92
gordon CreditAttribution: gordon at Heydon Consulting commentedBrain Fart! Just ignore me!