|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
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
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace spec\Sylius\Bundle\FixturesBundle\Loader; |
|
15
|
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
use Prophecy\Argument; |
|
18
|
|
|
use Sylius\Bundle\FixturesBundle\Listener\AfterSuiteListenerInterface; |
|
19
|
|
|
use Sylius\Bundle\FixturesBundle\Listener\BeforeSuiteListenerInterface; |
|
20
|
|
|
use Sylius\Bundle\FixturesBundle\Listener\SuiteEvent; |
|
21
|
|
|
use Sylius\Bundle\FixturesBundle\Loader\HookableSuiteLoader; |
|
22
|
|
|
use Sylius\Bundle\FixturesBundle\Loader\SuiteLoaderInterface; |
|
23
|
|
|
use Sylius\Bundle\FixturesBundle\Suite\SuiteInterface; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @author Kamil Kokot <[email protected]> |
|
27
|
|
|
*/ |
|
28
|
|
|
final class HookableSuiteLoaderSpec extends ObjectBehavior |
|
29
|
|
|
{ |
|
30
|
|
|
function let(SuiteLoaderInterface $decoratedSuiteLoader): void |
|
31
|
|
|
{ |
|
32
|
|
|
$this->beConstructedWith($decoratedSuiteLoader); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
function it_implements_suite_loader_interface(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$this->shouldImplement(SuiteLoaderInterface::class); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
function it_delegates_suite_loading_to_the_base_loader(SuiteLoaderInterface $decoratedSuiteLoader, SuiteInterface $suite): void |
|
41
|
|
|
{ |
|
42
|
|
|
$suite->getListeners()->willReturn([]); |
|
43
|
|
|
|
|
44
|
|
|
$decoratedSuiteLoader->load($suite)->shouldBeCalled(); |
|
45
|
|
|
|
|
46
|
|
|
$this->load($suite); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
function it_executes_before_suite_listeners( |
|
50
|
|
|
SuiteLoaderInterface $decoratedSuiteLoader, |
|
51
|
|
|
SuiteInterface $suite, |
|
52
|
|
|
BeforeSuiteListenerInterface $beforeSuiteListener |
|
53
|
|
|
): void { |
|
54
|
|
|
$suite->getListeners()->will(function () use ($beforeSuiteListener) { |
|
55
|
|
|
yield $beforeSuiteListener->getWrappedObject() => []; |
|
|
|
|
|
|
56
|
|
|
}); |
|
57
|
|
|
|
|
58
|
|
|
$beforeSuiteListener->beforeSuite(new SuiteEvent($suite->getWrappedObject()), [])->shouldBeCalledTimes(1); |
|
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
$decoratedSuiteLoader->load($suite)->shouldBeCalled(); |
|
61
|
|
|
|
|
62
|
|
|
$this->load($suite); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
function it_executes_after_suite_listeners( |
|
66
|
|
|
SuiteLoaderInterface $decoratedSuiteLoader, |
|
67
|
|
|
SuiteInterface $suite, |
|
68
|
|
|
AfterSuiteListenerInterface $afterSuiteListener |
|
69
|
|
|
): void { |
|
70
|
|
|
$suite->getListeners()->will(function () use ($afterSuiteListener) { |
|
71
|
|
|
yield $afterSuiteListener->getWrappedObject() => []; |
|
|
|
|
|
|
72
|
|
|
}); |
|
73
|
|
|
|
|
74
|
|
|
$decoratedSuiteLoader->load($suite)->shouldBeCalled(); |
|
75
|
|
|
|
|
76
|
|
|
$afterSuiteListener->afterSuite(new SuiteEvent($suite->getWrappedObject()), [])->shouldBeCalledTimes(1); |
|
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
$this->load($suite); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
function it_executes_customized_suite_listeners( |
|
82
|
|
|
SuiteLoaderInterface $decoratedSuiteLoader, |
|
83
|
|
|
SuiteInterface $suite, |
|
84
|
|
|
BeforeSuiteListenerInterface $beforeSuiteListener, |
|
85
|
|
|
AfterSuiteListenerInterface $afterSuiteListener |
|
86
|
|
|
): void { |
|
87
|
|
|
$suite->getListeners()->will(function () use ($beforeSuiteListener, $afterSuiteListener) { |
|
88
|
|
|
yield $beforeSuiteListener->getWrappedObject() => ['listener_option1' => 'listener_value1']; |
|
|
|
|
|
|
89
|
|
|
yield $afterSuiteListener->getWrappedObject() => ['listener_option2' => 'listener_value2']; |
|
|
|
|
|
|
90
|
|
|
}); |
|
91
|
|
|
|
|
92
|
|
|
$beforeSuiteListener->beforeSuite(new SuiteEvent($suite->getWrappedObject()), ['listener_option1' => 'listener_value1'])->shouldBeCalledTimes(1); |
|
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
$decoratedSuiteLoader->load($suite)->shouldBeCalled(); |
|
95
|
|
|
|
|
96
|
|
|
$afterSuiteListener->afterSuite(new SuiteEvent($suite->getWrappedObject()), ['listener_option2' => 'listener_value2'])->shouldBeCalledTimes(1); |
|
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
$this->load($suite); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.