Skip to content

Commit

Permalink
updated (renamed) Dsn test
Browse files Browse the repository at this point in the history
  • Loading branch information
dakujem committed Jul 14, 2020
1 parent 9456eb5 commit a78d7ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions tests/urlconfig.phpt → tests/dsn.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ namespace Dakujem\Cumulus\Test;
require_once __DIR__ . '/bootstrap.php';

use Dakujem\Cumulus\Dsn;
use Dakujem\Cumulus\UrlConfig;
use Tester\Assert;
use Tester\TestCase;

/**
* @author Andrej Rypak (dakujem) <xrypak@gmail.com>
*/
class _UrlConfigTest extends TestCase
class _DsnTest extends TestCase
{
protected function setUp()
{
Expand Down Expand Up @@ -195,7 +194,7 @@ class _UrlConfigTest extends TestCase
public function testUsage()
{
// test multiple ways to obtain config values
$dsn = new UrlConfig('mysql://john:secret@localhost:3306/my_db');
$dsn = new Dsn('mysql://john:secret@localhost:3306/my_db');
Assert::same('localhost', $dsn->get('host'), "Getter method access");
Assert::same('localhost', $dsn->host, "Magic props");
Assert::same('localhost', $dsn['host'], "Array access");
Expand Down Expand Up @@ -229,7 +228,7 @@ class _UrlConfigTest extends TestCase
*/
private function runCase($url, array $expected, bool $internalNull = false)
{
$dsn = new UrlConfig($url);
$dsn = new Dsn($url);

// sanity test
Assert::same($internalNull ? null : $url, $dsn->getUrl(), 'Getting the original URL');
Expand All @@ -250,9 +249,9 @@ class _UrlConfigTest extends TestCase
Assert::equal($expected, $dsn->getConfig(), "Getting complete configuration from $url");

// test PDO DSN
Assert::same($pdo, $dsn->getPdoDsn(), 'PDO DSN string');
Assert::same($pdo, $dsn->get('pdo', ''), 'PDO DSN string');
}
}

// run the test
(new _UrlConfigTest)->run();
(new _DsnTest)->run();
2 changes: 1 addition & 1 deletion tests/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
foreach (['urlconfig', 'lazyiterator',] as $test) {
$time1 = microtime(true);
require_once($dir . '/' . $test . '.phpt');
print '<hr/><pre>urlconfig.phpt | Finished at: ' . date('Y-m-d H:i:s') . ' | Runtime: ' . (microtime(true) - $time1) . 's</pre>';
print '<hr/><pre>' . $test . '.phpt | Finished at: ' . date('Y-m-d H:i:s') . ' | Runtime: ' . (microtime(true) - $time1) . 's</pre>';
}

0 comments on commit a78d7ce

Please sign in to comment.