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, the EntitySerializationTest test does not register all Normalizers with its mock Serializer. This means we aren't testing it as it would work in a full install.
Proposed resolution
Switch to DrupalUnitTestBase which creates a mock container. Use the serializer from this to test.
Comment | File | Size | Author |
---|---|---|---|
#15 | serializer-1904404-14.patch | 1.73 KB | tim.plunkett |
#10 | 1904404-10.patch | 5.28 KB | damiankloip |
#10 | interdiff.txt | 659 bytes | damiankloip |
#8 | 1904404-8.patch | 5.11 KB | damiankloip |
#7 | 1904404-7.patch | 5.1 KB | damiankloip |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedThis patch depends on #1903784: Move serialization to own module.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #3
damiankloip CreditAttribution: damiankloip commentedI like the test helper! This makes the tests much easier to read.
This looks confusing in the constructor, maybe we can just change the names of these to initEncoders/initNormalizers?
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedIn working with DrupalUnitTestBase to improve JSON-LD tests, I realized that it actually creates a mock container anyways. We can use the mock container that it provides instead of creating a helper class here. Will rewrite the patch shortly.
Comment #5
damiankloip CreditAttribution: damiankloip commentedLin, are you picking this one up? If not, I am happy to do this today.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedIt took me longer than I expected to debug the DrupalUnitTestBase issue in the JSON-LD tests, so I didn't get a chance to do this yesterday. Feel free to tackle it :)
Comment #7
damiankloip CreditAttribution: damiankloip commentedWe can actually convert these tests to use DrupalUnitTestBase too, so let's try that. It worked fine, apart from the default_langcode, which I have changed the expected data for.
I actually checked this normally, outside of tests, and it matches the structure that I have changed the expected data to in the test. SO I'm inclined to think this might be right. What do you think?
Cuts the text runs from ~10 secs to ~3 secs, not bad!
Comment #8
damiankloip CreditAttribution: damiankloip commentedJust another reroll now that we are in the serialization module.
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedSince entity_test is enabled manually, it doesn't need to be in the modules array.
Other than that, this looks good.
Comment #10
damiankloip CreditAttribution: damiankloip commentedGood point, thanks for the review.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedLooks good to me!
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #13
catchCommitted/pushed to 8.x, thanks!
Comment #14
tim.plunkettBecause of #1891516: Remove $install parameter from DrupalUnitTestBase::enableModules(), encourage individual schema tables this is broken, fixing now.
Comment #15
tim.plunkettPasses locally.
Comment #16
catchCommitted/pushed the follow-up, whoopsie that one was definitely me since I committed the DUTB patch yesterday...
Comment #17.0
(not verified) CreditAttribution: commentedUpdated with new proposed solution.