Completed
Push — checkout-consistent-prices ( af49ca )
by Kamil
13:24
created

MediaElement   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isImageDisplayed() 0 13 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sylius\Behat\Element\Product\ShowPage;
15
16
use FriendsOfBehat\PageObjectExtension\Element\Element;
17
18
final class MediaElement extends Element implements MediaElementInterface
19
{
20
    public function isImageDisplayed(): bool
21
    {
22
        $imageElement = $this->getDocument()->find('css', '#media a img');
23
        if ($imageElement === null) {
24
            return false;
25
        }
26
        $imageUrl = $imageElement->getAttribute('src');
27
        $this->getDriver()->visit($imageUrl);
28
        $pageText = $this->getDocument()->getText();
29
        $this->getDriver()->back();
30
31
        return false === stripos($pageText, '404 Not Found');
32
    }
33
}
34