Failed Conditions
Pull Request — develop (#3523)
by
unknown
62:01
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
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