public function MediaEntityContext::fromEmbedCode in Lightning Media 8.2
Same name and namespace in other branches
- 8 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 63
Class
- MediaEntityContext
- Contains step definitions for interacting with media entities.
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());
}