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.
Context
- #2257519: Move content assertion methods into a trait, so DUTB can consume it, too adds an
AssertContentTrait
, whose methods expect a range ofTestBase
methods to exist. - #2258217: Some Config web tests are not performing any HTTP requests adds a
ConfigSchemaTestTrait
, whose methods expect a range ofTestBase
methods to exist. - None of both test helper traits are declaring those dependent methods as abstract methods on the trait yet.
- Relying on methods to exist without defining them goes against basic design/programming principles.
Proposed solution
-
Add a new
AbstractAssertTrait
that is used by all custom test helper traits.
Details: AssertContentTrait
Studying the TestBase
↔ AssertContentTrait
dependencies:
TestBase methods |
Expected methods (AssertContentTrait ) |
---|---|
assert | assert |
assertEqual | assertEqual |
assertFalse | assertFalse |
assertIdentical | assertIdentical |
assertIdenticalObject | |
assertNotEqual | assertNotEqual |
assertNotIdentical | |
assertNotNull | |
assertNull | |
assertTrue | assertTrue |
error | |
fail | fail |
pass | pass |
verbose | verbose |
Details: ConfigSchemaTestTrait
ConfigSchemaTestTrait
only depends on fail()
and pass()
at this point.
However, its test helper methods are fairly basic currently; there's certainly room for improving them to use more advanced assertions.
Comment | File | Size | Author |
---|---|---|---|
test.abstract-trait.0.patch | 4.33 KB | sun | |
Comments
Comment #1
tim.plunkettComment #9
xjmI'd say given the PHPUnit assertion refactoring/cleanup we're doing in D9, this issue is obsolete.