From d1808db0df89c3a36d490f8ad16f2cca2a1b6130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 31 Jul 2010 14:40:58 -0430 Subject: [PATCH] Changing the encoding method for "charset" --- cake/libs/cake_response.php | 27 ++++++++++---------- cake/tests/cases/libs/cake_response.test.php | 18 ++++++------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/cake/libs/cake_response.php b/cake/libs/cake_response.php index 89fb6bd79..900545190 100644 --- a/cake/libs/cake_response.php +++ b/cake/libs/cake_response.php @@ -298,11 +298,11 @@ class CakeResponse { protected $_body = null; /** -* Encoding string to send +* The charset the response body is encoded with * * @var string */ - protected $_encoding = 'UTF-8'; + protected $_charset = 'UTF-8'; /** * Class constructor @@ -311,7 +311,7 @@ class CakeResponse { * - body: the rensonse text that should be sent to the client * - status: the HTTP status code to respond with * - type: a complete mime-type string or an extension mapepd in this class -* - encoding: the encoding for the response body +* - charset: the charset for the response body * @return void */ public function __construct(array $options = array()) { @@ -324,8 +324,8 @@ class CakeResponse { if (isset($options['type'])) { $this->type($options['type']); } - if (isset($options['encoding'])) { - $this->encoding($options['encoding']); + if (isset($options['charset'])) { + $this->charset($options['charset']); } } @@ -334,6 +334,7 @@ class CakeResponse { * */ public function send() { + } /** @@ -447,17 +448,17 @@ class CakeResponse { } /** -* Sets the response encoding or charset -* if $encoding is null the current encoding is returned +* Sets the response charset +* if $charset is null the current charset is returned * -* @param string $encoding -* @return string current status code +* @param string $charset +* @return string current charset */ - public function encoding($encoding = null) { - if (is_null($encoding)) { - return $this->_encoding; + public function charset($charset = null) { + if (is_null($charset)) { + return $this->_charset; } - return $this->_encoding = $encoding; + return $this->_charset = $charset; } /** diff --git a/cake/tests/cases/libs/cake_response.test.php b/cake/tests/cases/libs/cake_response.test.php index 92404e2c5..ba32d6608 100644 --- a/cake/tests/cases/libs/cake_response.test.php +++ b/cake/tests/cases/libs/cake_response.test.php @@ -12,19 +12,19 @@ class CakeRequestTestCase extends CakeTestCase { public function testConstruct() { $response = new CakeResponse(); $this->assertNull($response->body()); - $this->assertEquals($response->encoding(), 'UTF-8'); + $this->assertEquals($response->charset(), 'UTF-8'); $this->assertEquals($response->type(), 'text/html'); $this->assertEquals($response->statusCode(), 200); $options = array( 'body' => 'This is the body', - 'encoding' => 'my-custom-encoding', + 'charset' => 'my-custom-charset', 'type' => 'mp3', 'status' => '203' ); $response = new CakeResponse($options); $this->assertEquals($response->body(), 'This is the body'); - $this->assertEquals($response->encoding(), 'my-custom-encoding'); + $this->assertEquals($response->charset(), 'my-custom-charset'); $this->assertEquals($response->type(), 'audio/mpeg'); $this->assertEquals($response->statusCode(), 203); } @@ -42,15 +42,15 @@ class CakeRequestTestCase extends CakeTestCase { } /** -* Tests the encoding method +* Tests the charset method * */ - public function testEncoding() { + public function testCharset() { $response = new CakeResponse(); - $this->assertEquals($response->encoding(), 'UTF-8'); - $response->encoding('iso-8859-1'); - $this->assertEquals($response->encoding(), 'iso-8859-1'); - $this->assertEquals($response->encoding('UTF-16'), 'UTF-16'); + $this->assertEquals($response->charset(), 'UTF-8'); + $response->charset('iso-8859-1'); + $this->assertEquals($response->charset(), 'iso-8859-1'); + $this->assertEquals($response->charset('UTF-16'), 'UTF-16'); } /**