|
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\Bundle\ContentBundle\Factory\RouteFactoryInterface; |
|
11
|
|
|
use SWP\Bundle\ContentBundle\Model\RouteInterface; |
|
12
|
|
|
use SWP\Bundle\ContentBundle\Model\RouteRepositoryInterface; |
|
13
|
|
|
use SWP\Bundle\ContentBundle\Service\RouteServiceInterface; |
|
14
|
|
|
|
|
15
|
|
|
final class RouteContext extends AbstractContext implements Context |
|
16
|
|
|
{ |
|
17
|
|
|
private $entityManager; |
|
18
|
|
|
|
|
19
|
|
|
private $routeFactory; |
|
20
|
|
|
|
|
21
|
|
|
private $routeRepository; |
|
22
|
|
|
|
|
23
|
|
|
private $routeService; |
|
24
|
|
|
|
|
25
|
|
|
public function __construct( |
|
26
|
|
|
EntityManagerInterface $entityManager, |
|
27
|
|
|
RouteFactoryInterface $routeFactory, |
|
28
|
|
|
RouteRepositoryInterface $routeRepository, |
|
29
|
|
|
RouteServiceInterface $routeService |
|
30
|
|
|
) { |
|
31
|
|
|
$this->entityManager = $entityManager; |
|
32
|
|
|
$this->routeFactory = $routeFactory; |
|
33
|
|
|
$this->routeRepository = $routeRepository; |
|
34
|
|
|
$this->routeService = $routeService; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @Given the following Routes: |
|
39
|
|
|
*/ |
|
40
|
|
|
public function theFollowingRoutes(TableNode $table) |
|
41
|
|
|
{ |
|
42
|
|
|
foreach ($table as $row => $columns) { |
|
43
|
|
|
/** @var RouteInterface $route */ |
|
44
|
|
|
$route = $this->routeFactory->create(); |
|
45
|
|
|
$this->fillObject($route, $columns); |
|
46
|
|
|
$this->routeService->createRoute($route); |
|
47
|
|
|
|
|
48
|
|
|
$this->entityManager->persist($route); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
$this->entityManager->flush(); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|