Problem/Motivation
In #3227824: Move the linkset functionality from the decoupled menus contributed module to core's system module we introduced a ApiRequestTrait . This trait is used in the LinkSet functionality and JSON:API. This should also be used in \Drupal\Tests\rest\Functional\ResourceTestBase to minimize duplicated code. It is allowed to rename the method when using the trait (as seen in core/modules/jsonapi/tests/src/Functional/JsonApiRequestTestTrait.php.
Postponed on parent issue:
#3227824: Move the linkset functionality from the decoupled menus contributed module to core's system module
Steps to reproduce
na
Proposed resolution
Refactor \Drupal\Tests\rest\Functional\ResourceTestBase to use the test trait instead of a local method.
Remaining tasks
na.
User interface changes
na.
API changes
na.
Data model changes
Release notes snippet
Issue fork drupal-3320670
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
longwaveComment #4
quietone commentedComment #6
ankitv18 commentedComment #8
ankitv18 commentedPlease review MR!9059
Comment #9
smustgrave commentedRefactor appears fine.
Comment #10
longwaveDo we need a separate trait? Can we just say
directly in ResourceTestBase?
Comment #11
smustgrave commentedAssuming since JsonApi and LinksetController do the same that's why it was done that way.
Comment #12
ankitv18 commented@longwave Yes we can do that and actually I was planning to do the same but as @smustgrave mentioned I had taken the reference from jsonApi and linksetController.
Comment #13
ankitv18 commentedMore simpler without extra trait file
cc: @longwave @smustgrave
Comment #14
smustgrave commentedHaven't looked but may be worth a novice follow up to see if the other instances in jsonApi and linksetController could be refactored too?
But change here LGTM.
Comment #16
longwaveCommitted e4d0bea and pushed to 11.x. Thanks!
As it's just a cleanup I don't see the point in backporting any further. Also not sure it's worth the effort of cleaning up the JSON:API trait, and the linkset test uses this trait directly anyway. The only slightly weird case is a CKEditor5 test that uses the JSON:API trait when it could use the base trait directly.