|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the DriftPHP Project |
| 5 | + * |
| 6 | + * For the full copyright and license information, please view the LICENSE |
| 7 | + * file that was distributed with this source code. |
| 8 | + * |
| 9 | + * Feel free to edit as you please, and have fun. |
| 10 | + * |
| 11 | + * @author David Llop <[email protected]> |
| 12 | + */ |
| 13 | + |
| 14 | +declare(strict_types=1); |
| 15 | + |
| 16 | +namespace Drift\DBAL\Tests; |
| 17 | + |
| 18 | +use Drift\DBAL\Credentials; |
| 19 | +use PHPUnit\Framework\TestCase; |
| 20 | + |
| 21 | +/** |
| 22 | + * Class ConnectionTest. |
| 23 | + */ |
| 24 | +class CredentialsTest extends TestCase |
| 25 | +{ |
| 26 | + /** |
| 27 | + * Test that credentials works as expected with all the fields filled. |
| 28 | + */ |
| 29 | + public function testCredentialsCanBeConvertedToString() |
| 30 | + { |
| 31 | + $credentials = new Credentials('127.0.0.1', '3306', 'user', 'password', 'database'); |
| 32 | + |
| 33 | + $this-> assertEquals( 'user:[email protected]:3306/database', $credentials-> toString()); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Test that credentials works as expected without login information. |
| 38 | + */ |
| 39 | + public function testCredentialsCanBeConvertedToStringWithoutLogin() |
| 40 | + { |
| 41 | + $credentials = new Credentials('127.0.0.1', '3306', '', '', 'database'); |
| 42 | + |
| 43 | + $this->assertEquals('127.0.0.1:3306/database', $credentials->toString()); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Test that credentials works as expected without password. |
| 48 | + */ |
| 49 | + public function testCredentialsCanBeConvertedToStringWithoutPassword() |
| 50 | + { |
| 51 | + $credentials = new Credentials('127.0.0.1', '3306', 'user', '', 'database'); |
| 52 | + |
| 53 | + $this-> assertEquals( '[email protected]:3306/database', $credentials-> toString()); |
| 54 | + } |
| 55 | +} |
0 commit comments