Completed
Pull Request — master (#3666)
by
unknown
62:28
created

testReturnsDatabaseNameWithConnectDescriptor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 17
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Driver;
4
5
use Doctrine\DBAL\Connection;
6
use Doctrine\DBAL\Driver;
7
use Doctrine\DBAL\Driver\AbstractOracleDriver;
8
use Doctrine\DBAL\Platforms\AbstractPlatform;
9
use Doctrine\DBAL\Platforms\Oracle122Platform;
10
use Doctrine\DBAL\Platforms\OraclePlatform;
11
use Doctrine\DBAL\Schema\AbstractSchemaManager;
12
use Doctrine\DBAL\Schema\OracleSchemaManager;
13
14
class AbstractOracleDriverTest extends AbstractDriverTest
15
{
16
    public function testReturnsDatabaseName() : void
17
    {
18
        $params = [
19
            'user'     => 'foo',
20
            'password' => 'bar',
21
            'dbname'   => 'baz',
22
        ];
23
24
        $connection = $this->getConnectionMock();
25
26
        $connection->expects($this->once())
27
            ->method('getParams')
28
            ->will($this->returnValue($params));
29
30
        self::assertSame($params['user'], $this->driver->getDatabase($connection));
31
    }
32
33
    public function testReturnsDatabaseNameWithConnectDescriptor() : void
34
    {
35
        $params = [
36
            'user'             => 'foo',
37
            'password'         => 'bar',
38
            'connectionstring' => '(DESCRIPTION=' .
39
                '(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' .
40
                '(CONNECT_DATA=(SERVICE_NAME=baz)))',
41
        ];
42
43
        $connection = $this->getConnectionMock();
44
45
        $connection->expects($this->once())
46
            ->method('getParams')
47
            ->will($this->returnValue($params));
48
49
        self::assertSame($params['user'], $this->driver->getDatabase($connection));
50
    }
51
52
    protected function createDriver() : Driver
53
    {
54
        return $this->getMockForAbstractClass(AbstractOracleDriver::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getMockFor...actOracleDriver::class) returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return Doctrine\DBAL\Driver.
Loading history...
55
    }
56
57
    protected function createPlatform() : AbstractPlatform
58
    {
59
        return new OraclePlatform();
60
    }
61
62
    protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
63
    {
64
        return new OracleSchemaManager($connection);
65
    }
66
67
    /**
68
     * {@inheritDoc}
69
     */
70
    protected function getDatabasePlatformsForVersions() : array
71
    {
72
        return [
73
            [' 9.0.1.0.0 ', OraclePlatform::class],
74
            [' 9.2.0.1.0 ', OraclePlatform::class],
75
            [' 10.1.0.2.0 ', OraclePlatform::class],
76
            [' 10.2.0.1.0 ', OraclePlatform::class],
77
            [' 11.1.0.6.0 ', OraclePlatform::class],
78
            [' 11.2.0.1.0 ', OraclePlatform::class],
79
            [' 11.2.0.2.0 ', OraclePlatform::class],
80
            [' 12.1.0.1.0 ', OraclePlatform::class],
81
            [' 12.2.0.1.0 ', Oracle122Platform::class],
82
            ['Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production', Oracle122Platform::class],
83
            [' 18.1.0.0.0 ', Oracle122Platform::class],
84
        ];
85
    }
86
87
    /**
88
     * {@inheritDoc}
89
     */
90
    protected static function getExceptionConversionData() : array
91
    {
92
        return [
93
            self::EXCEPTION_CONNECTION => [
94
                ['1017', null, null],
95
                ['12545', null, null],
96
            ],
97
            self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
98
                ['2292', null, null],
99
            ],
100
            self::EXCEPTION_INVALID_FIELD_NAME => [
101
                ['904', null, null],
102
            ],
103
            self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
104
                ['918', null, null],
105
                ['960', null, null],
106
            ],
107
            self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
108
                ['1400', null, null],
109
            ],
110
            self::EXCEPTION_SYNTAX_ERROR => [
111
                ['923', null, null],
112
            ],
113
            self::EXCEPTION_TABLE_EXISTS => [
114
                ['955', null, null],
115
            ],
116
            self::EXCEPTION_TABLE_NOT_FOUND => [
117
                ['942', null, null],
118
            ],
119
            self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
120
                ['1', null, null],
121
                ['2299', null, null],
122
                ['38911', null, null],
123
            ],
124
        ];
125
    }
126
}
127