function LinkTest::testLinkDeprecations

@group legacy @expectedDeprecation Constructing a Drupal\jsonapi\JsonApiResource\Link with an array of link relation types is deprecated in drupal:8.8.0 and will throw a fatal error in drupal:9.0.0. Pass a single string instead. See https://www.drupal.org/node/3087821. @expectedDeprecation Drupal\jsonapi\JsonApiResource\Link::getLinkRelationTypes() is deprecated in drupal:8.8.0 and will be removed in drupal:9.0.0. Use getLinkRelationType() instead. See https://www.drupal.org/node/3087821. @covers ::__construct @covers ::getLinkRelationTypes

File

core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php, line 137

Class

LinkTest
@coversDefaultClass \Drupal\jsonapi\JsonApiResource\Link @group jsonapi

Namespace

Drupal\Tests\jsonapi\Unit\JsonApiResource

Code

public function testLinkDeprecations() {
    $this->mockUrlAssembler();
    $link = new Link((new CacheableMetadata())->addCacheTags([
        'foo',
    ]), Url::fromUri('https://jsonapi.org/foo'), [
        'self',
        'foo',
    ]);
    $this->assertSame([
        'self',
        'foo',
    ], $link->getLinkRelationTypes());
    $this->assertSame('self', $link->getLinkRelationType());
    $link = new Link((new CacheableMetadata())->addCacheTags([
        'foo',
    ]), Url::fromUri('https://jsonapi.org/foo'), 'self');
    $this->assertSame([
        'self',
    ], $link->getLinkRelationTypes());
}

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