Passed
Pull Request — master (#3588)
by Andrej
11:38
created

TransactionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 5 1
A setUp() 0 9 2
A testCommitFalse() 0 9 1
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Functional;
4
5
use Doctrine\DBAL\Platforms\MySqlPlatform;
6
use Doctrine\Tests\DbalFunctionalTestCase;
7
use function sleep;
8
9
class TransactionTest extends DbalFunctionalTestCase
10
{
11
    protected function setUp() : void
12
    {
13
        parent::setUp();
14
15
        if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
16
            return;
17
        }
18
19
        $this->markTestSkipped('Restricted to MySQL.');
20
    }
21
22
    protected function tearDown() : void
23
    {
24
        $this->resetSharedConn();
25
26
        parent::tearDown();
27
    }
28
29
    public function testCommitFalse() : void
30
    {
31
        $this->connection->query('SET SESSION wait_timeout=1');
32
33
        $this->assertTrue($this->connection->beginTransaction());
34
35
        sleep(2); // during the sleep mysql will close the connection
36
37
        $this->assertFalse(@$this->connection->commit()); // we will ignore `MySQL server has gone away` warnings
38
    }
39
}
40