Total Complexity | 2 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class ReopeningEntityManagerTest extends TestCase |
||
12 | { |
||
13 | /** |
||
14 | * @test |
||
15 | * @dataProvider provideWrapped |
||
16 | */ |
||
17 | public function wrappedEntityManagerIsOnlyRecreatedWhenCurrentOneIsClosed( |
||
18 | EntityManagerInterface $wrapped, |
||
19 | bool $shouldRecreate |
||
20 | ): void { |
||
21 | $factoryCalls = 0; |
||
22 | $reopeningEm = new ReopeningEntityManager(static function () use ($wrapped, &$factoryCalls) { |
||
23 | $factoryCalls++; |
||
24 | return $wrapped; |
||
25 | }); |
||
26 | |||
27 | $reopeningEm->open(); |
||
28 | |||
29 | $this->assertEquals($shouldRecreate, $factoryCalls === 2); |
||
30 | } |
||
31 | |||
32 | public function provideWrapped(): iterable |
||
43 | } |
||
44 | } |
||
45 |