MssqlQueryBuilderTest.php 1.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
<?php

namespace yiiunit\framework\db\mssql;

use yiiunit\framework\db\QueryBuilderTest;
use yii\db\Query;

/**
 * @group db
 * @group mssql
 */
12
class MssqlQueryBuilderTest extends QueryBuilderTest
13
{
14
    public $driverName = 'sqlsrv';
AlexGx committed
15

16 17 18 19
    public function testOffsetLimit()
    {
        $expectedQuerySql = 'SELECT `id` FROM `exapmle` OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY';
        $expectedQueryParams = null;
AlexGx committed
20

21 22
        $query = new Query();
        $query->select('id')->from('example')->limit(10)->offset(5);
AlexGx committed
23

24
        list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query);
AlexGx committed
25

26 27 28
        $this->assertEquals($expectedQuerySql, $actualQuerySql);
        $this->assertEquals($expectedQueryParams, $actualQueryParams);
    }
AlexGx committed
29

30 31 32 33
    public function testLimit()
    {
        $expectedQuerySql = 'SELECT `id` FROM `exapmle` OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY';
        $expectedQueryParams = null;
AlexGx committed
34

35 36
        $query = new Query();
        $query->select('id')->from('example')->limit(10);
AlexGx committed
37

38
        list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query);
AlexGx committed
39

40 41 42
        $this->assertEquals($expectedQuerySql, $actualQuerySql);
        $this->assertEquals($expectedQueryParams, $actualQueryParams);
    }
AlexGx committed
43

44 45 46 47
    public function testOffset()
    {
        $expectedQuerySql = 'SELECT `id` FROM `exapmle` OFFSET 10 ROWS';
        $expectedQueryParams = null;
AlexGx committed
48

49 50
        $query = new Query();
        $query->select('id')->from('example')->offset(10);
AlexGx committed
51

52
        list($actualQuerySql, $actualQueryParams) = $this->getQueryBuilder()->build($query);
AlexGx committed
53

54 55 56
        $this->assertEquals($expectedQuerySql, $actualQuerySql);
        $this->assertEquals($expectedQueryParams, $actualQueryParams);
    }
AlexGx committed
57
}