Problem/Motivation
EntityResourceTestBase is subclassed by every entity type in core, which is further subclassed nine times for various REST and HAL tests. It contains four test methods, one for each HTTP verb.
However, when testing config entities, three of these HTTP verbs simply pass immediately:
public function testPost() {
// @todo Remove this in https://www.drupal.org/node/2300677.
if ($this->entity instanceof ConfigEntityInterface) {
$this->assertTrue(TRUE, 'POSTing config entities is not yet supported.');
return;
}
...
public function testPatch() {
// @todo Remove this in https://www.drupal.org/node/2300677.
if ($this->entity instanceof ConfigEntityInterface) {
$this->assertTrue(TRUE, 'PATCHing config entities is not yet supported.');
return;
}
...
public function testDelete() {
// @todo Remove this in https://www.drupal.org/node/2300677.
if ($this->entity instanceof ConfigEntityInterface) {
$this->assertTrue(TRUE, 'DELETEing config entities is not yet supported.');
return;
}
The setup of these tests is still done, but no actual testing is performed. This means that for each config entity type we perform 3 x 9 = 27 installs via BrowserTestBase::setUp()
that are immediately thrown away because the test is effectively skipped.
At present there are 31 config entity types (and only 13 content entity types) in core. This means that we are performing 31 x 27 = 837 unnecessary installs during every full test run across core.
Steps to reproduce
Proposed resolution
Split EntityResourceTestBase into a new subclass ContentEntityResourceTestBase for content entities that require all four methods.
Remove all the skipped methods from EntityResourceTestBase keeping only testGet() and supporting methods.
Modify EntityResourceRestTestCoverageTest to ensure both config and content entities are tested correctly.
Revert this patch when #2300677: POST/PATCH config entities via REST for config entity types that support validation lands.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet