Passed
Pull Request — master (#23)
by Marc
03:04
created

OptionsTest::testAccessors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
c 0
b 0
f 0
rs 9.0856
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace TBolier\RethinkQL\UnitTest\Connection;
5
6
use TBolier\RethinkQL\Connection\Options;
7
use TBolier\RethinkQL\UnitTest\BaseUnitTestCase;
8
9
class OptionsTest extends BaseUnitTestCase
10
{
11
    /**
12
     * @return void
13
     * @throws \Exception
14
     */
15
    public function testAccessors(): void
16
    {
17
        $config = [
18
            'hostname' => 'example.test',
19
            'port' => 42,
20
            'dbname' => 'test',
21
            'user' => 'admin',
22
            'password' => 'secret',
23
            'timeout' => 120,
24
            'timeout_stream' => 300,
25
            'ssl' => true,
26
        ];
27
28
        $options = new Options($config);
29
30
        $this->assertEquals($config['hostname'], $options->getHostname());
31
        $this->assertEquals($config['port'], $options->getPort());
32
        $this->assertEquals($config['dbname'], $options->getDbName());
33
        $this->assertEquals($config['user'], $options->getUser());
34
        $this->assertEquals($config['password'], $options->getPassword());
35
        $this->assertEquals($config['timeout'], $options->getTimeout());
36
        $this->assertEquals($config['timeout_stream'], $options->getTimeoutStream());
37
        $this->assertEquals($config['ssl'], $options->isSsl());
38
    }
39
40
    /**
41
     * @return void
42
     * @throws \Exception
43
     */
44
    public function testIfHasDefaultDatabaseReturnsTrue(): void
45
    {
46
        $config = [
47
            'dbname' => 'test',
48
        ];
49
50
        $options = new Options($config);
51
52
        $this->assertTrue($options->hasDefaultDatabase());
53
    }
54
55
    /**
56
     * @return void
57
     * @throws \Exception
58
     */
59
    public function testIfHasDefaultDatabaseReturnsFalse(): void
60
    {
61
        $config = [];
62
63
        $options = new Options($config);
64
65
        $this->assertFalse($options->hasDefaultDatabase());
66
    }
67
}
68