Completed
Pull Request — 2.11.x (#2448)
by
unknown
12:14
created

ConnectorFactoryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 14
c 1
b 0
f 0
dl 0
loc 33
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateHighAvailability() 0 6 1
A testCreateRandom() 0 6 1
A testCreateDefault() 0 6 1
A testCreateUnknown() 0 7 1
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Connection;
4
5
use Doctrine\DBAL\Connections\ConnectorFactory;
6
use Doctrine\DBAL\Driver;
7
use Doctrine\DBAL\Exception\ConnectorException;
8
use Doctrine\Tests\DbalTestCase;
9
10
class ConnectorFactoryTest extends DbalTestCase
11
{
12
    public function testCreateHighAvailability() : void
13
    {
14
        $driverMock = $this->createMock(Driver::class);
15
        $params     = ['strategy' => 'high_availability'];
16
17
        $this->assertInstanceOf('Doctrine\DBAL\Connections\Connector\HighAvailabilityConnector', ConnectorFactory::create($params, $driverMock));
18
    }
19
20
    public function testCreateRandom() : void
21
    {
22
        $driverMock = $this->createMock(Driver::class);
23
        $params     = ['strategy' => 'random'];
24
25
        $this->assertInstanceOf('Doctrine\DBAL\Connections\Connector\RandomConnector', ConnectorFactory::create($params, $driverMock));
26
    }
27
28
    public function testCreateDefault() : void
29
    {
30
        $driverMock = $this->createMock(Driver::class);
31
        $params     = [];
32
33
        $this->assertInstanceOf('Doctrine\DBAL\Connections\Connector\RandomConnector', ConnectorFactory::create($params, $driverMock));
34
    }
35
36
    public function testCreateUnknown() : void
37
    {
38
        $this->expectException(ConnectorException::class);
39
        $driverMock = $this->createMock(Driver::class);
40
        $params     = ['strategy' => '12345'];
41
42
        ConnectorFactory::create($params, $driverMock);
43
    }
44
}
45