From f0738098b0d4476c612e6a6da95d99b4e0aae843 Mon Sep 17 00:00:00 2001 From: drishu Date: Tue, 28 Jul 2020 12:29:41 +0000 Subject: [PATCH] EWPP-32: Add createMediaRemoteVideo to MediaContext. --- tests/Behat/MediaContext.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/Behat/MediaContext.php b/tests/Behat/MediaContext.php index 7b4f8b5c..04759704 100644 --- a/tests/Behat/MediaContext.php +++ b/tests/Behat/MediaContext.php @@ -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. *