In Scope:
./Condition/ConditionFormTest.php
./Form/AlterTest.php
./Form/ArbitraryRebuildTest.php
./Form/CheckboxTest.php
./Form/ConfirmFormTest.php
./Form/ElementsLabelsTest.php
./Form/ElementsVerticalTabsTest.php
./Form/ElementTest.php
./Form/EmailTest.php
./Form/FormStoragePageCacheTest.php
./Form/FormTest.php
./Form/LanguageSelectElementTest.php
./Form/ProgrammaticTest.php
./Form/ResponseTest.php
./Form/StateValuesCleanAdvancedTest.php
./Form/StateValuesCleanTest.php
./Form/StubForm.php
./Form/SystemConfigFormTest.php
./Form/UrlTest.php
./Form/ValidationTest.php
Out of Scope:
- Drupal\system\Tests\Form\ElementsTableSelectTest should be split into JTB and BTB
- Drupal\system\Tests\Form\RebuildTest should be split into JTB and BTB
- Drupal\system\Tests\Form\StorageTest should be split into JTB and BTB
- Drupal\system\Tests\Form\TriggeringElementTest discuss to do the changes in BTB drupalPostForm and handle the exceptions there like WTB
| Comment | File | Size | Author |
|---|---|---|---|
| #39 | 2867154-31.patch | 44.05 KB | lendude |
| #31 | 2867154-31.patch | 44.05 KB | lendude |
| #31 | interdiff-2867154-27-31.txt | 926 bytes | lendude |
| #27 | 2867154-27.patch | 43.59 KB | manuel garcia |
| #27 | interdiff.txt | 501 bytes | manuel garcia |
Comments
Comment #2
jhedstromI was hoping that
SystemConfigFormTestBasecould be converted to a kernel test, but in some of the tests extending that, there are browser requests. For instance, inFormObjectTestSince this goes beyond the initial intent of
SystemConfigFormTestBase, those could either be refactored to check directly in a kernel test, or moved to a separate functional test...Comment #3
michielnugter commentedComment #4
phenaproximaI converted a few of the tests -- namely, the ones that didn't break in some scary way upon conversion to BrowserTestBase. :) Namely:
Comment #6
michielnugter commentedThink this is the best conversion for hidden fields on Mink. I looked to see if there are other ways but this seems the best way. With the comments explaining it I think we have a good way forward on hidden fields.
Rest of the patch looks good so far, nice minimal changes.
And the fail:
Checked this one but can't see the reason yet, haven't dug deep though..
Comment #7
phenaproximaI've made further progress on converting these tests, so I'm assigning this to myself for now.
Comment #8
phenaproximaMore progress!
Some of the existing tests use AJAX methods, or are otherwise super-awkward to convert, so I'm going to convert those later. But as of this, I'd say about 80% of the form tests are done!
Not bothering with an interdiff because there are so many changes that it'd be kinda pointless. :)
Comment #9
naveenvalechaNice progress. Setting it to N/R to see where testbot fails?
We're doing the conversion of Ajax tests in follow-up if they are not too straightforward.
Comment #11
naveenvalechaHere's More progress. Converted more tests. Updated IS according the conversion in the patch. Few failing tests will look into these later today.
Failing Tests:
1)
TriggeringElementTest::testAttemptAccessControlBypass is failing while setting the name of the input field name, but at Mink NodeElement we don't have the option to set the name of any field.
$elements[0]['name'] = 'button1';2)
TriggeringElementTest::testNoButtonInfoInPost is failing as the error handing in WTB drupalPostForm is different from BTB drupalPostForm. In BTB, it throws error if the button does not exists, so I think we should move it to follow-up issue to discuss it and then do the changes accordingly.
Comment #13
naveenvalechaHere's the green patch. Moved TriggeringElementTest back to WTB, see #11 for more details.
//Naveen
Comment #15
dawehnerNitpick: this is an unnecessary change
It feels like this test could actually be a kernel test, should we open up a follow up for that?
I'm curious whether for BC reasons it would actually make sense to return the HTML output here, much like
drupalGetdoes right now. Do you have an opinion about that?Maybe we could explain that behat/mink is meant to test normal user behaviour, instead of what we do here, which is abuser behaviour.
Comment #16
lendude#15.2 just checked
class ProgrammaticTest extends KernelTestBaseand it passes without any further changes, so lets not do it in a followup but do it hereno need for the string cast
Why can we remove this and still get an 'illegal choice'? That seems strange to me.
No need to cast to string
we usually go for protected any special reason not to do so here?
Comment #17
phenaproxima@Lendude:
I had no choice but to remove that, because Mink has no setAttribute() method for manipulating the DOM tree generically. The equivalent forgery-making happens in the actual form class now -- I added a #post_render callback function to change the value of the checkbox after the form is rendered, resulting in the illegal choice.
Comment #18
lendude@phenaproxima++
Those two things are so far apart in the patch that I'd forgotten about that change by the time I got to reviewing the relevant test bit :)
Since that test is really about catching DOM manipulations, shouldn't we have a javascript test that does this? Now that test feels more about catching people doing weird stuff in their PHP code then about catching client side forgeries. I don't think we're losing any coverage here, the original test was just simulating too, but might be worth a follow up to do some real client side forging.
Really great work on this btw, this is not a straight forward one.
Comment #20
manuel garcia commentedSome progress:
Still to address/answer:
Comment #21
manuel garcia commentedApologies, forgot to move
ProgrammaticTestintocore/modules/system/tests/src/Kernel/Form/in last patch, doing it now.Comment #22
lendude@Manuel Garcia some workflow stuff got into the patch in #21
Comment #23
manuel garcia commentedThanks @Lendude - clearly I need to improve my patch juggling skills...
Here is the correct patch, interdiff on #21 is correct.
Comment #25
manuel garcia commentedComment #27
manuel garcia commentedwrong namespace :-s
Comment #28
lendudeCreated a follow-up for the remaining tests, #2900291: Form: Convert system functional tests to phpunit Part 2
About the remaining questions:
#15.3 Opened #2900292: For BC purposes \Drupal\Tests\BrowserTestBase::drupalPostForm should return the HTML of the rendered page, this is a fairly trivial change, so don't think we need to postpone on this
#15.4 I think that should just be general knowledge, so I think we should add the user/abuser to https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial or something, adding it in a comment here seems a little low impact
#16.2 follow up for additional coverage #2900294: Add javascript test to supplement FormTest::testInputForgery
I think this is ready
Comment #29
larowlannice!
I think we should add a @see back to the postRender ^ so that its clear what is going on.
Comment #30
larowlanFor #29.2 - the input forgery is important from a security standpoint so I think docs gate is enough to block commit
After that - good to go.
I'd also expect that a lot of these can be converted to kernel tests ala PathElementTest but that's obviously out of scope here and future enhancements.
Comment #31
lendude@larowlan thanks for the feedback.
Updated the existing @see on the test method which was referencing _form_test_input_forgery() which probably hasn't existed for 5+ years, added an explanation and a @see back to the post render.
Comment #33
Anonymous (not verified) commentedThe patch broke after #2868019: AssertLegacyTrait field assertions not compatible with Simpletest assertions.
Before:
After:
Ie. before:
getValue(), after:getText().But the getText() cuts the '\n':
Comment #35
Anonymous (not verified) commentedOpps, strict '===' not suitable here, because sometimes
$valueis object, like TranslatableMarkup.Comment #37
Anonymous (not verified) commentedWell, I already bit muddied the logic 😯. Roll back to #31 and try again.
Comment #38
lendude@vaplas I agree we need that change to assertFieldByName but doing it here is too much creep. We need a follow up to #2868019: AssertLegacyTrait field assertions not compatible with Simpletest assertions or even a roll back since we broke BC, but lets not do that change in this issue.
#31 should work.
Comment #39
lendude#2868019: AssertLegacyTrait field assertions not compatible with Simpletest assertions was reverted, reupping #31, since this should now be green.
Comment #40
Anonymous (not verified) commentedThank you @Lendude! Now I will know how to act in such situations. Please do not add credit to me in this issue, because I get credit for these patches in the appropriate issue.
NB: points from #30 are addressed in #31. So +1 to RTBC.
Comment #41
jibranBack to RTBC.
Comment #44
larowlanGold!
Committed as cfbe5da and pushed to 8.5.x.
Cherry-picked as 4bcd0ea and pushed to 8.4.x
More down!
Comment #46
jhedstromFor folks coming to this issue by searching
SystemConfigFormTestBasenote that this did not actually convert that. I'd guess this would be targeted for #2900291: Form: Convert system functional tests to phpunit Part 2...