Skip to content

Commit

Permalink
Merge pull request #121 from openeuropa/EWPP-32
Browse files Browse the repository at this point in the history
EWPP-32: Add createMediaRemoteVideo to MediaContext.
  • Loading branch information
ademarco authored Aug 11, 2020
2 parents cd39489 + f073809 commit 9216650
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/Behat/MediaContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,33 @@ public function createMediaAvPortalPhotos(TableNode $table): void {
}
}

/**
* Creates media Remote video with the specified URLs.
*
* Usage example:
*
* Given the following remote videos:
* | url |
* | url 1 |
* | ... |
*
* @Given the following remote video(s):
*/
public function createMediaRemoteVideo(TableNode $table): void {
foreach ($table->getColumnsHash() as $hash) {
$media = \Drupal::entityTypeManager()
->getStorage('media')->create([
'bundle' => 'remote_video',
'oe_media_oembed_video' => $hash['url'],
'status' => 1,
]);
$media->save();

// Store for cleanup.
$this->media[] = $media;
}
}

/**
* Remove any created media.
*
Expand Down

0 comments on commit 9216650

Please sign in to comment.