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
|
|
|
|