MediaTest.php in Drupal 8
File
core/modules/media/tests/src/Kernel/MediaTest.php
View source
<?php
namespace Drupal\Tests\media\Kernel;
use Drupal\media\Entity\Media;
class MediaTest extends MediaKernelTestBase {
public function testEntity() {
$media = Media::create([
'bundle' => $this->testMediaType
->id(),
]);
$this
->assertSame($media, $media
->setOwnerId($this->user
->id()), 'setOwnerId() method returns its own entity.');
}
public function testNameBaseField() {
$field_definitions = $this->container
->get('entity_field.manager')
->getBaseFieldDefinitions('media');
$this
->assertTrue($field_definitions['name']
->isDisplayConfigurable('view'));
$this
->assertSame($field_definitions['name']
->getDisplayOptions('view'), [
'region' => 'hidden',
]);
}
public function testGetCurrentUserId() {
$this
->assertEquals([
'1',
], Media::getCurrentUserId());
}
}