public function ProvidedFieldsTest::testProvidedFields in Video Embed Field 8.2
Same name and namespace in other branches
- 8 modules/video_embed_media/tests/src/Kernel/ProvidedFieldsTest.php \Drupal\Tests\video_embed_media\Kernel\ProvidedFieldsTest::testProvidedFields()
Test the fields provided by the integration.
@dataProvider providedFieldsTestCases
File
- modules/
video_embed_media/ tests/ src/ Kernel/ ProvidedFieldsTest.php, line 96
Class
- ProvidedFieldsTest
- Test the provided fields.
Namespace
Drupal\Tests\video_embed_media\KernelCode
public function testProvidedFields($input, $field, $expected) {
$source_field = $this->plugin
->getSourceFieldDefinition($this->entityType);
$field_name = $source_field
->getName();
$entity = Media::create([
'bundle' => $this->entityType
->id(),
$field_name => [
[
'value' => $input,
],
],
]);
// The 'image_local_url' returns path to the local image only if it actually
// exists. Otherwise the default image is returned.
if ($field == 'image_local_uri') {
touch($expected);
}
$actual = $this->plugin
->getMetadata($entity, $field);
$this
->assertEquals($expected, $actual);
}