|
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\Page\Admin\Product; |
|
15
|
|
|
|
|
16
|
|
|
use Behat\Mink\Session; |
|
17
|
|
|
use Sylius\Behat\Page\Admin\Crud\IndexPage as CrudIndexPage; |
|
18
|
|
|
use Sylius\Behat\Service\Accessor\TableAccessorInterface; |
|
19
|
|
|
use Sylius\Behat\Service\Checker\ImageExistenceCheckerInterface; |
|
20
|
|
|
use Symfony\Component\Routing\RouterInterface; |
|
21
|
|
|
|
|
22
|
|
|
final class IndexPage extends CrudIndexPage implements IndexPageInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** @var ImageExistenceCheckerInterface */ |
|
25
|
|
|
private $imageExistenceChecker; |
|
26
|
|
|
|
|
27
|
|
|
public function __construct( |
|
28
|
|
|
Session $session, |
|
29
|
|
|
array $parameters, |
|
30
|
|
|
RouterInterface $router, |
|
31
|
|
|
TableAccessorInterface $tableAccessor, |
|
32
|
|
|
string $routeName, |
|
33
|
|
|
ImageExistenceCheckerInterface $imageExistenceChecker |
|
34
|
|
|
) { |
|
35
|
|
|
parent::__construct($session, $parameters, $router, $tableAccessor, $routeName); |
|
36
|
|
|
|
|
37
|
|
|
$this->imageExistenceChecker = $imageExistenceChecker; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* {@inheritdoc} |
|
42
|
|
|
*/ |
|
43
|
|
|
public function filterByTaxon($taxonName) |
|
44
|
|
|
{ |
|
45
|
|
|
$this->getElement('taxon_filter', ['%taxon%' => $taxonName])->click(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function hasProductAccessibleImage(string $productCode): bool |
|
49
|
|
|
{ |
|
50
|
|
|
$productRow = $this->getTableAccessor()->getRowWithFields($this->getElement('table'), ['code' => $productCode]); |
|
51
|
|
|
$imageUrl = $productRow->find('css', 'img')->getAttribute('src'); |
|
52
|
|
|
|
|
53
|
|
|
return $this->imageExistenceChecker->doesImageWithUrlExist($imageUrl, 'sylius_admin_product_thumbnail'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritdoc} |
|
58
|
|
|
*/ |
|
59
|
|
|
protected function getDefinedElements() |
|
60
|
|
|
{ |
|
61
|
|
|
return array_merge(parent::getDefinedElements(), [ |
|
62
|
|
|
'taxon_filter' => '.item a:contains("%taxon%")', |
|
63
|
|
|
]); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|