From 936c5cf8fbada76780f6749d2c94331e715715e3 Mon Sep 17 00:00:00 2001
From: catch <6915-catch@users.noreply.drupalcode.org>
Date: Thu, 18 Jul 2024 20:32:13 +0900
Subject: [PATCH] Issue #3462264 by alexpott: Skip unsupported methods in
 rest/jsonapi tests in an efficient way

---
 .../Rest/CommentResourceTestBase.php          | 11 ++++
 .../Functional/Rest/CommentXmlAnonTest.php    | 16 ------
 .../Rest/CommentXmlBasicAuthTest.php          | 16 ------
 .../Functional/Rest/CommentXmlCookieTest.php  | 16 ------
 .../Functional/Rest/FileResourceTestBase.php  | 30 ++++++-----
 .../Rest/ImageStyleResourceTestBase.php       | 12 +++++
 .../Functional/Rest/ImageStyleXmlAnonTest.php |  8 ---
 .../Rest/ImageStyleXmlBasicAuthTest.php       |  8 ---
 .../Rest/ImageStyleXmlCookieTest.php          |  8 ---
 .../tests/src/Functional/FileUploadTest.php   | 53 ++++---------------
 .../Functional/Rest/NodeResourceTestBase.php  | 11 ++++
 .../src/Functional/Rest/NodeXmlAnonTest.php   |  8 ---
 .../Functional/Rest/NodeXmlBasicAuthTest.php  |  8 ---
 .../src/Functional/Rest/NodeXmlCookieTest.php |  8 ---
 .../ModeratedNodeXmlAnonTest.php              |  8 ---
 .../ModeratedNodeXmlBasicAuthTest.php         |  8 ---
 .../ModeratedNodeXmlCookieTest.php            |  8 ---
 .../XmlEntityNormalizationQuirksTrait.php     | 27 ++++------
 .../Functional/Rest/TermResourceTestBase.php  | 11 ++++
 .../src/Functional/Rest/TermXmlAnonTest.php   |  8 ---
 .../Functional/Rest/TermXmlBasicAuthTest.php  |  8 ---
 .../src/Functional/Rest/TermXmlCookieTest.php |  8 ---
 .../Functional/Rest/UserResourceTestBase.php  | 27 ++++++----
 .../src/Functional/Rest/UserXmlAnonTest.php   |  8 ---
 .../Functional/Rest/UserXmlBasicAuthTest.php  | 16 ------
 .../src/Functional/Rest/UserXmlCookieTest.php | 16 ------
 .../Functional/Rest/WorkspaceXmlAnonTest.php  |  8 ---
 .../Rest/WorkspaceXmlBasicAuthTest.php        |  8 ---
 .../Rest/WorkspaceXmlCookieTest.php           |  8 ---
 29 files changed, 101 insertions(+), 289 deletions(-)

diff --git a/core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php b/core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php
index 60b13b236169..7185164749b2 100644
--- a/core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php
+++ b/core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php
@@ -50,6 +50,17 @@ abstract class CommentResourceTestBase extends EntityResourceTestBase {
    */
   protected $entity;
 
+  /**
+   * Marks some tests as skipped because XML cannot be deserialized.
+   *
+   * @before
+   */
+  public function commentResourceTestBaseSkipTests(): void {
+    if (static::$format === 'xml' && in_array($this->name(), ['testPostDxWithoutCriticalBaseFields', 'testPostSkipCommentApproval'], TRUE)) {
+      $this->markTestSkipped('Deserialization of the XML format is not supported.');
+    }
+  }
+
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/comment/tests/src/Functional/Rest/CommentXmlAnonTest.php b/core/modules/comment/tests/src/Functional/Rest/CommentXmlAnonTest.php
index 6404656dfe99..b0eab80dda0e 100644
--- a/core/modules/comment/tests/src/Functional/Rest/CommentXmlAnonTest.php
+++ b/core/modules/comment/tests/src/Functional/Rest/CommentXmlAnonTest.php
@@ -52,20 +52,4 @@ class CommentXmlAnonTest extends CommentResourceTestBase {
     'field_name',
   ];
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPostDxWithoutCriticalBaseFields(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testPostSkipCommentApproval(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/comment/tests/src/Functional/Rest/CommentXmlBasicAuthTest.php b/core/modules/comment/tests/src/Functional/Rest/CommentXmlBasicAuthTest.php
index 05fec0c0a771..ed8f3ee70d3d 100644
--- a/core/modules/comment/tests/src/Functional/Rest/CommentXmlBasicAuthTest.php
+++ b/core/modules/comment/tests/src/Functional/Rest/CommentXmlBasicAuthTest.php
@@ -41,20 +41,4 @@ class CommentXmlBasicAuthTest extends CommentResourceTestBase {
    */
   protected static $auth = 'basic_auth';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPostDxWithoutCriticalBaseFields(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testPostSkipCommentApproval(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/comment/tests/src/Functional/Rest/CommentXmlCookieTest.php b/core/modules/comment/tests/src/Functional/Rest/CommentXmlCookieTest.php
index 44028b9db894..a382a8bd4c5a 100644
--- a/core/modules/comment/tests/src/Functional/Rest/CommentXmlCookieTest.php
+++ b/core/modules/comment/tests/src/Functional/Rest/CommentXmlCookieTest.php
@@ -36,20 +36,4 @@ class CommentXmlCookieTest extends CommentResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPostDxWithoutCriticalBaseFields(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testPostSkipCommentApproval(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php b/core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php
index b8f448d16549..1de8bdb305b3 100644
--- a/core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php
+++ b/core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php
@@ -41,6 +41,23 @@ abstract class FileResourceTestBase extends EntityResourceTestBase {
    */
   protected $author;
 
+  /**
+   * Marks some tests as skipped because XML cannot be deserialized.
+   *
+   * @before
+   */
+  public function fileResourceTestBaseSkipTests(): void {
+    if ($this->name() === 'testPost') {
+      // 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.');
+    }
+  }
+
   /**
    * {@inheritdoc}
    */
@@ -197,19 +214,6 @@ protected function getExpectedCacheContexts() {
     ];
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPost(): 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();
-  }
-
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php b/core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php
index 262ceea3a787..82c15600f339 100644
--- a/core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php
+++ b/core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php
@@ -36,6 +36,18 @@ abstract class ImageStyleResourceTestBase extends ConfigEntityResourceTestBase {
    */
   protected $effectUuid;
 
+  /**
+   * Marks some tests as skipped because XML cannot be deserialized.
+   *
+   * @before
+   */
+  public function imageStyleResourceTestBaseSkipTests(): void {
+    if ($this->name() === 'testGet' && 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');
+    }
+  }
+
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlAnonTest.php b/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlAnonTest.php
index d7e43ab03a1f..ebdd61ad5a39 100644
--- a/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlAnonTest.php
+++ b/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlAnonTest.php
@@ -30,12 +30,4 @@ class ImageStyleXmlAnonTest extends ImageStyleResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testGet(): void {
-    // @todo Remove this method override in https://www.drupal.org/node/2905655
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlBasicAuthTest.php b/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlBasicAuthTest.php
index 269b32aafa8c..50ed72ece1ae 100644
--- a/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlBasicAuthTest.php
+++ b/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlBasicAuthTest.php
@@ -40,12 +40,4 @@ class ImageStyleXmlBasicAuthTest extends ImageStyleResourceTestBase {
    */
   protected static $auth = 'basic_auth';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testGet(): void {
-    // @todo Remove this method override in https://www.drupal.org/node/2905655
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlCookieTest.php b/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlCookieTest.php
index b3e9c820e881..ba0237440403 100644
--- a/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlCookieTest.php
+++ b/core/modules/image/tests/src/Functional/Rest/ImageStyleXmlCookieTest.php
@@ -35,12 +35,4 @@ class ImageStyleXmlCookieTest extends ImageStyleResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testGet(): void {
-    // @todo Remove this method override in https://www.drupal.org/node/2905655
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php b/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
index 16e2de4a2fa4..36f972ebc120 100644
--- a/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
@@ -108,10 +108,21 @@ class FileUploadTest extends ResourceTestBase {
    */
   protected $fileStorage;
 
+  /**
+   * A list of test methods to skip.
+   *
+   * @var array
+   */
+  const SKIP_METHODS = ['testGetIndividual', 'testPostIndividual', 'testPatchIndividual', 'testDeleteIndividual', 'testCollection', 'testRelationships'];
+
   /**
    * {@inheritdoc}
    */
   protected function setUp(): void {
+    if (in_array($this->name(), static::SKIP_METHODS, TRUE)) {
+      $this->markTestSkipped('Irrelevant for this test');
+    }
+
     parent::setUp();
 
     $this->fileStorage = $this->container->get('entity_type.manager')
@@ -147,48 +158,6 @@ protected function setUp(): void {
     $this->entity = $this->entityStorage->loadUnchanged($this->entity->id());
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testGetIndividual(): void {
-    $this->markTestSkipped('Irrelevant for this test');
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testPostIndividual(): void {
-    $this->markTestSkipped('Irrelevant for this test');
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchIndividual(): void {
-    $this->markTestSkipped('Irrelevant for this test');
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testDeleteIndividual(): void {
-    $this->markTestSkipped('Irrelevant for this test');
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testCollection(): void {
-    $this->markTestSkipped('Irrelevant for this test');
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testRelationships(): void {
-    $this->markTestSkipped('Irrelevant for this test');
-  }
-
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php b/core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php
index d8c663bb03c0..f1defe8e1fc7 100644
--- a/core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php
+++ b/core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php
@@ -40,6 +40,17 @@ abstract class NodeResourceTestBase extends EntityResourceTestBase {
    */
   protected $entity;
 
+  /**
+   * Marks some tests as skipped because XML cannot be deserialized.
+   *
+   * @before
+   */
+  public function nodeResourceTestBaseSkipTests(): void {
+    if (static::$format === 'xml' && $this->name() === 'testPatchPath') {
+      $this->markTestSkipped('Deserialization of the XML format is not supported.');
+    }
+  }
+
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/node/tests/src/Functional/Rest/NodeXmlAnonTest.php b/core/modules/node/tests/src/Functional/Rest/NodeXmlAnonTest.php
index 68faeeb20d15..96c2e40b9c11 100644
--- a/core/modules/node/tests/src/Functional/Rest/NodeXmlAnonTest.php
+++ b/core/modules/node/tests/src/Functional/Rest/NodeXmlAnonTest.php
@@ -30,12 +30,4 @@ class NodeXmlAnonTest extends NodeResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/node/tests/src/Functional/Rest/NodeXmlBasicAuthTest.php b/core/modules/node/tests/src/Functional/Rest/NodeXmlBasicAuthTest.php
index b12d2969f24e..2f67b86eccbc 100644
--- a/core/modules/node/tests/src/Functional/Rest/NodeXmlBasicAuthTest.php
+++ b/core/modules/node/tests/src/Functional/Rest/NodeXmlBasicAuthTest.php
@@ -40,12 +40,4 @@ class NodeXmlBasicAuthTest extends NodeResourceTestBase {
    */
   protected static $auth = 'basic_auth';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/node/tests/src/Functional/Rest/NodeXmlCookieTest.php b/core/modules/node/tests/src/Functional/Rest/NodeXmlCookieTest.php
index 53785df4e6c8..117e219b537d 100644
--- a/core/modules/node/tests/src/Functional/Rest/NodeXmlCookieTest.php
+++ b/core/modules/node/tests/src/Functional/Rest/NodeXmlCookieTest.php
@@ -35,12 +35,4 @@ class NodeXmlCookieTest extends NodeResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlAnonTest.php b/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlAnonTest.php
index 71a2db986d98..b093726f6824 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlAnonTest.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlAnonTest.php
@@ -30,12 +30,4 @@ class ModeratedNodeXmlAnonTest extends ModeratedNodeResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlBasicAuthTest.php b/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlBasicAuthTest.php
index 823bf23ad177..b0e462ea1899 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlBasicAuthTest.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlBasicAuthTest.php
@@ -40,12 +40,4 @@ class ModeratedNodeXmlBasicAuthTest extends ModeratedNodeResourceTestBase {
    */
   protected static $auth = 'basic_auth';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlCookieTest.php b/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlCookieTest.php
index b8f0db39ac02..05650cef1771 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlCookieTest.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlCookieTest.php
@@ -35,12 +35,4 @@ class ModeratedNodeXmlCookieTest extends ModeratedNodeResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/XmlEntityNormalizationQuirksTrait.php b/core/modules/rest/tests/src/Functional/EntityResource/XmlEntityNormalizationQuirksTrait.php
index 9698e5d1c1e6..8b74b107883a 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/XmlEntityNormalizationQuirksTrait.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/XmlEntityNormalizationQuirksTrait.php
@@ -25,6 +25,17 @@ trait XmlEntityNormalizationQuirksTrait {
 
   use XmlNormalizationQuirksTrait;
 
+  /**
+   * Marks some tests as skipped because XML cannot be deserialized.
+   *
+   * @before
+   */
+  public function xmlEntityNormalizationQuirksTraitSkipTests(): void {
+    if (in_array($this->name(), ['testPatch', 'testPost'], TRUE)) {
+      $this->markTestSkipped('Deserialization of the XML format is not supported.');
+    }
+  }
+
   /**
    * {@inheritdoc}
    */
@@ -148,20 +159,4 @@ protected function applyXmlConfigEntityDecodingQuirks(array $normalization) {
     return $normalization;
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPost(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatch(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php b/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php
index cdd3d8fbb9d6..ac887b31f158 100644
--- a/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php
+++ b/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php
@@ -34,6 +34,17 @@ abstract class TermResourceTestBase extends EntityResourceTestBase {
    */
   protected $entity;
 
+  /**
+   * Marks some tests as skipped because XML cannot be deserialized.
+   *
+   * @before
+   */
+  public function termResourceTestBaseSkipTests(): void {
+    if (static::$format === 'xml' && $this->name() === 'testPatchPath') {
+      $this->markTestSkipped('Deserialization of the XML format is not supported.');
+    }
+  }
+
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlAnonTest.php b/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlAnonTest.php
index f5c7a2bc562d..ca30a562fd3d 100644
--- a/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlAnonTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlAnonTest.php
@@ -31,12 +31,4 @@ class TermXmlAnonTest extends TermResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlBasicAuthTest.php b/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlBasicAuthTest.php
index caa6e5e05564..a2ecbaae21aa 100644
--- a/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlBasicAuthTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlBasicAuthTest.php
@@ -41,12 +41,4 @@ class TermXmlBasicAuthTest extends TermResourceTestBase {
    */
   protected static $auth = 'basic_auth';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlCookieTest.php b/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlCookieTest.php
index 7eba87162c1f..9dd431715062 100644
--- a/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlCookieTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/Rest/TermXmlCookieTest.php
@@ -36,12 +36,4 @@ class TermXmlCookieTest extends TermResourceTestBase {
    */
   protected static $auth = 'cookie';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php b/core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php
index d3c03ff5b8c1..c423c06d5fed 100644
--- a/core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php
+++ b/core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php
@@ -48,6 +48,23 @@ abstract class UserResourceTestBase extends EntityResourceTestBase {
    */
   protected static $secondCreatedEntityId = 5;
 
+  /**
+   * Marks some tests as skipped because XML cannot be deserialized.
+   *
+   * @before
+   */
+  public function userResourceTestBaseSkipTests(): void {
+    if (in_array($this->name(), ['testPatchDxForSecuritySensitiveBaseFields', 'testPatchSecurityOtherUser'], TRUE)) {
+      if (static::$format === 'xml') {
+        $this->markTestSkipped('Deserialization of the XML format is not supported.');
+      }
+
+      if (static::$auth === FALSE) {
+        $this->markTestSkipped('The anonymous user is never allowed to modify itself.');
+      }
+    }
+  }
+
   /**
    * {@inheritdoc}
    */
@@ -148,11 +165,6 @@ protected function getNormalizedPostEntity() {
    * Tests PATCHing security-sensitive base fields of the logged in account.
    */
   public function testPatchDxForSecuritySensitiveBaseFields(): void {
-    // The anonymous user is never allowed to modify itself.
-    if (!static::$auth) {
-      $this->markTestSkipped();
-    }
-
     $this->initAuthentication();
     $this->provisionEntityResource();
 
@@ -264,11 +276,6 @@ protected function assertRpcLogin($username, $password) {
    * Tests PATCHing security-sensitive base fields to change other users.
    */
   public function testPatchSecurityOtherUser(): void {
-    // The anonymous user is never allowed to modify other users.
-    if (!static::$auth) {
-      $this->markTestSkipped();
-    }
-
     $this->initAuthentication();
     $this->provisionEntityResource();
 
diff --git a/core/modules/user/tests/src/Functional/Rest/UserXmlAnonTest.php b/core/modules/user/tests/src/Functional/Rest/UserXmlAnonTest.php
index 9b25e90217b3..436ad727eaf9 100644
--- a/core/modules/user/tests/src/Functional/Rest/UserXmlAnonTest.php
+++ b/core/modules/user/tests/src/Functional/Rest/UserXmlAnonTest.php
@@ -31,12 +31,4 @@ class UserXmlAnonTest extends UserResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchDxForSecuritySensitiveBaseFields(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/user/tests/src/Functional/Rest/UserXmlBasicAuthTest.php b/core/modules/user/tests/src/Functional/Rest/UserXmlBasicAuthTest.php
index 04384ea35c07..9ffe31296118 100644
--- a/core/modules/user/tests/src/Functional/Rest/UserXmlBasicAuthTest.php
+++ b/core/modules/user/tests/src/Functional/Rest/UserXmlBasicAuthTest.php
@@ -41,20 +41,4 @@ class UserXmlBasicAuthTest extends UserResourceTestBase {
    */
   protected static $auth = 'basic_auth';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchDxForSecuritySensitiveBaseFields(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchSecurityOtherUser(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/user/tests/src/Functional/Rest/UserXmlCookieTest.php b/core/modules/user/tests/src/Functional/Rest/UserXmlCookieTest.php
index f4257b75f724..cf63ccbff179 100644
--- a/core/modules/user/tests/src/Functional/Rest/UserXmlCookieTest.php
+++ b/core/modules/user/tests/src/Functional/Rest/UserXmlCookieTest.php
@@ -36,20 +36,4 @@ class UserXmlCookieTest extends UserResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchDxForSecuritySensitiveBaseFields(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchSecurityOtherUser(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlAnonTest.php b/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlAnonTest.php
index 2e3dd785b694..1b1ac04224dd 100644
--- a/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlAnonTest.php
+++ b/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlAnonTest.php
@@ -32,12 +32,4 @@ class WorkspaceXmlAnonTest extends WorkspaceResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlBasicAuthTest.php b/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlBasicAuthTest.php
index cbecdd36d2c7..ce8a2502732b 100644
--- a/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlBasicAuthTest.php
+++ b/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlBasicAuthTest.php
@@ -42,12 +42,4 @@ class WorkspaceXmlBasicAuthTest extends WorkspaceResourceTestBase {
    */
   protected static $auth = 'basic_auth';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
diff --git a/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlCookieTest.php b/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlCookieTest.php
index 9065e0714a19..c29c539f062d 100644
--- a/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlCookieTest.php
+++ b/core/modules/workspaces/tests/src/Functional/Rest/WorkspaceXmlCookieTest.php
@@ -37,12 +37,4 @@ class WorkspaceXmlCookieTest extends WorkspaceResourceTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatchPath(): void {
-    // Deserialization of the XML format is not supported.
-    $this->markTestSkipped();
-  }
-
 }
-- 
GitLab