Loading core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php +1 −6 Changes for core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php: 1 added line, 6 removed lines. Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ use Drupal\file\Entity\File; use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase; use Drupal\user\Entity\User; use PHPUnit\Framework\Attributes\Before; /** * Resource test base for file entity. Loading Loading @@ -48,17 +47,13 @@ abstract class FileResourceTestBase extends EntityResourceTestBase { /** * Marks some tests as skipped because XML cannot be deserialized. */ #[Before] public function fileResourceTestBaseSkipTests(): void { if ($this->name() === 'testPost') { protected function doTestPost(): void { // Drupal does not allow creating file entities independently. It allows // you to create file entities that are referenced from another entity // (e.g. an image for a node's image field). // For that purpose, there is the "file_upload" REST resource plugin. // @see \Drupal\file\FileAccessControlHandler::checkCreateAccess() // @see \Drupal\file\Plugin\rest\resource\FileUploadResource $this->markTestSkipped('Drupal does not allow creating file entities independently.'); } } /** Loading core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php +3 −4 Changes for core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php: 3 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ use Drupal\image\Entity\ImageStyle; use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase; use PHPUnit\Framework\Attributes\Before; /** * ResourceTestBase for ImageStyle entity. Loading Loading @@ -40,12 +39,12 @@ abstract class ImageStyleResourceTestBase extends ConfigEntityResourceTestBase { /** * Marks some tests as skipped because XML cannot be deserialized. */ #[Before] public function imageStyleResourceTestBaseSkipTests(): void { if ($this->name() === 'testGet' && static::$format === 'xml') { protected function setUp(): void { if ($this->name() === 'testCrud' && static::$format === 'xml') { // @todo Remove this method override in https://www.drupal.org/node/2905655 $this->markTestSkipped('XML encoder does not support UUIDs as keys: makes ImageStyle config entity XML serialization crash'); } parent::setUp(); } /** Loading core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php +2 −2 Changes for core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -326,7 +326,7 @@ protected function getExpectedCacheContexts() { /** * {@inheritdoc} */ public function testPost(): void { protected function doTestPost(): void { $file_storage = $this->container->get('entity_type.manager')->getStorage('file'); // Step 1: upload file, results in File entity marked temporary. Loading @@ -336,7 +336,7 @@ public function testPost(): void { $this->assertFalse($file->isPermanent()); // Step 2: create Media entity using the File, makes File entity permanent. parent::testPost(); parent::doTestPost(); $file = $file_storage->loadUnchanged(3); $this->assertFalse($file->isTemporary()); $this->assertTrue($file->isPermanent()); Loading core/modules/rest/tests/modules/rest_test/src/Hook/RestTestHooks.php +9 −9 Changes for core/modules/rest/tests/modules/rest_test/src/Hook/RestTestHooks.php: 9 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -25,36 +25,36 @@ class RestTestHooks { */ #[Hook('entity_field_access')] public function entityFieldAccess($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, ?FieldItemListInterface $items = NULL): AccessResultInterface { // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testPost() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testPatch() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestPost() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestPatch() if ($field_definition->getName() === 'field_rest_test') { switch ($operation) { case 'view': // Never ever allow this field to be viewed: this lets // EntityResourceTestBase::testGet() test in a "vanilla" way. // EntityResourceTestBase::doTestGet() test in a "vanilla" way. return AccessResult::forbidden(); case 'edit': return AccessResult::forbidden(); } } // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testGet() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testPatch() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestGet() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestPatch() if ($field_definition->getName() === 'field_rest_test_multivalue') { switch ($operation) { case 'view': // Never ever allow this field to be viewed: this lets // EntityResourceTestBase::testGet() test in a "vanilla" way. // EntityResourceTestBase::doTestGet() test in a "vanilla" way. return AccessResult::forbidden(); } } // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testGet() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testPatch() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestGet() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestPatch() if ($field_definition->getName() === 'rest_test_validation') { switch ($operation) { case 'view': // Never ever allow this field to be viewed: this lets // EntityResourceTestBase::testGet() test in a "vanilla" way. // EntityResourceTestBase::doTestGet() test in a "vanilla" way. return AccessResult::forbidden(); } } Loading core/modules/rest/tests/src/Functional/EntityResource/ConfigEntityResourceTestBase.php +2 −13 Changes for core/modules/rest/tests/src/Functional/EntityResource/ConfigEntityResourceTestBase.php: 2 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -11,22 +11,11 @@ */ abstract class ConfigEntityResourceTestBase extends EntityResourceTestBase { /** * A list of test methods to skip. * * @var array */ const SKIP_METHODS = ['testPost', 'testPatch', 'testDelete']; /** * {@inheritdoc} */ protected function setUp(): void { if (in_array($this->name(), static::SKIP_METHODS, TRUE)) { // Skip before installing Drupal to prevent unnecessary use of resources. $this->markTestSkipped("Not yet supported for config entities."); } parent::setUp(); public function testCrud(): void { $this->doTestGet(); } } Loading
core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php +1 −6 Changes for core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php: 1 added line, 6 removed lines. Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ use Drupal\file\Entity\File; use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase; use Drupal\user\Entity\User; use PHPUnit\Framework\Attributes\Before; /** * Resource test base for file entity. Loading Loading @@ -48,17 +47,13 @@ abstract class FileResourceTestBase extends EntityResourceTestBase { /** * Marks some tests as skipped because XML cannot be deserialized. */ #[Before] public function fileResourceTestBaseSkipTests(): void { if ($this->name() === 'testPost') { protected function doTestPost(): void { // Drupal does not allow creating file entities independently. It allows // you to create file entities that are referenced from another entity // (e.g. an image for a node's image field). // For that purpose, there is the "file_upload" REST resource plugin. // @see \Drupal\file\FileAccessControlHandler::checkCreateAccess() // @see \Drupal\file\Plugin\rest\resource\FileUploadResource $this->markTestSkipped('Drupal does not allow creating file entities independently.'); } } /** Loading
core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php +3 −4 Changes for core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php: 3 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ use Drupal\image\Entity\ImageStyle; use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase; use PHPUnit\Framework\Attributes\Before; /** * ResourceTestBase for ImageStyle entity. Loading Loading @@ -40,12 +39,12 @@ abstract class ImageStyleResourceTestBase extends ConfigEntityResourceTestBase { /** * Marks some tests as skipped because XML cannot be deserialized. */ #[Before] public function imageStyleResourceTestBaseSkipTests(): void { if ($this->name() === 'testGet' && static::$format === 'xml') { protected function setUp(): void { if ($this->name() === 'testCrud' && static::$format === 'xml') { // @todo Remove this method override in https://www.drupal.org/node/2905655 $this->markTestSkipped('XML encoder does not support UUIDs as keys: makes ImageStyle config entity XML serialization crash'); } parent::setUp(); } /** Loading
core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php +2 −2 Changes for core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -326,7 +326,7 @@ protected function getExpectedCacheContexts() { /** * {@inheritdoc} */ public function testPost(): void { protected function doTestPost(): void { $file_storage = $this->container->get('entity_type.manager')->getStorage('file'); // Step 1: upload file, results in File entity marked temporary. Loading @@ -336,7 +336,7 @@ public function testPost(): void { $this->assertFalse($file->isPermanent()); // Step 2: create Media entity using the File, makes File entity permanent. parent::testPost(); parent::doTestPost(); $file = $file_storage->loadUnchanged(3); $this->assertFalse($file->isTemporary()); $this->assertTrue($file->isPermanent()); Loading
core/modules/rest/tests/modules/rest_test/src/Hook/RestTestHooks.php +9 −9 Changes for core/modules/rest/tests/modules/rest_test/src/Hook/RestTestHooks.php: 9 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -25,36 +25,36 @@ class RestTestHooks { */ #[Hook('entity_field_access')] public function entityFieldAccess($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, ?FieldItemListInterface $items = NULL): AccessResultInterface { // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testPost() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testPatch() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestPost() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestPatch() if ($field_definition->getName() === 'field_rest_test') { switch ($operation) { case 'view': // Never ever allow this field to be viewed: this lets // EntityResourceTestBase::testGet() test in a "vanilla" way. // EntityResourceTestBase::doTestGet() test in a "vanilla" way. return AccessResult::forbidden(); case 'edit': return AccessResult::forbidden(); } } // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testGet() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testPatch() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestGet() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestPatch() if ($field_definition->getName() === 'field_rest_test_multivalue') { switch ($operation) { case 'view': // Never ever allow this field to be viewed: this lets // EntityResourceTestBase::testGet() test in a "vanilla" way. // EntityResourceTestBase::doTestGet() test in a "vanilla" way. return AccessResult::forbidden(); } } // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testGet() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testPatch() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestGet() // @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::doTestPatch() if ($field_definition->getName() === 'rest_test_validation') { switch ($operation) { case 'view': // Never ever allow this field to be viewed: this lets // EntityResourceTestBase::testGet() test in a "vanilla" way. // EntityResourceTestBase::doTestGet() test in a "vanilla" way. return AccessResult::forbidden(); } } Loading
core/modules/rest/tests/src/Functional/EntityResource/ConfigEntityResourceTestBase.php +2 −13 Changes for core/modules/rest/tests/src/Functional/EntityResource/ConfigEntityResourceTestBase.php: 2 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -11,22 +11,11 @@ */ abstract class ConfigEntityResourceTestBase extends EntityResourceTestBase { /** * A list of test methods to skip. * * @var array */ const SKIP_METHODS = ['testPost', 'testPatch', 'testDelete']; /** * {@inheritdoc} */ protected function setUp(): void { if (in_array($this->name(), static::SKIP_METHODS, TRUE)) { // Skip before installing Drupal to prevent unnecessary use of resources. $this->markTestSkipped("Not yet supported for config entities."); } parent::setUp(); public function testCrud(): void { $this->doTestGet(); } }