function JsonApiRegressionTest::testGetTermWhenMultipleVocabulariesExistFromIssue2977879

Same name and namespace in other branches
  1. 8.9.x core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest::testGetTermWhenMultipleVocabulariesExistFromIssue2977879()
  2. 10 core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest::testGetTermWhenMultipleVocabulariesExistFromIssue2977879()
  3. 11.x core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest::testGetTermWhenMultipleVocabulariesExistFromIssue2977879()

Ensures GETting terms works when multiple vocabularies exist.

See also

https://www.drupal.org/project/drupal/issues/2977879

File

core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php, line 209

Class

JsonApiRegressionTest
JSON:API regression tests.

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function testGetTermWhenMultipleVocabulariesExistFromIssue2977879() {
    // Set up data model.
    $this->assertTrue($this->container
        ->get('module_installer')
        ->install([
        'taxonomy',
    ], TRUE), 'Installed modules.');
    Vocabulary::create([
        'name' => 'one',
        'vid' => 'one',
    ])->save();
    Vocabulary::create([
        'name' => 'two',
        'vid' => 'two',
    ])->save();
    $this->rebuildAll();
    // Create data.
    Term::create([
        'vid' => 'one',
    ])->setName('Test')
        ->save();
    // Test.
    $user = $this->drupalCreateUser([
        'access content',
    ]);
    $response = $this->request('GET', Url::fromUri('internal:/jsonapi/taxonomy_term/one'), [
        RequestOptions::AUTH => [
            $user->getAccountName(),
            $user->pass_raw,
        ],
    ]);
    $this->assertSame(200, $response->getStatusCode());
}

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