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

DsnTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetDsn() 0 5 1
A testGetHost() 0 4 1
A testGetDatabaseName() 0 4 1
A testGetDriver() 0 4 1
A testGetPort() 0 4 1
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