function MediaLinkRelationsTest::testExistLinkRelationships

Same name in other branches
  1. 9 core/modules/media/tests/src/Kernel/MediaLinkRelationsTest.php \Drupal\Tests\media\Kernel\MediaLinkRelationsTest::testExistLinkRelationships()
  2. 8.9.x core/modules/media/tests/src/Kernel/MediaLinkRelationsTest.php \Drupal\Tests\media\Kernel\MediaLinkRelationsTest::testExistLinkRelationships()
  3. 10 core/modules/media/tests/src/Kernel/MediaLinkRelationsTest.php \Drupal\Tests\media\Kernel\MediaLinkRelationsTest::testExistLinkRelationships()

Tests that all link relationships for Media exist.

File

core/modules/media/tests/src/Kernel/MediaLinkRelationsTest.php, line 19

Class

MediaLinkRelationsTest
Tests link relationships for media items.

Namespace

Drupal\Tests\media\Kernel

Code

public function testExistLinkRelationships() : void {
    
    /** @var \Drupal\Core\Http\LinkRelationTypeManager $link_relation_type_manager */
    $link_relation_type_manager = $this->container
        ->get('plugin.manager.link_relation_type');
    $media = Media::create([
        'bundle' => $this->testMediaType
            ->id(),
    ]);
    $media->save();
    foreach ($media->uriRelationships() as $relation_name) {
        $this->assertTrue($link_relation_type_manager->hasDefinition($relation_name), "Link relationship '{$relation_name}' for a media item");
    }
}

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