Passed
Push — master ( 87e63f...d6a1bd )
by Darío
02:40
created

DriverFactoryTest::testWrongDriverCreation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 11
rs 9.9666
c 0
b 0
f 0
1
<?php
2
/**
3
 * DronePHP (http://www.dronephp.com)
4
 *
5
 * @link      http://github.com/Pleets/DronePHP
6
 * @copyright Copyright (c) 2016-2018 Pleets. (http://www.pleets.org)
7
 * @license   http://www.dronephp.com/license
8
 * @author    Darío Rivera <[email protected]>
9
 */
10
namespace DroneTest\Util;
11
12
use Drone\Db\Driver\DriverFactory;
13
use PHPUnit\Framework\TestCase;
14
15
class DriverFactoryTest extends TestCase
16
{
17
    /**
18
     * Tests if we can build a ltrim statement with SQLFunction
19
     *
20
     * @return null
21
     */
22
    public function testDriverCreation()
23
    {
24
        $driver = DriverFactory::create([
25
            "dbhost"       => "localhost",
26
            "dbuser"       => "root",
27
            "dbpass"       => "",
28
            "dbname"       => "test",
29
            "dbchar"       => "utf8",
30
            "dbport"       => "3306",
31
            'driver'       => 'Mysqli',
32
            "auto_connect" => false
33
        ]);
34
35
        $this->assertInstanceOf('\Drone\Db\Driver\MySQL', $driver);
36
        $this->assertEquals('localhost', $driver->getDbhost());
37
        $this->assertEquals('root', $driver->getDbuser());
38
        $this->assertEquals('test', $driver->getDbname());
39
        $this->assertEquals('3306', $driver->getDbport());
40
    }
41
42
    /**
43
     * Tests handling when driver does not exists
44
     *
45
     * @expectedException RuntimeException
46
     */
47
    public function testWrongDriverCreation()
48
    {
49
        $driver = DriverFactory::create([
0 ignored issues
show
Unused Code introduced by
The assignment to $driver is dead and can be removed.
Loading history...
50
            "dbhost"       => "localhost",
51
            "dbuser"       => "root",
52
            "dbpass"       => "",
53
            "dbname"       => "test",
54
            "dbchar"       => "utf8",
55
            "dbport"       => "3306",
56
            'driver'       => 'fooBarDriver',
57
            "auto_connect" => false
58
        ]);
59
    }
60
}