9c7ca28eef9a3ec4a222a1dc653904151e0b60f7
[yaffs-website] / web / core / modules / media / tests / src / Kernel / MediaTest.php
1 <?php
2
3 namespace Drupal\Tests\media\Kernel;
4
5 use Drupal\media\Entity\Media;
6
7 /**
8  * Tests Media.
9  *
10  * @group media
11  */
12 class MediaTest extends MediaKernelTestBase {
13
14   /**
15    * Tests various aspects of a media item.
16    */
17   public function testEntity() {
18     $media = Media::create(['bundle' => $this->testMediaType->id()]);
19
20     $this->assertSame($media, $media->setOwnerId($this->user->id()), 'setOwnerId() method returns its own entity.');
21   }
22
23   /**
24    * Tests the Media "name" base field behavior.
25    */
26   public function testNameBaseField() {
27     /** @var \Drupal\Core\Field\BaseFieldDefinition[] $field_definitions */
28     $field_definitions = $this->container->get('entity_field.manager')
29       ->getBaseFieldDefinitions('media');
30
31     // Ensure media name is configurable on manage display.
32     $this->assertTrue($field_definitions['name']->isDisplayConfigurable('view'));
33     // Ensure it is not visible by default.
34     $this->assertSame($field_definitions['name']->getDisplayOptions('view'), ['region' => 'hidden']);
35   }
36
37 }