Passed
Push — master ( 68b04b...f7f8f7 )
by Eugene
02:12
created

testCreateTcpAcceptsOptionOfValidType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the tarantool/client package.
5
 *
6
 * (c) Eugene Leonovich <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Tarantool\Client\Tests\Unit\Connection;
15
16
use PHPUnit\Framework\TestCase;
17
use Tarantool\Client\Connection\StreamConnection;
18
use Tarantool\Client\Tests\PhpUnitCompat;
19
20
final class StreamConnectionTest extends TestCase
21
{
22
    use PhpUnitCompat;
23
24
    /**
25
     * @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideConnectionArrayOptionsOfValidTypes
26
     * @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideTcpExtraConnectionArrayOptionsOfValidTypes
27
     * @doesNotPerformAssertions
28
     */
29
    public function testCreateTcpAcceptsOptionOfValidType(string $optionName, $optionValue) : void
30
    {
31
        StreamConnection::createTcp(StreamConnection::DEFAULT_TCP_URI, [$optionName => $optionValue]);
32
    }
33
34
    /**
35
     * @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideConnectionArrayOptionsOfValidTypes
36
     * @doesNotPerformAssertions
37
     */
38
    public function testCreateUdsAcceptsOptionOfValidType(string $optionName, $optionValue) : void
39
    {
40
        StreamConnection::createUds('unix:///socket.sock', [$optionName => $optionValue]);
41
    }
42
43
    /**
44
     * @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideConnectionArrayOptionsOfInvalidTypes
45
     * @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideTcpExtraConnectionArrayOptionsOfInvalidTypes
46
     */
47
    public function testCreateTcpRejectsOptionOfInvalidType(string $optionName, $optionValue, string $expectedType) : void
48
    {
49
        $this->expectException(\TypeError::class);
50
        $this->expectExceptionMessageMatches("/must be of(?: the)? type $expectedType/");
51
52
        StreamConnection::createTcp(StreamConnection::DEFAULT_TCP_URI, [$optionName => $optionValue]);
53
    }
54
55
    /**
56
     * @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideConnectionArrayOptionsOfInvalidTypes
57
     */
58
    public function testCreateUdsRejectsOptionOfInvalidType(string $optionName, $optionValue, string $expectedType) : void
59
    {
60
        $this->expectException(\TypeError::class);
61
        $this->expectExceptionMessageMatches("/must be of(?: the)? type $expectedType/");
62
63
        StreamConnection::createUds('unix:///socket.sock', [$optionName => $optionValue]);
64
    }
65
}
66