Completed
Pull Request — 1.5 (#758)
by Paweł
11:13
created

ContentListContext::theFollowingContentLists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
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 Doctrine\ORM\EntityManagerInterface;
10
use SWP\Component\ContentList\Repository\ContentListRepositoryInterface;
11
use SWP\Component\Storage\Factory\FactoryInterface;
12
13
final class ContentListContext extends AbstractContext implements Context
14
{
15
    private $contentListFactory;
16
17
    private $contentListRepository;
18
19
    private $entityManager;
20
21
    public function __construct(FactoryInterface $contentListFactory, ContentListRepositoryInterface $contentListRepository, EntityManagerInterface $entityManager)
22
    {
23
        $this->contentListFactory = $contentListFactory;
24
        $this->contentListRepository = $contentListRepository;
25
        $this->entityManager = $entityManager;
26
    }
27
28
    /**
29
     * @Given the following Content Lists:
30
     */
31
    public function theFollowingContentLists(TableNode $table)
32
    {
33
        foreach ($table as $row => $columns) {
34
            $contentList = $this->contentListFactory->create();
35
            $this->fillObject($contentList, $columns);
36
            $this->entityManager->persist($contentList);
37
        }
38
39
        $this->entityManager->flush();
40
    }
41
}
42