diff --git a/lib/Cake/Configure/IniReader.php b/lib/Cake/Configure/IniReader.php index 77035e9c2..b571c7004 100644 --- a/lib/Cake/Configure/IniReader.php +++ b/lib/Cake/Configure/IniReader.php @@ -140,10 +140,11 @@ class IniReader implements ConfigReaderInterface { /** * Dumps the state of Configure data into an ini formatted string. * + * @param string $filename The filename on $this->_path to save into. * @param array $data The data to convert to ini file. - * @return string The converted configuration as an ini string + * @return int Bytes saved. */ - public function dump($data) { + public function dump($filename, $data) { $result = array(); foreach ($data as $key => $value) { if ($key[0] != '[') { @@ -156,6 +157,7 @@ class IniReader implements ConfigReaderInterface { } } } - return join("\n", $result); + $contents = join("\n", $result); + return file_put_contents($this->_path . $filename, $contents); } } diff --git a/lib/Cake/Configure/PhpReader.php b/lib/Cake/Configure/PhpReader.php index 6ee4e3770..f5d961961 100644 --- a/lib/Cake/Configure/PhpReader.php +++ b/lib/Cake/Configure/PhpReader.php @@ -91,11 +91,13 @@ class PhpReader implements ConfigReaderInterface { * Converts the provided $data into a string of PHP code that can * be used saved into a file and loaded later. * + * @param string $filename The filename to create on $this->_path. * @param array $data Data to dump. - * @return string String or PHP code. + * @return int Bytes saved. */ - public function dump($data) { - return '_path . $filename, $contents); } } diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 9a4e1adc9..9b4a85ee3 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -284,20 +284,20 @@ class Configure { * 'default' adapter is a PhpReader, the generated file will be a PHP configuration * file loadable by the PhpReader. * - * @param string $filename The filename to save content into. + * @param string $key The identifier to create in the config adapter. + * This could be a filename or a cache key depending on the adapter being used. * @param string $config The name of the configured adapter to dump data with. - * @return void + * @return boolean success * @throws ConfigureException if the adapter does not implement a `dump` method. */ - public static function dump($filename, $config = 'default') { + public static function dump($key, $config = 'default') { if (empty(self::$_readers[$config])) { throw new ConfigureException(__d('cake', 'There is no "%s" adapter.', $config)); } if (!method_exists(self::$_readers[$config], 'dump')) { throw new ConfigureException(__d('cake', 'The "%s" adapter, does not have a dump() method.', $config)); } - $content = self::$_readers[$config]->dump(self::$_values); - return file_put_contents($filename, $content); + return (bool)self::$_readers[$config]->dump($key, self::$_values); } /** diff --git a/lib/Cake/Test/Case/Configure/IniReaderTest.php b/lib/Cake/Test/Case/Configure/IniReaderTest.php index 6d69c0371..0caaf92e2 100644 --- a/lib/Cake/Test/Case/Configure/IniReaderTest.php +++ b/lib/Cake/Test/Case/Configure/IniReaderTest.php @@ -144,7 +144,9 @@ class IniReaderTest extends CakeTestCase { 'timestamp' => 'force' ), ); - $result = $reader->dump($data); + $result = $reader->dump('test.ini', $data); + $this->assertTrue($result > 0); + $expected = <<path . 'test.ini'; + $result = file_get_contents($file); + unlink($file); + $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/Case/Configure/PhpReaderTest.php b/lib/Cake/Test/Case/Configure/PhpReaderTest.php index a80152aeb..ef7932988 100644 --- a/lib/Cake/Test/Case/Configure/PhpReaderTest.php +++ b/lib/Cake/Test/Case/Configure/PhpReaderTest.php @@ -116,7 +116,8 @@ class PhpReaderTest extends CakeTestCase { 'timestamp' => 'force' ), ); - $result = $reader->dump($data); + $result = $reader->dump('test.php', $data); + $this->assertTrue($result > 0); $expected = <<assertEquals($expected, $result); + $file = $this->path . 'test.php'; + $contents = file_get_contents($file); + @unlink($contents); + $this->assertEquals($expected, $contents); } } diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index 88a996e19..a384c591c 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -378,7 +378,7 @@ class ConfigureTest extends CakeTestCase { public function testDump() { Configure::config('test_reader', new PhpReader(TMP)); - $result = Configure::dump(TMP . 'config_test.php', 'test_reader'); + $result = Configure::dump('config_test.php', 'test_reader'); $this->assertTrue($result > 0); $result = file_get_contents(TMP . 'config_test.php'); $this->assertContains('