public function LibraryInclusionTranslationTest::testVideoFile in Lightning Media 8.4
Same name and namespace in other branches
- 8.3 modules/lightning_media_video/tests/src/Kernel/LibraryInclusionTranslationTest.php \Drupal\Tests\lightning_media_video\Kernel\LibraryInclusionTranslationTest::testVideoFile()
Tests that field_media_in_library is not translatable for video.
File
- modules/
lightning_media_video/ tests/ src/ Kernel/ LibraryInclusionTranslationTest.php, line 43
Class
- LibraryInclusionTranslationTest
- Tests translatability of field_media_in_library.
Namespace
Drupal\Tests\lightning_media_video\KernelCode
public function testVideoFile() {
$uri = uniqid('public://') . '.mp4';
$this
->assertGreaterThan(0, file_put_contents($uri, $this
->getRandomGenerator()
->paragraphs()));
$file = File::create([
'uri' => $uri,
]);
$file
->save();
$media = Media::create([
'bundle' => 'video',
'name' => $this
->randomString(),
'field_media_video_file' => $file
->id(),
'field_media_in_library' => TRUE,
]);
$media
->addTranslation('hu', [
'field_media_in_library' => FALSE,
]);
$media
->save();
$this
->assertTrue($media->field_media_in_library->value);
$this
->assertTrue($media
->getTranslation('hu')->field_media_in_library->value);
}