MediaTest.php
Same filename in this branch
Same filename in other branches
- 9 core/modules/media/tests/src/Kernel/MediaTest.php
- 9 core/modules/jsonapi/tests/src/Functional/MediaTest.php
- 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
- 9 core/modules/ckeditor/tests/src/FunctionalJavascript/MediaTest.php
- 10 core/modules/media/tests/src/Kernel/MediaTest.php
- 10 core/modules/jsonapi/tests/src/Functional/MediaTest.php
- 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
- 11.x core/modules/media/tests/src/Kernel/MediaTest.php
- 11.x core/modules/jsonapi/tests/src/Functional/MediaTest.php
- 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
Namespace
Drupal\Tests\media\KernelFile
-
core/
modules/ media/ tests/ src/ Kernel/ MediaTest.php
View source
<?php
namespace Drupal\Tests\media\Kernel;
use Drupal\media\Entity\Media;
/**
* Tests Media.
*
* @group media
*/
class MediaTest extends MediaKernelTestBase {
/**
* Tests various aspects of a media item.
*/
public function testEntity() {
$media = Media::create([
'bundle' => $this->testMediaType
->id(),
]);
$this->assertSame($media, $media->setOwnerId($this->user
->id()), 'setOwnerId() method returns its own entity.');
}
/**
* Tests the Media "name" base field behavior.
*/
public function testNameBaseField() {
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $field_definitions */
$field_definitions = $this->container
->get('entity_field.manager')
->getBaseFieldDefinitions('media');
// Ensure media name is configurable on manage display.
$this->assertTrue($field_definitions['name']->isDisplayConfigurable('view'));
// Ensure it is not visible by default.
$this->assertSame($field_definitions['name']->getDisplayOptions('view'), [
'region' => 'hidden',
]);
}
/**
* Tests the legacy method used as the default entity owner.
*
* @group legacy
* @expectedDeprecation The ::getCurrentUserId method is deprecated in 8.6.x and will be removed before 9.0.0.
*/
public function testGetCurrentUserId() {
$this->assertEquals([
'1',
], Media::getCurrentUserId());
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
MediaTest | Tests Media. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.