Completed
Push — master ( 24b4eb...6e3afd )
by Marco
12s
created

Tests/DBAL/Platforms/SQLServerPlatformTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Doctrine\Tests\DBAL\Platforms;
4
5
use Doctrine\DBAL\LockMode;
6
use Doctrine\DBAL\Platforms\SQLServerPlatform;
7
use Doctrine\DBAL\Types\Type;
8
9
class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase
10
{
11
12
    public function createPlatform()
13
    {
14
        return new SQLServerPlatform;
15
    }
16
17
    /**
18
     * @group DDC-2310
19
     * @dataProvider getLockHints
20
     */
21 View Code Duplication
    public function testAppendsLockHint($lockMode, $lockHint)
22
    {
23
        $fromClause     = 'FROM users';
24
        $expectedResult = $fromClause . $lockHint;
25
26
        self::assertSame($expectedResult, $this->_platform->appendLockHint($fromClause, $lockMode));
27
    }
28
29
    /**
30
     * @group DBAL-2408
31
     * @dataProvider getModifyLimitQueries
32
     */
33
    public function testScrubInnerOrderBy($query, $limit, $offset, $expectedResult)
34
    {
35
        self::assertSame($expectedResult, $this->_platform->modifyLimitQuery($query, $limit, $offset));
36
    }
37
38 View Code Duplication
    public function getLockHints()
39
    {
40
        return array(
41
            array(null, ''),
42
            array(false, ''),
43
            array(true, ''),
44
            array(LockMode::NONE, ' WITH (NOLOCK)'),
45
            array(LockMode::OPTIMISTIC, ''),
46
            array(LockMode::PESSIMISTIC_READ, ' WITH (HOLDLOCK, ROWLOCK)'),
47
            array(LockMode::PESSIMISTIC_WRITE, ' WITH (UPDLOCK, ROWLOCK)'),
48
        );
49
    }
50
51
    public function getModifyLimitQueries()
52
    {
53
        return array(
54
            // Test re-ordered query with correctly-scrubbed ORDER BY clause
55
            array('SELECT id_0, MIN(sclr_2) AS dctrn_minrownum FROM (SELECT c0_.id AS id_0, c0_.title AS title_1, ROW_NUMBER() OVER(ORDER BY c0_.title ASC) AS sclr_2 FROM TestTable c0_ ORDER BY c0_.title ASC) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC', 30, null, 'WITH dctrn_cte AS (SELECT TOP 30 id_0, MIN(sclr_2) AS dctrn_minrownum FROM (SELECT c0_.id AS id_0, c0_.title AS title_1, ROW_NUMBER() OVER(ORDER BY c0_.title ASC) AS sclr_2 FROM TestTable c0_) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC) SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM dctrn_cte) AS doctrine_tbl WHERE doctrine_rownum BETWEEN 1 AND 30 ORDER BY doctrine_rownum ASC'),
56
57
            // Test re-ordered query with no scrubbed ORDER BY clause
58
            array('SELECT id_0, MIN(sclr_2) AS dctrn_minrownum FROM (SELECT c0_.id AS id_0, c0_.title AS title_1, ROW_NUMBER() OVER(ORDER BY c0_.title ASC) AS sclr_2 FROM TestTable c0_) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC', 30, null, 'WITH dctrn_cte AS (SELECT TOP 30 id_0, MIN(sclr_2) AS dctrn_minrownum FROM (SELECT c0_.id AS id_0, c0_.title AS title_1, ROW_NUMBER() OVER(ORDER BY c0_.title ASC) AS sclr_2 FROM TestTable c0_) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC) SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM dctrn_cte) AS doctrine_tbl WHERE doctrine_rownum BETWEEN 1 AND 30 ORDER BY doctrine_rownum ASC'),
59
        );
60
    }
61
62 View Code Duplication
    public function testGetDefaultValueDeclarationSQLForDateType()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
    {
64
        $currentDateSql = $this->_platform->getCurrentDateSQL();
65
        $field = array(
66
            'type'    => Type::getType('date'),
67
            'default' => $currentDateSql,
68
        );
69
70
        $this->assertEquals(
71
            " DEFAULT '".$currentDateSql."'",
72
            $this->_platform->getDefaultValueDeclarationSQL($field)
73
        );
74
    }
75
}
76