Completed
Push — develop ( 40c4f3...ed7ad1 )
by Sergei
62:39
created

EasyConnectStringTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 26
dl 0
loc 51
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A connectionParametersProvider() 0 34 1
A testFromConnectionParameters() 0 5 1
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
     *
13
     * @dataProvider connectionParametersProvider
14
     */
15
    public function testFromConnectionParameters(array $params, string $expected) : void
16
    {
17
        $string = EasyConnectString::fromConnectionParameters($params);
18
19
        $this->assertSame($expected, (string) $string);
20
    }
21
22
    /**
23
     * @return mixed[]
24
     */
25
    public static function connectionParametersProvider() : iterable
26
    {
27
        return [
28
            'empty-params' => [[],''],
29
            'common-params' => [
30
                [
31
                    'host' => 'oracle.example.com',
32
                    'port' => 1521,
33
                    'dbname' => 'XE',
34
                ],
35
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle.example.com)(PORT=1521))(CONNECT_DATA=(SID=XE)))',
36
            ],
37
            'no-db-name' => [
38
                ['host' => 'localhost'],
39
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))',
40
            ],
41
            'service' => [
42
                [
43
                    'host' => 'localhost',
44
                    'port' => 1521,
45
                    'service' => true,
46
                    'servicename' => 'BILLING',
47
                ],
48
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=BILLING)))',
49
            ],
50
            'advanced-params' => [
51
                [
52
                    'host' => 'localhost',
53
                    'port' => 41521,
54
                    'dbname' => 'XE',
55
                    'instancename' => 'SALES',
56
                    'pooled' => true,
57
                ],
58
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=41521))(CONNECT_DATA=(SID=XE)(INSTANCE_NAME=SALES)(SERVER=POOLED)))',
59
            ],
60
        ];
61
    }
62
}
63