You are here

public function LibraryInclusionTranslationTest::test in Lightning Media 8.3

Same name in this branch
  1. 8.3 modules/lightning_media_image/tests/src/Kernel/LibraryInclusionTranslationTest.php \Drupal\Tests\lightning_media_image\Kernel\LibraryInclusionTranslationTest::test()
  2. 8.3 modules/lightning_media_audio/tests/src/Kernel/LibraryInclusionTranslationTest.php \Drupal\Tests\lightning_media_audio\Kernel\LibraryInclusionTranslationTest::test()
  3. 8.3 modules/lightning_media_instagram/tests/src/Functional/LibraryInclusionTranslationTest.php \Drupal\Tests\lightning_media_instagram\Functional\LibraryInclusionTranslationTest::test()
  4. 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
  1. 8.4 modules/lightning_media_audio/tests/src/Kernel/LibraryInclusionTranslationTest.php \Drupal\Tests\lightning_media_audio\Kernel\LibraryInclusionTranslationTest::test()

File

modules/lightning_media_audio/tests/src/Kernel/LibraryInclusionTranslationTest.php, line 35

Class

LibraryInclusionTranslationTest
@group lightning_media @group lightning_media_audio

Namespace

Drupal\Tests\lightning_media_audio\Kernel

Code

public function test() {
  $uri = uniqid('public://') . '.mp3';
  $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' => 'audio_file',
    'name' => $this
      ->randomString(),
    'field_media_audio_file' => $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);
}