|
1
|
|
|
<?php |
|
2
|
|
|
namespace Yoanm\Behat3SymfonyExtension\Dispatcher; |
|
3
|
|
|
|
|
4
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
|
5
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
|
6
|
|
|
use Yoanm\Behat3SymfonyExtension\Event\Events; |
|
7
|
|
|
use Yoanm\Behat3SymfonyExtension\Event\KernelEvent; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Will dispatch events related to symfony app kernel |
|
11
|
|
|
* It's just a wrapper to have the minimum of requirements in the AppKernel mock |
|
12
|
|
|
* and the maximum of code coverage for this extension |
|
13
|
|
|
* @see Yoanm\Behat3SymfonyExtension\Factory\KernelFactory::load() |
|
14
|
|
|
*/ |
|
15
|
|
|
class BehatKernelEventDispatcher |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var EventDispatcherInterface */ |
|
18
|
|
|
private $behatEventDispatcher; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @param EventDispatcherInterface $behatEventDispatcher |
|
22
|
|
|
*/ |
|
23
|
4 |
|
public function __construct(EventDispatcherInterface $behatEventDispatcher) |
|
24
|
|
|
{ |
|
25
|
4 |
|
$this->behatEventDispatcher = $behatEventDispatcher; |
|
26
|
4 |
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param KernelInterface $kernel |
|
30
|
|
|
*/ |
|
31
|
1 |
|
public function beforeBoot(KernelInterface $kernel) |
|
32
|
|
|
{ |
|
33
|
1 |
|
$this->behatEventDispatcher->dispatch( |
|
34
|
1 |
|
Events::BEFORE_KERNEL_BOOT, |
|
35
|
1 |
|
new KernelEvent($kernel) |
|
36
|
1 |
|
); |
|
37
|
1 |
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param KernelInterface $kernel |
|
41
|
|
|
*/ |
|
42
|
1 |
|
public function afterBoot(KernelInterface $kernel) |
|
43
|
|
|
{ |
|
44
|
1 |
|
$this->behatEventDispatcher->dispatch( |
|
45
|
1 |
|
Events::AFTER_KERNEL_BOOT, |
|
46
|
1 |
|
new KernelEvent($kernel) |
|
47
|
1 |
|
); |
|
48
|
1 |
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param KernelInterface $kernel |
|
52
|
|
|
*/ |
|
53
|
1 |
|
public function beforeShutdown(KernelInterface $kernel) |
|
54
|
|
|
{ |
|
55
|
1 |
|
$this->behatEventDispatcher->dispatch( |
|
56
|
1 |
|
Events::BEFORE_KERNEL_SHUTDOWN, |
|
57
|
1 |
|
new KernelEvent($kernel) |
|
58
|
1 |
|
); |
|
59
|
1 |
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param KernelInterface $kernel |
|
63
|
|
|
*/ |
|
64
|
1 |
|
public function afterShutdown(KernelInterface $kernel) |
|
65
|
|
|
{ |
|
66
|
1 |
|
$this->behatEventDispatcher->dispatch( |
|
67
|
1 |
|
Events::AFTER_KERNEL_SHUTDOWN, |
|
68
|
1 |
|
new KernelEvent($kernel) |
|
69
|
1 |
|
); |
|
70
|
1 |
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|