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.
As outlined in #2430673: ContentEntityBase::__construct() lacks documentation there is some uncertainty over whether ContentEntityBase([LANGUAGE_DEFAULT => , 'fr' => ]) would even work. And even if it does, it would definitely be a good idea to get this tested. Especially since the $values data structure is very ... interesting so a proven to be working example is very useful here.
Comment | File | Size | Author |
---|---|---|---|
#10 | test_contententitybase-2436209-10.patch | 2.47 KB | siva_epari |
#6 | 2436209_6.patch | 2.46 KB | chx |
Comments
Comment #1
dawehnerAdapting the parent issue
Comment #2
chx CreditAttribution: chx commentedOpsie, sorry, thanks for fixing it, too many browser tabs :)
Comment #3
chx CreditAttribution: chx at MongoDB commentedHere we are.
Comment #4
chx CreditAttribution: chx at MongoDB commentedMoved the count assert one line down.
Comment #5
BerdirAs discussed with @chx, one goal here is essentially to provide examples/code documentation for alternative storage backends. Maybe we could actually refer to this somewhere, e.g. on the content entity storage base class?
The test currently doesn't pass in $bundle and $translations to the constructor.
1. The missing bundle only works because entity_test by default has no bundles and uses the $bundle == $entity_type_id fallback. We should instead (or maybe additionally) create a random bundle with entity_test_create_bundle(), including a test field that only exists on that bundle and create values also for that configurable field.
2. Missing $translations can probably be tested by calling getTranslationLanguages(), it should return the same languages as you create.
I think doing those two things should give you fairly good test coverage of those arguments.
Also wondering if we shouldn't merge this back together with #2430673: ContentEntityBase::__construct() lacks documentation. I wouldn't be surprised if this issue would get pushed back due to missing documentation.
Comment #6
chx CreditAttribution: chx at MongoDB commentedComment #7
plachLooks good to me, let's try to RTBC this and see what happens ;)
Comment #9
chx CreditAttribution: chx at MongoDB commentedComment #10
siva_epari CreditAttribution: siva_epari commentedPatch rerolled.
Comment #11
plachThanks
Comment #12
xjmA couple inline comments in this test would be peachy; it's kind of a wall of code at the moment, so somewhat difficult to see exactly what it tests. ("Works with translations" is not specific.)
I can see the case for separating the scope from #2430673: ContentEntityBase::__construct() lacks documentation or for combining the patches; no strong feelings either way.