function MediaSourceTest::testGetSourceFieldValue
Same name in other branches
- 9 core/modules/media/tests/src/Kernel/MediaSourceTest.php \Drupal\Tests\media\Kernel\MediaSourceTest::testGetSourceFieldValue()
- 10 core/modules/media/tests/src/Kernel/MediaSourceTest.php \Drupal\Tests\media\Kernel\MediaSourceTest::testGetSourceFieldValue()
- 11.x core/modules/media/tests/src/Kernel/MediaSourceTest.php \Drupal\Tests\media\Kernel\MediaSourceTest::testGetSourceFieldValue()
Tests the getSourceFieldValue() method.
File
-
core/
modules/ media/ tests/ src/ Kernel/ MediaSourceTest.php, line 212
Class
- MediaSourceTest
- Tests media source plugins related logic.
Namespace
Drupal\Tests\media\KernelCode
public function testGetSourceFieldValue() {
/** @var \Drupal\media\MediaInterface $media */
$media = Media::create([
'bundle' => $this->testMediaType
->id(),
'field_media_test' => 'some_value',
]);
$media->save();
$media_source = $media->getSource();
$this->assertSame('some_value', $media_source->getSourceFieldValue($media));
// Test that NULL is returned if there is no value in the source field.
$media->set('field_media_test', NULL)
->save();
$this->assertNull($media_source->getSourceFieldValue($media));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.