You are here

public function ContextBlockTest::testMedia in Core Context 8

Tests viewing context values stored on a media item.

File

tests/src/Functional/ContextBlockTest.php, line 148

Class

ContextBlockTest
@group core_context

Namespace

Drupal\Tests\core_context\Functional

Code

public function testMedia() {
  $this
    ->config('media.settings')
    ->set('standalone_url', TRUE)
    ->save();

  // Changing standalone_url necessitates a router rebuild.
  $this->container
    ->get('router.builder')
    ->rebuild();
  $media_type = $this
    ->createMediaType('test')
    ->id();
  $media = Media::create([
    'bundle' => $media_type,
    'field_media_test' => $this
      ->randomString(),
  ]);
  $media
    ->save();
  $this
    ->doEntityTest($media);
}