Failed Conditions
Push — master ( 5f5e96...daf37e )
by Adrien
03:02
created

TransportFactoryTest::providerDsn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 13
rs 9.9
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EcodevTests\Felix\Service;
6
7
use Ecodev\Felix\Service\TransportFactory;
8
use PHPUnit\Framework\TestCase;
9
10
class TransportFactoryTest extends TestCase
11
{
12
    /**
13
     * @dataProvider providerDsn
14
     */
15
    public function testDsn(null|array|string $input, string $expected): void
16
    {
17
        $actual = TransportFactory::dsn($input);
18
        self::assertSame($expected, $actual);
19
    }
20
21
    public function providerDsn(): iterable
22
    {
23
        yield [null, 'null://null'];
24
        yield ['', 'null://null'];
25
        yield ['smtp://my-user:my-pass@my-host:123', 'smtp://my-user:my-pass@my-host:123'];
26
        yield [[], 'null://null'];
27
        yield [['host' => '', 'port' => '', 'user' => '', 'password' => ''], 'null://null'];
28
        yield [['host' => '', 'port' => '', 'user' => 'my-user', 'password' => 'my-pass'], 'null://null'];
29
        yield 'port has default value' => [['host' => 'my-host'], 'smtp://my-host:587'];
30
        yield 'port has default value bis' => [['host' => 'my-host', 'port' => ''], 'smtp://my-host:587'];
31
        yield 'custom port' => [['host' => 'my-host', 'port' => '123'], 'smtp://my-host:123'];
32
        yield 'new style credentials' => [['host' => 'my-host', 'port' => '123', 'user' => 'my-user', 'password' => 'my-pass'], 'smtp://my-user:my-pass@my-host:123'];
33
        yield 'okpilot style credentials' => [['host' => 'my-host', 'port' => '123', 'connection_config' => ['username' => 'my-user', 'password' => 'my-pass']], 'smtp://my-user:my-pass@my-host:123'];
34
    }
35
}
36