Passed
Pull Request — master (#5)
by Alex
02:16
created

ConnectionConfigsTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 31
c 1
b 0
f 0
dl 0
loc 48
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testHasConnectionConfig() 0 8 1
A testGetConnectionConfig() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ArpTest\LaminasDoctrine\Config;
6
7
use Arp\LaminasDoctrine\Config\ConnectionConfigs;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * @covers \Arp\LaminasDoctrine\Config\ConnectionConfigs
12
 */
13
final class ConnectionConfigsTest extends TestCase
14
{
15
    /**
16
     * @var array<string, array<string, string>>
17
     */
18
    private array $configs = [
19
        'orm_default' => [
20
            'driverClass' => 'DefaultDriverClass',
21
            'host' => 'localhost',
22
            'port' => '3306',
23
            'user' => 'root',
24
            'password' => 'password',
25
            'dbname' => 'db_name',
26
        ],
27
        'FooConnection' => [
28
            'driverClass' => 'FooDriverClass',
29
            'host' => 'localhost',
30
            'port' => '3306',
31
            'user' => 'root',
32
            'password' => 'password',
33
            'dbname' => 'foo',
34
        ],
35
        'BarConnection' => [
36
            'driverClass' => 'BarDriverClass',
37
            'host' => 'localhost',
38
            'port' => '3306',
39
            'user' => 'root',
40
            'password' => 'password',
41
            'dbname' => 'bar',
42
        ],
43
    ];
44
45
    public function testHasConnectionConfig(): void
46
    {
47
        $connectionConfigs = new ConnectionConfigs($this->configs);
48
49
        $this->assertTrue($connectionConfigs->hasConnectionConfig('orm_default'));
50
        $this->assertTrue($connectionConfigs->hasConnectionConfig('FooConnection'));
51
        $this->assertTrue($connectionConfigs->hasConnectionConfig('BarConnection'));
52
        $this->assertFalse($connectionConfigs->hasConnectionConfig('baz'));
53
    }
54
55
    public function testGetConnectionConfig(): void
56
    {
57
        $connectionConfigs = new ConnectionConfigs($this->configs);
58
59
        $this->assertSame($this->configs['orm_default'], $connectionConfigs->getConnectionConfig('orm_default'));
60
        $this->assertSame($this->configs['FooConnection'], $connectionConfigs->getConnectionConfig('FooConnection'));
61
    }
62
}
63