Skip to content

Commit

Permalink
add tests modifying the dsn class map
Browse files Browse the repository at this point in the history
It should be possible to redefine the map - or add to it.
  • Loading branch information
AD7six committed Oct 31, 2014
1 parent 8f5398a commit b69cf9c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Core/StaticConfigTrait.php
Expand Up @@ -236,7 +236,7 @@ public static function parseDsn($dsn) {
*/
public static function dsnClassMap($map = null) {
if ($map) {
static::$_dsnClassMap = $map + $_dsnClassMap;
static::$_dsnClassMap = $map + static::$_dsnClassMap;
}
return static::$_dsnClassMap;
}
Expand Down
32 changes: 32 additions & 0 deletions tests/TestCase/Core/StaticConfigTraitTest.php
Expand Up @@ -411,4 +411,36 @@ public function testParseDsnPathSetting() {
$this->assertEquals($expected, TestLogStaticConfig::parseDsn($dsn));
}

/**
* Test that the dsn map can be updated/append to
*
* @return void
*/
public function testCanUpdateClassMap() {
$expected = [
'console' => 'Cake\Log\Engine\ConsoleLog',
'file' => 'Cake\Log\Engine\FileLog',
'syslog' => 'Cake\Log\Engine\SyslogLog',
];
$result = TestLogStaticConfig::dsnClassMap();
$this->assertEquals($expected, $result, "The class map should match the class property");

$expected = [
'console' => 'Special\EngineLog',
'file' => 'Cake\Log\Engine\FileLog',
'syslog' => 'Cake\Log\Engine\SyslogLog',
];
$result = TestLogStaticConfig::dsnClassMap(['console' => 'Special\EngineLog']);
$this->assertEquals($expected, $result, "Should be possible to change the map");

$expected = [
'console' => 'Special\EngineLog',
'file' => 'Cake\Log\Engine\FileLog',
'syslog' => 'Cake\Log\Engine\SyslogLog',
'my' => 'Special\OtherLog'
];
$result = TestLogStaticConfig::dsnClassMap(['my' => 'Special\OtherLog']);
$this->assertEquals($expected, $result, "Should be possible to add to the map");
}

}

0 comments on commit b69cf9c

Please sign in to comment.