Passed
Push — phpstan-tests ( 6a2b78...974220 )
by Michael
61:35 queued 23s
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
declare(strict_types=1);
4
5
namespace Doctrine\Tests\DBAL\Driver\AbstractOracleDriver;
6
7
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
8
use PHPUnit\Framework\TestCase;
9
10
class EasyConnectStringTest extends TestCase
11
{
12
    /**
13
     * @param mixed[] $params
14
     *
15
     * @dataProvider connectionParametersProvider
16
     */
17
    public function testFromConnectionParameters(array $params, string $expected) : void
18
    {
19
        $string = EasyConnectString::fromConnectionParameters($params);
20
21
        $this->assertSame($expected, (string) $string);
22
    }
23
24
    /**
25
     * @return mixed[]
26
     */
27
    public static function connectionParametersProvider() : iterable
28
    {
29
        return [
30
            'empty-params' => [[],''],
31
            'common-params' => [
32
                [
33
                    'host' => 'oracle.example.com',
34
                    'port' => 1521,
35
                    'dbname' => 'XE',
36
                ],
37
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle.example.com)(PORT=1521))(CONNECT_DATA=(SID=XE)))',
38
            ],
39
            'no-db-name' => [
40
                ['host' => 'localhost'],
41
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))',
42
            ],
43
            'service' => [
44
                [
45
                    'host' => 'localhost',
46
                    'port' => 1521,
47
                    'service' => true,
48
                    'servicename' => 'BILLING',
49
                ],
50
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=BILLING)))',
51
            ],
52
            'advanced-params' => [
53
                [
54
                    'host' => 'localhost',
55
                    'port' => 41521,
56
                    'dbname' => 'XE',
57
                    'instancename' => 'SALES',
58
                    'pooled' => true,
59
                ],
60
                '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=41521))(CONNECT_DATA=(SID=XE)(INSTANCE_NAME=SALES)(SERVER=POOLED)))',
61
            ],
62
        ];
63
    }
64
}
65