Failed Conditions
Pull Request — develop (#3523)
by
unknown
62:01
created

DBAL3516Test::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 13
rs 9.7333
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\DBAL\Functional\Ticket;
6
7
use Doctrine\Tests\DbalFunctionalTestCase;
8
9
/**
10
 * @group DBAL-3516
11
 */
12
class DBAL3516Test extends DbalFunctionalTestCase
13
{
14
    protected function setUp() : void
15
    {
16
        parent::setUp();
17
18
        $platform = $this->connection->getDatabasePlatform()->getName();
19
20
        if ($platform !== 'mssql') {
21
            $this->markTestSkipped('Currently restricted to MSSQL');
22
        }
23
24
        $this->connection->query('CREATE TABLE dbal3516(id INT IDENTITY, test int);');
25
        $this->connection->query('CREATE TABLE dbal3516help(id INT IDENTITY, test int);');
26
        $this->connection->query(<<<SQL
27
CREATE TRIGGER dbal3516_after_insert ON dbal3516 AFTER INSERT AS 
28
    DECLARE @i INT = 0;
29
    
30
    WHILE @i < 3
31
    BEGIN
32
        INSERT INTO dbal3516help (test) VALUES (1);
33
        SET @i = @i + 1;
34
    END;
35
SQL
36
        );
37
    }
38
39
    public function testLastInsertIdRelatedToTheMainInsertStatement() : void
40
    {
41
        $this->connection->insert('dbal3516help', ['test' => 1]);
42
        $this->connection->lastInsertId();
43
        $this->connection->insert('dbal3516', ['test' => 1]);
44
        $this->assertEquals(1, $this->connection->lastInsertId());
45
    }
46
}
47