public function LibraryInclusionTranslationTest::test in Lightning Media 8.3
Same name in this branch
- 8.3 modules/lightning_media_image/tests/src/Kernel/LibraryInclusionTranslationTest.php \Drupal\Tests\lightning_media_image\Kernel\LibraryInclusionTranslationTest::test()
- 8.3 modules/lightning_media_audio/tests/src/Kernel/LibraryInclusionTranslationTest.php \Drupal\Tests\lightning_media_audio\Kernel\LibraryInclusionTranslationTest::test()
- 8.3 modules/lightning_media_instagram/tests/src/Functional/LibraryInclusionTranslationTest.php \Drupal\Tests\lightning_media_instagram\Functional\LibraryInclusionTranslationTest::test()
- 8.3 modules/lightning_media_twitter/tests/src/Kernel/LibraryInclusionTranslationTest.php \Drupal\Tests\lightning_media_twitter\Kernel\LibraryInclusionTranslationTest::test()
Same name and namespace in other branches
- 8.4 modules/lightning_media_image/tests/src/Kernel/LibraryInclusionTranslationTest.php \Drupal\Tests\lightning_media_image\Kernel\LibraryInclusionTranslationTest::test()
File
- modules/
lightning_media_image/ tests/ src/ Kernel/ LibraryInclusionTranslationTest.php, line 35
Class
- LibraryInclusionTranslationTest
- @group lightning_media @group lightning_media_image
Namespace
Drupal\Tests\lightning_media_image\KernelCode
public function test() {
$uri = uniqid('public://') . '.png';
$this
->assertGreaterThan(0, file_put_contents($uri, $this
->getRandomGenerator()
->paragraphs()));
$file = File::create([
'uri' => $uri,
]);
$this
->assertSame(SAVED_NEW, $file
->save());
$media = Media::create([
'bundle' => 'image',
'name' => $this
->randomString(),
'image' => $file
->id(),
'field_media_in_library' => TRUE,
]);
$media
->addTranslation('hu', [
'field_media_in_library' => FALSE,
]);
$this
->assertSame(SAVED_NEW, $media
->save());
$this
->assertTrue($media->field_media_in_library->value);
$this
->assertTrue($media
->getTranslation('hu')->field_media_in_library->value);
}