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)
Now closed as duplicate in favour of #2870439: Convert web tests to browser tests for config module
Comment | File | Size | Author |
---|---|---|---|
#2 | convert_web_tests_to-2864026-2.patch | 14.18 KB | GoZ |
Comments
Comment #2
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedPatch does not convert all tests yet. Some work has to be done to complete this.
Tests importing configuration use DrupalPostAjaxForm() and should be converted to Javascript test base.
Comment #4
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedFail because of wtb assertCacheContext(). Postponed, waiting after #2795085: Add assertNoCacheTag to assertLegacyTrait commit.
Comment #5
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #7
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commented#2795085: Add assertNoCacheTag to assertLegacyTrait is in, so un-postponing this.
I am interested to hear yout thoughts on converting ConfigSingleImportExportTest::testExport() because it contains a call to getAllOptions() which was in
Drupal\simpletest\AssertContentTrait
but has not yet been moved intoDrupal\FunctionalTests\AssertLegacyTrait
(or to anywhere, infact). I need this function for converting WizardTest in #2866513-51: Convert web tests to browser tests for comment moduleI tried copying it into AssertLegacyTrait but the calling code needs some slight conversion, as the parameter $element from xpath is of the wrong class to that expected in the function definition.
Comment #8
LendudeFor ease of conversion/BC we might want to add
getAllOptions()
to AssertLegacyTrait, in that case we should open an issue for it and postpone on that, but....It's not used a lot, and I think it can be replaced by a one liner:
So is it really worth it? IMO it's also one of those methods that you would never look for if you didn't know it existed, so anybody not intimately familiar with the available methods would just use that one liner anyway.
Comment #9
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThanks Lendude. Yes, I spent some time trying to figure out how to get the options list, and was very pleased to discover the
->findAll()
method and get the test working before I saw your comment.With regard to copying/converting
getAllOptions()
to AssertLegacyTrait, it is only used in core tests in these two places (config and comment). I have searched the 28 modules for 8.x that I have on my local drive and only found it used once, in Token module. Is there a way to run a search on the contrib modules source code on drupal.org?I agree with you, I think it is not worth converting, and we should just use the direct call to
->findAll()
, which is simple and will save adding an extra 25 lines of barely-used code to AssertLegacyTrait. To help others who come along later who are converting tests that use getAllOptions() can we add a general comment in the top of AssertLegacyTrait listing functions and assertions which have not been converted, along with hints or issue links showing the alternatives?Comment #10
LendudeApparently I did something similar in the Views conversion, not that I remembered, https://www.drupal.org/node/2863267#comment-12014253
The fact that it's used at all makes me feel that we should add it to AssertLegacyTrait :(
It is also the clearest way to point people towards a better alternative then using the method. Opened #2907485: Add getAllOptions() to AssertLegacyTrait, so we can discuss it there further if needed.
I'd say we don't postpone this though, since it's just a one liner we replace it by, this won't effect the reviewability of the patch
Comment #11
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedIt looks like we have duplicate issues for converting the config tests:
#2864026: Convert web tests to browser tests for config module (this issue)
Created on 25 March 2017.
It is a child of #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase) but is not shown on that issue summary.
#2870439: Convert web tests to browser tests for config module
Created 17 April 2017
Also a child of the main issue and is shown in that issue summary. It has a bigger patch with more work done (15 files changed compared to 10).
Comment #12
naveenvalechaI have closed this as duplicate #2870439: Convert web tests to browser tests for config module give credit to @andypost and @valpas for their work in #2870439: Convert web tests to browser tests for config module
Comment #13
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThanks Naveenvalecha, but actually it should be the other way round, so I am closing this one as the duplicate. See my comment in #2870439-26: Convert web tests to browser tests for config module #26 for more details.