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)
Convert
All tests except:
- FileManagedFileElementTest should be split into javascript and BTB test #2809505: Convert AJAX part of \Drupal\file\Tests\FileManagedFileElementTest::testManagedFile to JavascriptTestBase
- FileFieldWidgetTest should be split into Javascript and BTB test #2809503: Convert AJAX part of \Drupal\file\Tests\FileFieldWidgetTest to JavascriptTestBase
Comment | File | Size | Author |
---|---|---|---|
#60 | interdiff-2870448-53-60.txt | 2.73 KB | yogeshmpawar |
#60 | 2870448-60.patch | 27.05 KB | yogeshmpawar |
#53 | interdiff-52-53.txt | 6.4 KB | Anonymous (not verified) |
#53 | 2870448-53.patch | 27.09 KB | Anonymous (not verified) |
#52 | interdiff-51-52.txt | 5.35 KB | Anonymous (not verified) |
Comments
Comment #2
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #3
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #4
dawehnerWe could convert part of the tests (aka. the tests which don't depend on views) already.
Comment #5
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedIt's true that we can do a partial convert but getting views in first would enable this issue to be converted in 1 go. To prevent a lot of spin-offs I postponed all issues that require base classes from other issues. A lot of them will be solved with getting views in though.
The way I see it the conversion can already be started but has to wait on the Views issue before it can be finished. Is that workable?
Comment #6
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedDiscussed on IRC and we decided to place all tests that have a non-converted base class out of scope. Updated the IS to reflect that.
Comment #7
naveenvalechaHere's the start. This patch should fail.
FileFieldTestBase class has functions(assertFileExists & assertFileNotExists) which PHPUnit_Framework_TestCase class also have static methods. We need to rename these methods from FileFieldTestBase class as we couldn't rely on the PHPUnit_Framework_TestCase assert methods directly. Because PHPUnit_Framework_TestCase assertFileExists expects $filename to be string. However in FileFieldTestBase its a file object.
//Naveen
Comment #8
naveenvalechaHere's the new patch which renamed the FileFieldTestBase methods
assertFileExists to assertFileExistsOnDisk
assertFileNotExists to assertFileNotExistsOnDisk
Next item:
- FileManagedFileElementTest should be split into javascript and BTB test
- FileFieldWidgetTest should be split into Javascript and BTB test
Remove these tests from this patch.
//Naveen
Comment #9
naveenvalechaHere we go with more fixes and removed the FileManagedFileElementTest & FileFieldWidgetTest from this converstion patch.
//Naveen
Comment #11
naveenvalechaComment #14
naveenvalechaComment #15
naveenvalechaFew more fixes.
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commentedI'm working on #2809503: Convert AJAX part of \Drupal\file\Tests\FileFieldWidgetTest to JavascriptTestBase, some part from there can be useful here.
Comment #20
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #22
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #23
Anonymous (not verified) CreditAttribution: Anonymous commentedSeparate issue for drupalPostFormHack() #2917885: Add drupalPostFormWithInvalidOptions() to BrowserTestBase.
Comment #24
Anonymous (not verified) CreditAttribution: Anonymous commentedPatch with #2917885: Add drupalPostFormWithInvalidOptions() to BrowserTestBase and #2919352: Move methods from FileFieldTestBase to Trait.
Revert #8, because we looks like we not need to do it here. FileFieldTestBase override assertFileExists, and can works with objects.
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commentedAdded mark [PP-2], but not changed status, because maybe not everything is ready.
Comment #27
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #29
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #30
dawehnerNice progress!
Why do we switch from equals to contains?
This new method is used for
\Drupal\file\Tests\DownloadTest::testFileCreateUrl
which could be actually a kernel test, couldn't it? What about filing a follow up?🙃 Let's skip this additional new line :)
I'm curious ... why is this $edit an invalid value here?
doesn't look too invalid for me, sorry for the dump question. This was done in #18 without much of an explanation.
Comment #31
Anonymous (not verified) CreditAttribution: Anonymous commentedGreat points as always!
30.1: done.
30.2: follow up or fix it here - both variants ok for me.
30.3: done.
30.4: done, I really overdid it with a replacement)
Comment #33
Anonymous (not verified) CreditAttribution: Anonymous commentedopps.
Comment #34
dawehnerDo you mind creating a follow up?
Comment #35
Anonymous (not verified) CreditAttribution: Anonymous commentedSure, done #2919872: Move part of DownloadTest::testFileCreateUrl() to a new Kernel test.
Comment #36
dawehnerThank you!
Comment #37
Anonymous (not verified) CreditAttribution: Anonymous commented@dawehner, thank you so much too!
Current patch contains two additional chunks from next issues:
I'm going to close first chunk as duplicate, because it's just a transfer of methods from the Class to the Trait. It's much better to do it right here to get a good test coverage.
But the second chunk is a trait with a new method, which most likely will need to be added separately. Therefore, I will add an additional test coverage there. And while to postpone this issue like [PP-1]. Correctly?
Comment #38
Anonymous (not verified) CreditAttribution: Anonymous commentedI took the
Drupal\file\Tests\FileFieldDisplayTest::testNodeDisplay()
to extend the test coverage ofdrupalPostFormWithInvalidOptions()
, and came across an interesting thing.Why we cann't use BTB::drupalPostForm() here?
Because
$field_name . '[1][display]'
not found.But why?
Because we add new file in 'Preview' request directly.
Okay. But then we go back and check both:
What do we want to get with these asserts?
By message, that both files 'appears as expected'.
But only the first file does exist. No second file.
$this->assertRaw($field_name . '[1][display]', 'Second file appears as expected.');
This assert is passed only because the upload form already has a hidden display field with that name. It's enough to check exist of
$field_name. '[1] [description]'
or directly the second file itself, for confirm it.And what suggestions?
For check the work without saving form, we can to do 'Upload' request, and only then to do 'Preview' request. Like last part of
testAddValuesForFieldWithExistValues()
in #2917885-24: Add drupalPostFormWithInvalidOptions() to BrowserTestBase.Comment #39
Anonymous (not verified) CreditAttribution: Anonymous commentedHere's what I proposed to do in #38. Now the test works correctly with
drupalPostForm()
too.Comment #41
Anonymous (not verified) CreditAttribution: Anonymous commentedReroll after #1472946: Remove usages of deprecated function drupal_realpath() throughout core functions and #2919872: Move part of DownloadTest::testFileCreateUrl() to a new Kernel test.
Comment #42
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdated with latest version
DrupalPostFormWithInvalidOptionsTrait
from #2917885: Add drupalPostFormWithInvalidOptions() to BrowserTestBase.The changes are not very readable, so here's a quick review:
Comment #44
dawehnerWhat about setting
['http_errors ' => FALSE]
in guzzle? Wouldn't this be way more readable overall?Comment #45
Anonymous (not verified) CreditAttribution: Anonymous commented#44 it is nice idea! Thank you, @dawehner!
Comment #47
Anonymous (not verified) CreditAttribution: Anonymous commentedAfter epic #2346893: Duplicate AJAX wrapper around a file field we have one js-test
FileFieldValidateTest::testAJAXValidationMessage()
.How to do better?
FileFieldValidateTest::testAJAXValidationMessage()
to JTB test here.Comment #48
Anonymous (not verified) CreditAttribution: Anonymous commented#47: FileFieldValidateTest::testAJAXValidationMessage() leave in WTB.
Replaced #2917885: Add drupalPostFormWithInvalidOptions() to BrowserTestBase on simplified version in BTB. BTB place because:
Both of them need in drupalPostFormWithInvalidOptions(). Other issues can be also need this API (example, #2949091: Multiple file field with all file extensions does not work).
Also removed extra parameter in
FileFieldTestBase::uploadNodeFiles()
. This parameter needs for #2809503: Convert AJAX part of \Drupal\file\Tests\FileFieldWidgetTest to JavascriptTestBase, but not now.Comment #50
Anonymous (not verified) CreditAttribution: Anonymous commentedOpps, one unrelated change. (Edit: please ignore, incorrect branch compare
Also strange, that the test run time increased by 5 minutes o_O.)BTB::drupalPostForm()
much slower thanWTB::drupalPostForm()
?Comment #51
Anonymous (not verified) CreditAttribution: Anonymous commentedMeh, decople FileFieldValidateTest looks ugly here, file to #2950187: Convert AJAX part of \Drupal\file\Tests\FileFieldValidateTest::testAJAXValidationMessage to JavascriptTestBase by analogy with other cases in IS.
Nit clean up.
Now the conversion is almost straight. But a couple of places:
See #38.
Perhaps it's too arrogant to add this helper method right here, but who will tell me the best place?
Comment #52
Anonymous (not verified) CreditAttribution: Anonymous commentedReroll after #2864035: Convert web tests to browser tests for rdf module.
Now without extra fixes in FileFieldTestBase, without new Trait, without new method in BrowserTestBase.
Comment #53
Anonymous (not verified) CreditAttribution: Anonymous commentedTook the FileFieldValidateTest from #2950187: Convert AJAX part of \Drupal\file\Tests\FileFieldValidateTest::testAJAXValidationMessage to JavascriptTestBase, because it is trivial convertion.
Created CR + updated
@trigger_error
message.Converted *Update* test (trivial changes in path to fixtures).
Comment #54
Anonymous (not verified) CreditAttribution: Anonymous commentedFrom CR (or trigger_error):
But we definitely need to convert the api-methods from the FileFieldTestBase class to the trait. Example for create JTB tests like #2809503: Convert AJAX part of \Drupal\file\Tests\FileFieldWidgetTest to JavascriptTestBase.
It may be better to move this class to trait right now, for avoid one more record like:
?
Comment #55
Anonymous (not verified) CreditAttribution: Anonymous commented#54: opps, I am lol. Move methods from class to trait does not mean, that class will be deprecated :)
So, we can make trait late.
Comment #56
borisson_This looks great, I found a couple of places where we're using a
t(
where it's not needed, but since this is just a conversion, we should just do this and fix those later, if we get a phpcs rule for it.Comment #57
alexpottWhy are we getting the client in different ways? Let's pick one.
to set
I think.Comment #58
Lendude#57.1 can now use #2911915: Add getHttpClient() to BrowserTestBase!
Comment #59
yogeshmpawarComment #60
yogeshmpawarAddressed changes mentioned in #57 by @alexpott & Thanks @Lendude for pointing out.
Added updated patch with an interdiff.
Comment #61
LendudeThanks @yogeshmpawar! Feedback has been addressed, back to RTBC.
Comment #62
alexpottCommitted 6312fcb and pushed to 8.6.x. Thanks!
Comment #64
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedParent issue was set to #2870441: Convert web tests to browser tests for content_translation module but this looks like a mistake?
Changed parent to #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)
Comment #66
quietone CreditAttribution: quietone at PreviousNext commentedpublish the change record