-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test credentials as string without password (#20)
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the DriftPHP Project | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Feel free to edit as you please, and have fun. | ||
* | ||
* @author David Llop <[email protected]> | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Drift\DBAL\Tests; | ||
|
||
use Drift\DBAL\Credentials; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class ConnectionTest. | ||
*/ | ||
class CredentialsTest extends TestCase | ||
{ | ||
/** | ||
* Test that credentials works as expected with all the fields filled. | ||
*/ | ||
public function testCredentialsCanBeConvertedToString() | ||
{ | ||
$credentials = new Credentials('127.0.0.1', '3306', 'user', 'password', 'database'); | ||
|
||
$this->assertEquals('user:[email protected]:3306/database', $credentials->toString()); | ||
} | ||
|
||
/** | ||
* Test that credentials works as expected without login information. | ||
*/ | ||
public function testCredentialsCanBeConvertedToStringWithoutLogin() | ||
{ | ||
$credentials = new Credentials('127.0.0.1', '3306', '', '', 'database'); | ||
|
||
$this->assertEquals('127.0.0.1:3306/database', $credentials->toString()); | ||
} | ||
|
||
/** | ||
* Test that credentials works as expected without password. | ||
*/ | ||
public function testCredentialsCanBeConvertedToStringWithoutPassword() | ||
{ | ||
$credentials = new Credentials('127.0.0.1', '3306', 'user', '', 'database'); | ||
|
||
$this->assertEquals('[email protected]:3306/database', $credentials->toString()); | ||
} | ||
} |