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

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

parent 353e737c
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -382,7 +382,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([
@@ -390,7 +390,7 @@ public function testPatchIndividual(): void {
      'type' => 'bar',
    ])->save();

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

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

  /**
   * {@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
@@ -112,7 +112,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
@@ -359,10 +359,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
@@ -131,7 +131,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.');
@@ -142,7 +142,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