Skip to content

Commit

Permalink
OPENEUROPA-2416: Update behat steps to allow more than one item per p…
Browse files Browse the repository at this point in the history
…age.
  • Loading branch information
imanoleguskiza committed Feb 4, 2020
1 parent 8765308 commit be7448b
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions tests/Behat/AvPortalContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,20 @@ public function assertAvPortalVideoIframe(string $title): void {

$media = reset($media);
$ref = $media->get('oe_media_avportal_video')->value;
$this->assertSession()->elementAttributeContains('css', 'iframe', 'src', $ref);
$iframes = $this->getSession()->getPage()->findAll('css', 'iframe');
if (empty($iframes)) {
throw new \Exception('No iframes found on the page.');

}
$video_found = FALSE;
foreach ($iframes as $iframe) {
if (strpos($iframe->getAttribute('src'), $ref) !== FALSE) {
$video_found = TRUE;
}
}
if (!$video_found) {
throw new \Exception(sprintf('The video named "%s" was not found on the page.', $title));
}
}

/**
Expand All @@ -95,8 +108,20 @@ public function assertAvPortalPhoto(string $title, string $src): void {
if (!$media) {
throw new \Exception(sprintf('The media named "%s" does not exist', $title));
}
$images = $this->getSession()->getPage()->findAll('css', 'img.avportal-photo');
if (empty($images)) {
throw new \Exception('No avportal images found on the page.');

$this->assertSession()->elementAttributeContains('css', 'img.avportal-photo', 'src', $src);
}
$image_found = FALSE;
foreach ($images as $image) {
if (strpos($image->getAttribute('src'), $src) !== FALSE) {
$image_found = TRUE;
}
}
if (!$image_found) {
throw new \Exception(sprintf('The imaged named "%s" was not found on the page.', $title));
}
}

/**
Expand Down

0 comments on commit be7448b

Please sign in to comment.