Completed
Push — master ( b1f992...6891e7 )
by Marco
17s queued 12s
created

testFromConnectionParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Driver\AbstractOracleDriver;
4
5
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
6
use PHPUnit\Framework\TestCase;
7
8
class EasyConnectStringTest extends TestCase
9
{
10
    /**
11
     * @param mixed[] $params
12
     * @dataProvider connectionParametersProvider
13
     */
14
    public function testFromConnectionParameters(array $params, string $expected) : void
15
    {
16
        $string = EasyConnectString::fromConnectionParameters($params);
17
18
        $this->assertSame($expected, (string) $string);
19
    }
20
21
    /**
22
     * @return mixed[]
23
     */
24
    public static function connectionParametersProvider() : iterable
25
    {
26
        return [
27
            'empty-params' => [[],''],
28
            'common-params' => [
29
                [
30
                    'host' => 'oracle.example.com',
31
                    'port' => 1521,
32
                    'dbname' => 'XE',
33
                ],
34
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle.example.com)(PORT=1521))(CONNECT_DATA=(SID=XE)))',
35
            ],
36
            'no-db-name' => [
37
                ['host' => 'localhost'],
38
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))',
39
            ],
40
            'service' => [
41
                [
42
                    'host' => 'localhost',
43
                    'port' => 1521,
44
                    'service' => true,
45
                    'servicename' => 'BILLING',
46
                ],
47
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=BILLING)))',
48
            ],
49
            'advanced-params' => [
50
                [
51
                    'host' => 'localhost',
52
                    'port' => 41521,
53
                    'dbname' => 'XE',
54
                    'instancename' => 'SALES',
55
                    'pooled' => true,
56
                ],
57
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=41521))(CONNECT_DATA=(SID=XE)(INSTANCE_NAME=SALES)(SERVER=POOLED)))',
58
            ],
59
        ];
60
    }
61
}
62