Completed
Pull Request — master (#3588)
by Andrej
14:44
created

TransactionTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 3
c 2
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Functional;
4
5
use Doctrine\DBAL\Platforms\MySqlPlatform;
6
use Doctrine\Tests\DbalFunctionalTestCase;
7
use PHPUnit\Framework\Error\Warning;
8
use function sleep;
9
10
class TransactionTest extends DbalFunctionalTestCase
11
{
12
    protected function setUp() : void
13
    {
14
        parent::setUp();
15
16
        Warning::$enabled = false; // we will ignore `MySQL server has gone away` warnings
17
18
        if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
19
            return;
20
        }
21
22
        $this->markTestSkipped('Restricted to MySQL.');
23
    }
24
25
    protected function tearDown() : void
26
    {
27
        Warning::$enabled = true;
28
        $this->resetSharedConn();
29
30
        parent::tearDown();
31
    }
32
33
    public function testCommitFalse() : void
34
    {
35
        $this->connection->query('SET SESSION wait_timeout=1');
36
37
        $this->assertTrue($this->connection->beginTransaction());
38
39
        sleep(2); // during the sleep mysql will close the connection
40
41
        $this->assertFalse($this->connection->commit());
42
    }
43
}
44