Total Complexity | 2 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
12 | final class FactorySingletonTest extends TestCase |
||
13 | { |
||
14 | public function test_singleton_returns_same_instance(): void |
||
15 | { |
||
16 | $factory = new class() extends AbstractFactory { |
||
17 | public function createObject(): CustomInterface |
||
18 | { |
||
19 | return $this->singleton(CustomInterface::class, static fn (): CustomClass => new CustomClass()); |
||
20 | } |
||
21 | }; |
||
22 | $a = $factory->createObject(); |
||
23 | $b = $factory->createObject(); |
||
24 | |||
25 | self::assertSame($a, $b); |
||
26 | } |
||
27 | |||
28 | public function test_without_singleton_returns_new_instance(): void |
||
41 | } |
||
42 | } |
||
43 |