Skip to content
Permalink
Browse files

Add exception on parse failure.

  • Loading branch information...
markstory committed Aug 11, 2017
1 parent f13b003 commit edcb3dc629a506d3566fa14a174dfe34bf75f1a9
Showing with 14 additions and 2 deletions.
  1. +2 −2 src/Core/StaticConfigTrait.php
  2. +12 −0 tests/TestCase/Datasource/ConnectionManagerTest.php
@@ -237,7 +237,7 @@ public static function configured()
*
* @param string $dsn The DSN string to convert to a configuration array
* @return array The configuration array to be stored after parsing the DSN
* @throws \InvalidArgumentException If not passed a string
* @throws \InvalidArgumentException If not passed a string, or passed an invalid string
*/
public static function parseDsn($dsn)
{
@@ -255,7 +255,7 @@ public static function parseDsn($dsn)
preg_match($pattern, $dsn, $parsed);
if (empty($parsed)) {
return false;
throw new InvalidArgumentException("The DSN string '{$dsn}' could not be parsed.");
}
foreach ($parsed as $k => $v) {
if (is_int($k)) {
@@ -397,6 +397,18 @@ public function testParseDsn($dsn, $expected)
$this->assertEquals($expected, $result);
}
/**
* Test parseDsn invalid.
*
* @expectedException InvalidArgumentException
* @expectedExceptionMessage The DSN string 'bagof:nope' could not be parsed.
* @return void
*/
public function testParseDsnInvalid()
{
$result = ConnectionManager::parseDsn('bagof:nope');
}
/**
* Tests that directly setting an instance in a config, will not return a different
* instance later on

0 comments on commit edcb3dc

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.