| Conditions | 1 |
| Paths | 1 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public function testTransactionShortcutException(): void |
||
| 19 | { |
||
| 20 | $db = $this->getConnection(true); |
||
| 21 | |||
| 22 | $this->expectException(Exception::class); |
||
| 23 | |||
| 24 | $db->transaction( |
||
| 25 | static function () use ($db) { |
||
| 26 | $db->createCommand()->insert('profile', ['description' => 'test transaction shortcut'])->execute(); |
||
| 27 | |||
| 28 | throw new Exception('Exception in transaction shortcut'); |
||
| 29 | } |
||
| 30 | ); |
||
| 31 | $profilesCount = $db->createCommand( |
||
| 32 | <<<SQL |
||
| 33 | SELECT COUNT(*) FROM {{profile}} WHERE [[description]] = 'test transaction shortcut' |
||
| 34 | SQL |
||
| 35 | )->queryScalar(); |
||
| 36 | |||
| 37 | $this->assertSame(0, $profilesCount, 'profile should not be inserted in transaction shortcut'); |
||
| 38 | } |
||
| 40 |