Verified Commit 84159273 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3468280 by catch, bbrala: Speed up JSON:API ResourceTestBase

(cherry picked from commit ae9641c1)
parent b7553795
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -383,7 +383,7 @@ protected static function getExpectedCollectionCacheability(AccountInterface $ac
  /**
   * {@inheritdoc}
   */
  public function testPatchIndividual(): void {
  protected function doTestPatchIndividual(): void {
    // Ensure ::getModifiedEntityForPatchTesting() can pick an alternative value
    // for the 'entity_id' field.
    EntityTest::create([
@@ -391,7 +391,7 @@ public function testPatchIndividual(): void {
      'type' => 'bar',
    ])->save();

    parent::testPatchIndividual();
    parent::doTestPatchIndividual();
  }

}
+8 −3
Original line number Diff line number Diff line
@@ -201,11 +201,16 @@ protected function getPostDocument() {
  }

  /**
   * {@inheritdoc}
   * Tests POST/PATCH/DELETE for an individual resource.
   */
  public function testPostIndividual(): void {
  public function testIndividual(): void {
    // @todo https://www.drupal.org/node/1927648
    $this->markTestSkipped();
    // Add doTestPostIndividual().
    $this->doTestPatchIndividual();
    $this->entity = $this->resaveEntity($this->entity, $this->account);
    $this->revokePermissions();
    $this->config('jsonapi.settings')->set('read_only', TRUE)->save(TRUE);
    $this->doTestDeleteIndividual();
  }

  /**
+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ class FileUploadTest extends ResourceTestBase {
   *
   * @var array
   */
  const SKIP_METHODS = ['testGetIndividual', 'testPostIndividual', 'testPatchIndividual', 'testDeleteIndividual', 'testCollection', 'testRelationships'];
  const SKIP_METHODS = ['testGetIndividual', 'testIndividual', 'testCollection', 'testRelationships'];

  /**
   * {@inheritdoc}
+2 −2
Original line number Diff line number Diff line
@@ -360,10 +360,10 @@ protected function getExpectedUnauthorizedAccessCacheability() {
  /**
   * {@inheritdoc}
   */
  public function testPostIndividual(): void {
  protected function doTestPostIndividual(): void {
    // @todo Mimic \Drupal\Tests\rest\Functional\EntityResource\Media\MediaResourceTestBase::testPost()
    // @todo Later, use https://www.drupal.org/project/drupal/issues/2958554 to upload files rather than the REST module.
    parent::testPostIndividual();
    parent::doTestPostIndividual();
  }

  /**
+2 −2
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ public function testGetIndividual(): void {
  /**
   * {@inheritdoc}
   */
  public function testPatchIndividual(): void {
  protected function doTestPatchIndividual(): void {
    // Contact Message entities are not stored, so they cannot be modified.
    $this->expectException(RouteNotFoundException::class);
    $this->expectExceptionMessage('Route "jsonapi.contact_message--camelids.individual" does not exist.');
@@ -143,7 +143,7 @@ public function testPatchIndividual(): void {
  /**
   * {@inheritdoc}
   */
  public function testDeleteIndividual(): void {
  protected function doTestDeleteIndividual(): void {
    // Contact Message entities are not stored, so they cannot be deleted.
    $this->expectException(RouteNotFoundException::class);
    $this->expectExceptionMessage('Route "jsonapi.contact_message--camelids.individual" does not exist.');
Loading