Skip to content
Snippets Groups Projects
Commit 936c5cf8 authored by catch's avatar catch
Browse files

Issue #3462264 by alexpott: Skip unsupported methods in rest/jsonapi tests in an efficient way

parent 1dcc53dd
No related branches found
No related tags found
2 merge requests!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!9944Issue #3483353: Consider making the createCopy config action optionally fail...
Pipeline #228405 passed
Pipeline: drupal

#228407

    Showing
    with 84 additions and 199 deletions
    ......@@ -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}
    */
    ......
    ......@@ -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();
    }
    }
    ......@@ -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();
    }
    }
    ......@@ -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();
    }
    }
    ......@@ -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}
    */
    ......
    ......@@ -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}
    */
    ......
    ......@@ -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();
    }
    }
    ......@@ -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();
    }
    }
    ......@@ -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();
    }
    }
    ......@@ -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}
    */
    ......
    ......@@ -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}
    */
    ......
    ......@@ -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();
    }
    }
    ......@@ -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();
    }
    }
    ......@@ -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();
    }
    }
    ......@@ -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();
    }
    }
    ......@@ -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();
    }
    }
    ......@@ -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();
    }
    }
    ......@@ -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();
    }
    }
    ......@@ -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}
    */
    ......
    ......@@ -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();
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment