1 | <?php |
||
17 | class StrategyFactoryTest extends Base |
||
18 | { |
||
19 | /** |
||
20 | * @group unit |
||
21 | */ |
||
22 | public function testCreateCallbackStrategy(): void |
||
23 | { |
||
24 | $callback = static function ($connections): void { |
||
|
|||
25 | }; |
||
26 | |||
27 | $strategy = StrategyFactory::create($callback); |
||
28 | |||
29 | $this->assertInstanceOf(CallbackStrategy::class, $strategy); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @group unit |
||
34 | */ |
||
35 | public function testCreateByName(): void |
||
36 | { |
||
37 | $strategyName = 'Simple'; |
||
38 | |||
39 | $strategy = StrategyFactory::create($strategyName); |
||
40 | |||
41 | $this->assertInstanceOf(Simple::class, $strategy); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @group unit |
||
46 | */ |
||
47 | public function testCreateByClass(): void |
||
48 | { |
||
49 | $strategy = new EmptyStrategy(); |
||
50 | |||
51 | $this->assertEquals($strategy, StrategyFactory::create($strategy)); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @group unit |
||
56 | */ |
||
57 | public function testCreateByClassName(): void |
||
58 | { |
||
59 | $strategy = StrategyFactory::create(EmptyStrategy::class); |
||
60 | |||
61 | $this->assertInstanceOf(EmptyStrategy::class, $strategy); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @group unit |
||
66 | */ |
||
67 | public function testFailCreate(): void |
||
68 | { |
||
69 | $this->expectException(\InvalidArgumentException::class); |
||
70 | |||
71 | $strategy = new \stdClass(); |
||
72 | |||
73 | StrategyFactory::create($strategy); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @group unit |
||
78 | */ |
||
79 | public function testNoCollisionWithGlobalNamespace(): void |
||
88 | } |
||
89 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.