summaryrefslogtreecommitdiffstats
path: root/tests/Builder/TransactionStatementTest.php
blob: b431643f8d873c341a1835092b720903f0079ec1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

namespace SqlParser\Tests\Builder;

use SqlParser\Parser;

use SqlParser\Tests\TestCase;

class TransactionStatementTest extends TestCase
{

    public function testBuilderView()
    {
        $query = 'START TRANSACTION;' .
            'SELECT @A:=SUM(salary) FROM table1 WHERE type=1;' .
            'UPDATE table2 SET summary=@A WHERE type=1;' .
            'COMMIT;';

        $parser = new Parser($query);
        $stmt = $parser->statements[0];

        $this->assertEquals(
            'START TRANSACTION;' .
            'SELECT  @A:=SUM(salary) FROM table1 WHERE type=1 ;' .
            'UPDATE  table2 SET summary = @A WHERE type=1 ;' .
            'COMMIT',
            $stmt->build()
        );
    }
}