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
Currently assertNoCacheTag exist on WebTestBase but there is no equivalent available for BrowserTestBase, in order to facilitate ease of conversion we should add assertNoCacheTag to assertLegacyTrait
Proposed resolution
Remaining tasks
Create the methods and deprecate them.
Add tests.
User interface changes
API changes
New methods available for conversion.
Data model changes
Blocking these issues
- #2870452: Convert web tests to browser tests for menu_ui module
- #2870439: Convert web tests to browser tests for config module
- #2863644: Convert web tests of block
Comment | File | Size | Author |
---|---|---|---|
#32 | interdiff-2795085.txt | 744 bytes | dawehner |
#32 | 2795085-32.patch | 1.89 KB | dawehner |
#30 | 2795085-30.patch | 1.16 KB | naveenvalecha |
Comments
Comment #2
dawehnerComment #3
dawehnerComment #4
dawehnerComment #5
legovaerThe method
assertCacheContexts
contains a call togetCacheHeaderValues()
which on his side contains a call toWebTestBase::drupalGetHeader()
.I think we first need to identify how we're going to provide exactly the same functionality within PHPUnit before we can start working on this issue.
Comment #6
prafulla_anurag CreditAttribution: prafulla_anurag as a volunteer commentedI would like to work on this issue. This would be my first task with drupal, so I might need some help.
Comment #8
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedThis is needed by a lot of tests for a wtb to btb conversion
Comment #9
dawehnerCan we link to some change record which explain this kind of conversion? I believe we should add this, given how the
trigger_error
s should look like.Comment #10
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedChange record has been created.
Comment #11
dawehnerDo you think we should have some trait for those assertions?
Comment #12
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedOnly if every cache asserts are moving to this assertCacheTrait.
1/ We add this asserts to assertLegacyTrait and will move every cache assert in a new assertCacheTrait with another issue.
2/ First we put those asserts to a new assertCacheTrait than we will move other cache assert to assertCacheTrait with another issue.
I have no preference for one or the other.
Comment #13
dawehnerIt feels like cache tags are so often needed that adding it into the testing api could make sense for itself. Any thoughts?
Comment #14
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedI have encountered another test that could use it here:
#2863644: Convert web tests of block.
As there is a valid alternative in Mink I prefer adding it to the AssertLegacyTrait so we can dump them again in Drupal 9.
+1 on the needs tests though, we need to add coverage for these assertions in BrowserTestBaseTest.
Comment #15
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #16
Torenware CreditAttribution: Torenware as a volunteer commentedComment #17
dawehnerDoes someone mind update the issue summary a bit, at least?
Comment #18
benjifisherAdding a tag based on #17. Maybe the attention this issue got in #17 is barely enough that I should keep the Baltimore2017 tag.
Comment #19
benjifisheroops
Comment #20
andypostMaybe better to convert
AssertPageCacheContextsAndTagsTrait
& deprecate in favour of new one?Comment #21
LendudeAghhh ok just wrote a different comment 3 times and then when diving in deeper turned completely around on this again and again!
I think that the title should point to assertCacheTag and assertNoCacheTag (@dawehner correct me if I'm wrong please), since these methods exist on WebTestBase, and nowhere else. So not cacheContext. The cacheContext methods are available on
AssertPageCacheContextsAndTagsTrait
and anything needing those should wait for #2863318: Cache: Convert system functional tests to phpunit to land. So the patch in #10 is not correct (sorry).Updating the IS with what I think should be done here, but of course update it if I'm reading all of this wrong.
Comment #22
naveenvalechaWe have assertCacheTag in AssertLegacyTrait we need assertNoCacheTag, assertCacheContext/assertNoCacheContext to BTB
Updated IS accordingly.
//Naveen
Comment #23
naveenvalechaComment #24
naveenvalechaHere's the patch.
This issue is blocking these issues:
- #2870452: Convert web tests to browser tests for menu_ui module
- #2870439: Convert web tests to browser tests for config module
- #2863644: Convert web tests of block
Comment #25
Lendude@naveenvalecha I think the interdiff in #24 is the patch as it should be. Both assertCacheContext and assertNoCacheContext are (or will be) available on
\Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait
, that just needs to be converted. If we add those methods to AssertLegacyTrait we will be in a right mess when you use AssertPageCacheContextsAndTagsTrait once it's converted.Comment #26
naveenvalecha\Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait
is being used by the WTB tests. if we'll convert it for BTB then the WTB tests(which are using this Trait) will fail b/c$this->assertSession()
only compatible with the BTB not WTB. So we need to add these methods to the AssertLegacyTrait for now and we rely on the AssertPageCacheContextsAndTagsTrait once all the conversion will be done.OR
We could add a copy of AssertPageCacheContextsAndTagsTrait into BTB namespace and use it in BTB tests. What do you think?
//Naveen
Comment #27
LendudeThat one, and deprecate the old one, but I would consider that work part of #2863318: Cache: Convert system functional tests to phpunit. This issue just needs to worry about
assertNoCacheTag
since that is not available anywhere for BrowserTestBase and doesn't exist on any traits, only on WebTestBase itselfComment #28
naveenvalechaupdated the IS as per #27
Comment #30
naveenvalechaHere's the correct one.
Comment #31
LendudeNice. Still needs some test coverage added in
\Drupal\Tests\Core\Assert\AssertLegacyTraitTest
Comment #32
dawehnerLet's do that quickly :)
Comment #33
LendudeNice one.
Comment #35
andypostComment #36
naveenvalechaThis is blocker for issues mentioned in IS
Comment #37
larowlanWe need to update the change record (it is about contexts not tags)
Adding @Lendude to issue credits as he was instrumental in shaping patch
Comment #38
larowlanCan someone provide new copy to go in the change record on commit?
Comment #39
LendudeUpdated the change record to match the actual change.
Comment #41
larowlanCommitted as ba0ac0f and pushed to 8.4.x. Keep up the great work!
Comment #42
andypostYay! lots of issues unblocked! thanx Lee)
Comment #43
dawehnerThank you @larowlan!
Comment #44
naveenvalechaThanks a ton! Lee, it unblocked a couple of issues and will help to gain the momentum to phpunit issues.