Problem/Motivation
Write EntityResourceTestBase subclasses for workspace, content_workspace, and replication_log entities
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | 2928215-23.patch | 3.18 KB | amateescu |
| #20 | interdiff-20.txt | 1.13 KB | amateescu |
| #20 | 2928215-20.patch | 15.03 KB | amateescu |
| #19 | 2928215-19.patch | 15.58 KB | timmillwood |
| #19 | interdiff-2928215-19.txt | 2.61 KB | timmillwood |
Comments
Comment #2
wim leersAs of #2868035: Test that all core content+config entity types have functional REST test coverage, every entity type is required to have REST test coverage. To ensure Drupal 8 is actually "API-First": all entities should be accessible via HTTP APIs.
Comment #3
wim leersComment #4
amateescu commentedcontent_workspaceis an internal entity type, why would we want to add REST support for it?Kind of the same for
replication_log, is there are any reason to support CRUD for this entity type via REST?Comment #5
wim leersThat's possible. If that is the case, then we should explicitly test that it's not supported. See #2843753: Prevent ContentModerationState from being exposed by REST's EntityResource and #2779931: Add storage exception that enforces unique content_entity_type_id and content_entity_id on the content moderation state content entity, and add access control handler to forbid all access.
Comment #6
timmillwoodLet's do content workspace entities first.
Comment #7
timmillwoodAdding progress on testing GET, PATCH, POST, DELETE operations.
All fail on permission related issues, which makes me think the workspace permission setup is both flawed and untested.
Comment #9
timmillwoodDepends on #2928887: EntityResource and EntityResourceTestBase have different ideas for access, but still doesn't pass.
Any tips welcome.
Comment #11
timmillwoodMoving the code from #2928887: EntityResource and EntityResourceTestBase have different ideas for access into WorkspaceResourceTestBase.
The remaining failing tests depend on #2885469: Regression: manually setting the ID field for newly-created content entities is not possible anymore (public follow-up to SA-2017-002).
@todo: decide what we want to do about replication_log.
Comment #13
timmillwoodThis fixes remaining issues with the Workspace entity tests.
After discussion with @amateescu we decided replication_log is an internal entity type, and therefore shouldn't be exposed via REST.
Comment #15
timmillwoodFixing all the coding standards items!
Comment #17
timmillwoodPostponed on #2885469: Regression: manually setting the ID field for newly-created content entities is not possible anymore (public follow-up to SA-2017-002)
Comment #18
wim leersLooks great!
Just FYI: we didn't add these comments to the REST tests in core because it's 100% boilerplate: the class name already explains precisely this :)
So you can remove it if you want, but if you prefer this, that's fine too
This should not grant all permissions, but should only grant the permissions necessary depending on the method. That's why
$methodis a parameter.Supernit: The second line I quoted is indented one level too much.
Hm, why do we need one return value to be cast to an integer but not the other?
See #2928887-3: EntityResource and EntityResourceTestBase have different ideas for access — this should hardcode the expected strings, otherwise we still won't A) know that the messages are helpful, B) know that we regress.
👍
👍 — nice bugfix that this surfaced :)
Comment #19
timmillwood#18.1 - PHPCS tells me we need these.
#18.2 - Done
#18.3 - Done
#18.4 - I've no idea, but otherwise I was getting a string.
#18.5 - Done
#18.6 - 🤘
#18.7 - 🤘
Comment #20
amateescu commentedThese tests are needed in the main core patch, so I rerolled #19, fixed a couple of minor things and committed to 8.x-2.x.
This means that the new tests will fail until #2885469: Regression: manually setting the ID field for newly-created content entities is not possible anymore (public follow-up to SA-2017-002) gets in, but well, #2927169: Fix views queries is in the same boat :)
Comment #22
wim leersSo very glad to see this test coverage, and I'm sure that that gives you some extra confidence too :) And fewer hurdles to get it into core!
#19:
Sorry for not seeing your comment until now :(
RE #18.4: hm, but that then means
getStartTime()isn't returning an integer, which violates its interface if I'm reading #2784921-83: Add Workspaces experimental module correctly.#20: I think you'll like the fact that I've been pushing #2885469: Regression: manually setting the ID field for newly-created content entities is not possible anymore (public follow-up to SA-2017-002) forward then :)
Comment #23
amateescu commentedThis happens for many other timestamp fields, and basically all integer ones IIRC. There are many instances of casting to
(int)throughout REST test classes.FWIW, these changes were needed in order to make the core patch pass all the tests, so I've committed them here as well.
Comment #25
amateescu commentedIndeed :) Thank you!