You are here

public function LibraryInclusionTranslationTest::testRemoteVideo in Lightning Media 8.4

Tests that field_media_in_library is not translatable for remote_video.

File

modules/lightning_media_video/tests/src/Kernel/LibraryInclusionTranslationTest.php, line 68

Class

LibraryInclusionTranslationTest
Tests translatability of field_media_in_library.

Namespace

Drupal\Tests\lightning_media_video\Kernel

Code

public function testRemoteVideo() {
  $url = $this
    ->randomString();
  $url_resolver = $this
    ->prophesize(UrlResolverInterface::class);
  $url_resolver
    ->getResourceUrl($url)
    ->willReturnArgument(0);
  $this->container
    ->set('media.oembed.url_resolver', $url_resolver
    ->reveal());
  $resource = Resource::link();
  $resource_fetcher = $this
    ->prophesize(ResourceFetcherInterface::class);
  $resource_fetcher
    ->fetchResource($url)
    ->willReturn($resource);
  $this->container
    ->set('media.oembed.resource_fetcher', $resource_fetcher
    ->reveal());
  $media = Media::create([
    'bundle' => 'remote_video',
    'field_media_oembed_video' => $url,
    'field_media_in_library' => TRUE,
  ]);
  $media
    ->addTranslation('hu', [
    'field_media_in_library' => FALSE,
    'field_media_oembed_video' => $url,
  ]);
  $media
    ->save();
  $this
    ->assertTrue($media->field_media_in_library->value);
  $this
    ->assertTrue($media
    ->getTranslation('hu')->field_media_in_library->value);
}