Passed
Pull Request — master (#380)
by Wilmer
04:47 queued 01:51
created

DsnTest::testGetDriver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\Connection;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Db\Connection\Dsn;
9
10
/**
11
 * @group db
12
 */
13
final class DsnTest extends TestCase
14
{
15
    public function testGetDatabaseName(): void
16
    {
17
        $dsn = new Dsn('mysql', 'localhost', 'yiitest', '3306', ['charset' => 'utf8']);
18
        $this->assertSame('yiitest', $dsn->getDatabaseName());
19
    }
20
21
    public function testGetDriver(): void
22
    {
23
        $dsn = new Dsn('mysql', 'localhost', 'yiitest', '3306', ['charset' => 'utf8']);
24
        $this->assertSame('mysql', $dsn->getDriver());
25
    }
26
27
    public function testGetDsn(): void
28
    {
29
        $dsn = new Dsn('mysql', 'localhost', 'yiitest', '3306', ['charset' => 'utf8']);
30
        $this->assertSame('mysql:host=localhost;dbname=yiitest;port=3306;charset=utf8', $dsn->asString());
31
        $this->assertSame('mysql:host=localhost;dbname=yiitest;port=3306;charset=utf8', $dsn->__toString());
32
    }
33
34
    public function testGetHost(): void
35
    {
36
        $dsn = new Dsn('mysql', 'localhost', 'yiitest', '3306', ['charset' => 'utf8']);
37
        $this->assertSame('localhost', $dsn->getHost());
38
    }
39
40
    public function testGetPort(): void
41
    {
42
        $dsn = new Dsn('mysql', 'localhost', 'yiitest', '3306', ['charset' => 'utf8']);
43
        $this->assertSame('3306', $dsn->getPort());
44
    }
45
}
46