Passed
Pull Request — 2.9 (#3517)
by
unknown
62:06
created

DBAL3516Test   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 21
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

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