SQLServerPlatformTest.php 1.35 KB
Newer Older
1 2
<?php

3
namespace Doctrine\DBAL\Tests\Platforms;
4

5
use Doctrine\DBAL\LockMode;
6
use Doctrine\DBAL\Platforms\AbstractPlatform;
7
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
8

9
class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase
10
{
11
    public function createPlatform() : AbstractPlatform
12
    {
13
        return new SQLServer2012Platform();
14 15
    }

16
    /**
17 18
     * @param int|bool|null $lockMode
     *
19 20 21
     * @group DDC-2310
     * @dataProvider getLockHints
     */
22
    public function testAppendsLockHint($lockMode, string $lockHint) : void
23 24 25 26
    {
        $fromClause     = 'FROM users';
        $expectedResult = $fromClause . $lockHint;

Sergei Morozov's avatar
Sergei Morozov committed
27
        self::assertSame($expectedResult, $this->platform->appendLockHint($fromClause, $lockMode));
28 29
    }

30 31 32 33
    /**
     * @return mixed[][]
     */
    public static function getLockHints() : iterable
34
    {
Sergei Morozov's avatar
Sergei Morozov committed
35 36 37 38 39 40 41 42 43
        return [
            [null, ''],
            [false, ''],
            [true, ''],
            [LockMode::NONE, ' WITH (NOLOCK)'],
            [LockMode::OPTIMISTIC, ''],
            [LockMode::PESSIMISTIC_READ, ' WITH (HOLDLOCK, ROWLOCK)'],
            [LockMode::PESSIMISTIC_WRITE, ' WITH (UPDLOCK, ROWLOCK)'],
        ];
44
    }
45

46 47 48 49
    public function testGeneratesTypeDeclarationForDateTimeTz() : void
    {
        self::assertEquals('DATETIMEOFFSET(6)', $this->platform->getDateTimeTzTypeDeclarationSQL([]));
    }
50
}