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