public function MediaEntityContext::fromEmbedCode in Lightning Media 8
Same name and namespace in other branches
- 8.2 tests/contexts/MediaEntityContext.behat.inc \Acquia\LightningExtension\Context\MediaEntityContext::fromEmbedCode()
- 8.3 tests/contexts/MediaEntityContext.behat.inc \Acquia\LightningExtension\Context\MediaEntityContext::fromEmbedCode()
Creates a media item from an embed code.
@Given :bundle media from embed code:
@When I create :bundle media from embed code:
Parameters
string $bundle: The media bundle ID.
\Behat\Gherkin\Node\PyStringNode $embed_code: The embed code.
File
- tests/
contexts/ MediaEntityContext.behat.inc, line 55
Class
Namespace
Acquia\LightningExtension\ContextCode
public function fromEmbedCode($bundle, PyStringNode $embed_code) {
$media = Media::create([
'bundle' => $bundle,
'name' => $this
->getRandom()
->string(),
'embed_code' => (string) $embed_code,
'field_media_in_library' => TRUE,
]);
$this
->getContext(EntityContext::class)
->save($media
->setPublished());
}