class JsonApiRegressionTest

Same name in this branch
  1. 9 core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest
Same name and namespace in other branches
  1. 11.x core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest
  2. 10 core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest
  3. 8.9.x core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest

JSON:API regression tests.

@group jsonapi @group rdf @group legacy

Hierarchy

Expanded class hierarchy of JsonApiRegressionTest

File

core/modules/rdf/tests/src/Functional/Jsonapi/JsonApiRegressionTest.php, line 19

Namespace

Drupal\Tests\rdf\Functional\Jsonapi
View source
class JsonApiRegressionTest extends JsonApiFunctionalTestBase {
  use CommentTestTrait;
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'basic_auth',
    'comment',
    'rdf',
  ];
  
  /**
   * Ensure that child comments can be retrieved via JSON:API.
   */
  public function testLeakedCacheMetadataViaRdfFromIssue3053827() : void {
    $this->addDefaultCommentField('node', 'article');
    $this->rebuildAll();
    Node::create([
      'title' => 'Commented Node',
      'type' => 'article',
    ])->save();
    $default_values = [
      'entity_id' => 1,
      'entity_type' => 'node',
      'field_name' => 'comment',
      'status' => 1,
    ];
    $parent = Comment::create([
      'subject' => 'Marlin',
    ] + $default_values);
    $parent->save();
    $child = Comment::create([
      'subject' => 'Nemo',
      'pid' => $parent->id(),
    ] + $default_values);
    $child->save();
    $user = $this->drupalCreateUser([
      'access comments',
    ]);
    $request_options = [
      RequestOptions::AUTH => [
        $user->getAccountName(),
        $user->pass_raw,
      ],
    ];
    // Requesting the comment collection should succeed.
    $response = $this->request('GET', Url::fromUri('internal:/jsonapi/comment/comment'), $request_options);
    $this->assertSame(200, $response->getStatusCode());
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.