diff --git a/src/Log/Log.php b/src/Log/Log.php index 1929cae8eec..49990e392e8 100644 --- a/src/Log/Log.php +++ b/src/Log/Log.php @@ -105,7 +105,7 @@ class Log { use StaticConfigTrait { - config as protected _config; + setConfig as protected _setConfig; } /** @@ -276,9 +276,9 @@ public static function levels() * @return array|null Null when adding configuration and an array of configuration data when reading. * @throws \BadMethodCallException When trying to modify an existing config. */ - public static function config($key, $config = null) + public static function setConfig($key, $config = null) { - $return = static::_config($key, $config); + $return = static::_setConfig($key, $config); if ($return !== null) { return $return; } diff --git a/tests/TestCase/Log/LogTest.php b/tests/TestCase/Log/LogTest.php index b3976e566c0..865b5ded1ef 100644 --- a/tests/TestCase/Log/LogTest.php +++ b/tests/TestCase/Log/LogTest.php @@ -171,6 +171,20 @@ public function testConfigVariants($settings) Log::drop('test'); } + /** + * Test the various setConfig call signatures. + * + * @dataProvider configProvider + * @return void + */ + public function testSetConfigVariants($settings) + { + Log::setConfig('test', $settings); + $this->assertContains('test', Log::configured()); + $this->assertInstanceOf('Cake\Log\Engine\FileLog', Log::engine('test')); + Log::drop('test'); + } + /** * Test that config() throws an exception when adding an * adapter with the wrong type. @@ -184,6 +198,19 @@ public function testConfigInjectErrorOnWrongType() Log::info('testing'); } + /** + * Test that setConfig() throws an exception when adding an + * adapter with the wrong type. + * + * @expectedException \RuntimeException + * @return void + */ + public function testSetConfigInjectErrorOnWrongType() + { + Log::setConfig('test', new \StdClass); + Log::info('testing'); + } + /** * Test that config() can read data back *