1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of TrackAdvance. |
5
|
|
|
* |
6
|
|
|
* (c) Boccard |
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
|
|
|
namespace App\Behat\Context\Cli; |
13
|
|
|
|
14
|
|
|
use Behat\Behat\Context\Context; |
15
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
16
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application; |
17
|
|
|
use Symfony\Component\Console\Command\Command; |
18
|
|
|
use Symfony\Component\Console\Helper\QuestionHelper; |
19
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
21
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
22
|
|
|
|
23
|
|
|
class DefaultContext implements Context |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var KernelInterface |
27
|
|
|
*/ |
28
|
|
|
protected $kernel; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var Application |
32
|
|
|
*/ |
33
|
|
|
protected $application; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var CommandTester |
37
|
|
|
*/ |
38
|
|
|
protected static $sharedTester; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var Command |
42
|
|
|
*/ |
43
|
|
|
protected $command; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var QuestionHelper |
47
|
|
|
*/ |
48
|
|
|
protected $questionHelper; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param KernelInterface $kernel |
52
|
|
|
*/ |
53
|
|
|
public function __construct(KernelInterface $kernel) |
54
|
|
|
{ |
55
|
|
|
$this->kernel = $kernel; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function setTester(CommandTester $tester) |
59
|
|
|
{ |
60
|
|
|
static::$sharedTester = $tester; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return CommandTester |
65
|
|
|
*/ |
66
|
|
|
public function getTester() |
67
|
|
|
{ |
68
|
|
|
return static::$sharedTester; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return ObjectManager |
73
|
|
|
*/ |
74
|
|
|
protected function getEntityManager() |
75
|
|
|
{ |
76
|
|
|
return $this->getService('doctrine')->getManager(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param string $id |
81
|
|
|
* |
82
|
|
|
* @return object |
83
|
|
|
*/ |
84
|
|
|
protected function getService($id) |
85
|
|
|
{ |
86
|
|
|
return $this->getContainer()->get($id); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return ContainerInterface |
91
|
|
|
*/ |
92
|
|
|
protected function getContainer() |
93
|
|
|
{ |
94
|
|
|
return $this->kernel->getContainer(); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|