|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SWP\Behat\Contexts; |
|
6
|
|
|
|
|
7
|
|
|
use Behat\Behat\Context\Context; |
|
8
|
|
|
use Behat\Gherkin\Node\TableNode; |
|
9
|
|
|
use SWP\Bundle\ContentBundle\Doctrine\ArticleMediaRepositoryInterface; |
|
10
|
|
|
use SWP\Bundle\ContentBundle\Doctrine\SlideshowRepositoryInterface; |
|
11
|
|
|
use SWP\Bundle\ContentBundle\Model\SlideshowItemInterface; |
|
12
|
|
|
use SWP\Component\Storage\Factory\FactoryInterface; |
|
13
|
|
|
|
|
14
|
|
View Code Duplication |
final class SlideshowItemContext extends AbstractContext implements Context |
|
15
|
|
|
{ |
|
16
|
|
|
private $slideshowItemFactory; |
|
17
|
|
|
|
|
18
|
|
|
private $slideshowRepository; |
|
19
|
|
|
|
|
20
|
|
|
private $articleMediaRepository; |
|
21
|
|
|
|
|
22
|
|
|
public function __construct( |
|
23
|
|
|
FactoryInterface $slideshowItemFactory, |
|
24
|
|
|
SlideshowRepositoryInterface $slideshowRepository, |
|
25
|
|
|
ArticleMediaRepositoryInterface $articleRepository |
|
26
|
|
|
) { |
|
27
|
|
|
$this->slideshowItemFactory = $slideshowItemFactory; |
|
28
|
|
|
$this->slideshowRepository = $slideshowRepository; |
|
29
|
|
|
$this->articleMediaRepository = $articleRepository; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @Given the following Slideshow Items: |
|
34
|
|
|
*/ |
|
35
|
|
|
public function theFollowingSlideshowItems(TableNode $table) |
|
36
|
|
|
{ |
|
37
|
|
|
foreach ($table as $row => $columns) { |
|
38
|
|
|
/** @var SlideshowItemInterface $slideshowItem */ |
|
39
|
|
|
$slideshowItem = $this->slideshowItemFactory->create(); |
|
40
|
|
|
$slideshow = $this->slideshowRepository->findOneBy(['code' => $columns['slideshow']]); |
|
41
|
|
|
$columns['article_media'] = $this->articleMediaRepository->findOneBy(['key' => $columns['media']]); |
|
42
|
|
|
unset($columns['slideshow'], $columns['media']); |
|
43
|
|
|
|
|
44
|
|
|
$this->fillObject($slideshowItem, $columns); |
|
45
|
|
|
|
|
46
|
|
|
$slideshow->addItem($slideshowItem); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$this->slideshowRepository->flush(); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|