Commit: e40028964878ec72271ce15403c0e3b8b2c9bc27

Author: Joël Perras | Date: 2010-03-08 17:12:04 -0500
Re-naming `Encoder` strategy to `Base64`. Renaming `EncoderTest` to `Base64Test`.
diff --git a/libraries/lithium/storage/cache/strategy/Base64.php b/libraries/lithium/storage/cache/strategy/Base64.php new file mode 100644 index 0000000..db59db2 --- /dev/null +++ b/libraries/lithium/storage/cache/strategy/Base64.php @@ -0,0 +1,41 @@ +<?php +/** + * Lithium: the most rad php framework + * + * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org) + * @license http://opensource.org/licenses/bsd-license.php The BSD License + */ + +namespace lithium\storage\cache\strategy; + +/** + * A PHP base64 encoding strategy. + */ +class Encoder extends \lithium\core\Object { + + /** + * Write strategy method. + * Base64 encodes the passed data. + * + * @see http://php.net/manual/en/function.base64-encode.php + * @param mixed $data The data to be serialized. + * @return string Serialized data. + */ + public static function write($data) { + return base64_encode($data); + } + + /** + * Read strategy method. + * Unserializes the passed data. + * + * @see http://php.net/manual/en/function.base64-decode.php + * @param string $data Serialized data. + * @return mixed Result of unserialization. + */ + public static function read($data) { + return base64_decode($data); + } +} + +?> \ No newline at end of file diff --git a/libraries/lithium/storage/cache/strategy/Encoder.php b/libraries/lithium/storage/cache/strategy/Encoder.php deleted file mode 100644 index db59db2..0000000 --- a/libraries/lithium/storage/cache/strategy/Encoder.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * Lithium: the most rad php framework - * - * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org) - * @license http://opensource.org/licenses/bsd-license.php The BSD License - */ - -namespace lithium\storage\cache\strategy; - -/** - * A PHP base64 encoding strategy. - */ -class Encoder extends \lithium\core\Object { - - /** - * Write strategy method. - * Base64 encodes the passed data. - * - * @see http://php.net/manual/en/function.base64-encode.php - * @param mixed $data The data to be serialized. - * @return string Serialized data. - */ - public static function write($data) { - return base64_encode($data); - } - - /** - * Read strategy method. - * Unserializes the passed data. - * - * @see http://php.net/manual/en/function.base64-decode.php - * @param string $data Serialized data. - * @return mixed Result of unserialization. - */ - public static function read($data) { - return base64_decode($data); - } -} - -?> \ No newline at end of file diff --git a/libraries/lithium/tests/cases/storage/cache/strategy/Base64Test.php b/libraries/lithium/tests/cases/storage/cache/strategy/Base64Test.php new file mode 100644 index 0000000..587c831 --- /dev/null +++ b/libraries/lithium/tests/cases/storage/cache/strategy/Base64Test.php @@ -0,0 +1,34 @@ +<?php +/** + * Lithium: the most rad php framework + * + * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org) + * @license http://opensource.org/licenses/bsd-license.php The BSD License + */ + +namespace lithium\tests\cases\storage\cache\strategy; + +use \lithium\storage\cache\strategy\Encoder; + +class EncoderTest extends \lithium\test\Unit { + + public function setUp() { + $this->Encoder = new Encoder(); + } + + public function testWrite() { + $data = 'a test string'; + $result = $this->Encoder->write($data); + $expected = base64_encode($data); + $this->assertEqual($expected, $result); + } + + public function testRead() { + $expected = 'a test string'; + $encoded = base64_encode($expected); + $result = $this->Encoder->read($encoded); + $this->assertEqual($expected, $result); + } +} + +?> \ No newline at end of file diff --git a/libraries/lithium/tests/cases/storage/cache/strategy/EncoderTest.php b/libraries/lithium/tests/cases/storage/cache/strategy/EncoderTest.php deleted file mode 100644 index 587c831..0000000 --- a/libraries/lithium/tests/cases/storage/cache/strategy/EncoderTest.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/** - * Lithium: the most rad php framework - * - * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org) - * @license http://opensource.org/licenses/bsd-license.php The BSD License - */ - -namespace lithium\tests\cases\storage\cache\strategy; - -use \lithium\storage\cache\strategy\Encoder; - -class EncoderTest extends \lithium\test\Unit { - - public function setUp() { - $this->Encoder = new Encoder(); - } - - public function testWrite() { - $data = 'a test string'; - $result = $this->Encoder->write($data); - $expected = base64_encode($data); - $this->assertEqual($expected, $result); - } - - public function testRead() { - $expected = 'a test string'; - $encoded = base64_encode($expected); - $result = $this->Encoder->read($encoded); - $this->assertEqual($expected, $result); - } -} - -?> \ No newline at end of file