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.
* Copies EntityUnitTestBase to a new EntityKernelTestBase (there are lots of subclasses in many core and contrib modules too)
* Moves subclasses in Entity and Field system tests and all other kernel tests in the Entity system tests to Drupal\KernelTests\Core\Entity
* Adds a fix to AssertLegacyTrait::assertEquals because various tests currently rely on that safe string casting behavior (translatable strings, mostly)
Some fails are remaining, will continue later.
Comment | File | Size | Author |
---|---|---|---|
#15 | interdiff.txt | 5.45 KB | dawehner |
#15 | 2679096-15.patch | 47.71 KB | dawehner |
#13 | entity-kernel-tests-2679096-13-interdiff.txt | 3 KB | Berdir |
#13 | entity-kernel-tests-2679096-13.patch | 48.15 KB | Berdir |
#9 | entity-kernel-tests-2679096-7-interdiff.txt | 6.53 KB | Berdir |
Comments
Comment #2
BerdirComment #3
BerdirThis fixes a lot of "Indirect modification of overloaded property Drupal\KernelTests\Core\Entity\EntityTranslationTest::$field has no effect"
Also, assertEqual() in simpletest aparently things that [] == NULL. assertEquals() does not.
Previous patch was messed up, sorry.
Comment #6
BerdirForgot to fix the field tests.
Comment #7
dawehnerGreat work!
IMHO we should fix this is KernelTestBase::assertEquals instead
Comment #9
BerdirA few more conversions. FieldSettingsTest is failing. Whatever that test is trying to do, it doesn't work the way it thinks:
I think assertEqual() in simpletest doesn't check types of nested array elements and phpunit does. I'm not sure if it wanted to test that the string is converted to a boolean but it doesn't work. After saving, the original object is kept. And even reloading, as I tried, doesn't make it work as then it's replaced again.
Comment #10
BerdirThis is what I get before making changes:
And after my changes:
Comment #12
dawehnerIn my debugging this seems to be really caused by
\Drupal\field_test\Plugin\Field\FieldType\TestItem::fieldSettingsFromConfigData
believing in runtime casting after loading, which of course doesn't exist.Comment #13
BerdirYeah, I'm just updating the test to look for a string now. Also commented in #2236903: setSettings() on field definitions can unintentionally clear default values
Also fixed another test fail, tried to enable the same module twice. And fixed the namespace of the filter test moved that incorectly.
Comment #14
tim.plunkettIs this in scope?
These changes look wrong, or at least some of them.
Out of scope
This seems like it should be able to stay as a Boolean, is there a fix needed elsewhere?
Comment #15
dawehnerWell, they are needed in order to let phpunit not complain about it.
We debugged that earlier ... simpletest relied on casting 'TRUE' to TRUE, internally. The test though should actually expect that, see
\Drupal\field_test\Plugin\Field\FieldType\TestItem::fieldSettingsFromConfigData
Comment #17
tim.plunkettI'm not sure about this being 8.1.x or 8.2.x, leaving here for now.
Duh, good point about
@covers \Drupal\field\Entity\FieldStorageConfig::getSettings
Looks great!
Comment #18
dawehnerThank you tim!
Comment #19
alexpottCommitted c3f14f9 and pushed to 8.1.x and 8.2.x. Thanks!
As this is test only code I've committed to 8.1.x. Not cherry-picking to 8.0.x because it feels like unnecessary disruption to the production branch this late in its life cycle.
Comment #21
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedOpened an issue to backport the new test class to 8.0.x: #2683391: Backport EntityKernelTestBase to 8.0.x