Conditions | 3 |
Paths | 2 |
Total Lines | 22 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | protected function initializeTestDatabaseTransactions(): void |
||
12 | { |
||
13 | $database = $this->app->make('db'); |
||
14 | |||
15 | foreach ($this->connectionsToTransact() as $name) { |
||
|
|||
16 | $connection = $database->connection($name); |
||
17 | $dispatcher = $connection->getEventDispatcher(); |
||
18 | |||
19 | $connection->unsetEventDispatcher(); |
||
20 | $connection->beginTransaction($this->transactionCollections); |
||
21 | $connection->setEventDispatcher($dispatcher); |
||
22 | } |
||
23 | |||
24 | $this->beforeApplicationDestroyed(function () use ($database) { |
||
25 | foreach ($this->connectionsToTransact() as $name) { |
||
26 | $connection = $database->connection($name); |
||
27 | $dispatcher = $connection->getEventDispatcher(); |
||
28 | |||
29 | $connection->unsetEventDispatcher(); |
||
30 | $connection->rollback(); |
||
31 | $connection->setEventDispatcher($dispatcher); |
||
32 | $connection->disconnect(); |
||
33 | } |
||
37 |