From d0733ceb00e56aa68c555c28fb569dac36ec9941 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 16 Mar 2012 22:19:01 -0400 Subject: [PATCH] Fix most coding standards in Case/Network --- .../Test/Case/Network/CakeRequestTest.php | 16 +-- .../Test/Case/Network/CakeResponseTest.php | 129 +++++++++--------- .../Test/Case/Network/Email/CakeEmailTest.php | 32 ++--- .../Case/Network/Email/SmtpTransportTest.php | 1 - .../Network/Http/DigestAuthenticationTest.php | 4 +- .../Case/Network/Http/HttpResponseTest.php | 20 +-- .../Test/Case/Network/Http/HttpSocketTest.php | 17 +-- 7 files changed, 102 insertions(+), 117 deletions(-) diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 486f8e209..e1ef3a988 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -22,6 +22,7 @@ App::uses('Xml', 'Utility'); App::uses('CakeRequest', 'Network'); class CakeRequestTest extends CakeTestCase { + /** * setup callback * @@ -106,7 +107,6 @@ class CakeRequestTest extends CakeTestCase { $expected = array('one' => 'something', 'two' => 'else'); $this->assertEquals($expected, $request->query); $this->assertEquals('some/path?one=something&two=else', $request->url); - } /** @@ -161,7 +161,6 @@ class CakeRequestTest extends CakeTestCase { $this->assertFalse(isset($request->random)); } - /** * test parsing POST data into the object. * @@ -437,7 +436,6 @@ class CakeRequestTest extends CakeTestCase { ); $this->assertEquals($request->data, $expected); - $_FILES = array( 'data' => array( 'name' => array('birth_cert' => 'born on.txt'), @@ -471,7 +469,6 @@ class CakeRequestTest extends CakeTestCase { ); $request = new CakeRequest('some/path'); $this->assertEquals($request->params['form'], $_FILES); - } /** @@ -682,7 +679,7 @@ class CakeRequestTest extends CakeTestCase { * @expectedException CakeException * @return void */ - public function test__callExceptionOnUnknownMethod() { + public function testMagicCallExceptionOnUnknownMethod() { $request = new CakeRequest('some/path'); $request->IamABanana(); } @@ -725,7 +722,7 @@ class CakeRequestTest extends CakeTestCase { * * @return void */ - public function test__get() { + public function testMagicget() { $request = new CakeRequest('some/path'); $request->params = array('controller' => 'posts', 'action' => 'view', 'plugin' => 'blogs'); @@ -740,7 +737,7 @@ class CakeRequestTest extends CakeTestCase { * * @return void */ - public function test__isset() { + public function testMagicisset() { $request = new CakeRequest('some/path'); $request->params = array( 'controller' => 'posts', @@ -800,7 +797,7 @@ class CakeRequestTest extends CakeTestCase { $_SERVER['TEST_VAR'] = 'wrong'; $this->assertFalse($request->is('compare'), 'Value mis-match failed.'); - + $request->addDetector('compareCamelCase', array('env' => 'TEST_VAR', 'value' => 'foo')); $_SERVER['TEST_VAR'] = 'foo'; @@ -945,7 +942,6 @@ class CakeRequestTest extends CakeTestCase { $this->assertEquals($request->webroot, '/1.2.x.x/'); $this->assertEquals($request->url, 'posts/view/1'); - $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/app/webroot'; $_SERVER['PHP_SELF'] = '/index.php'; $_SERVER['PATH_INFO'] = '/posts/add'; @@ -962,7 +958,6 @@ class CakeRequestTest extends CakeTestCase { $this->assertEquals('', $request->base); $this->assertEquals('/', $request->webroot); - $_SERVER['DOCUMENT_ROOT'] = '/some/apps/where'; $_SERVER['PHP_SELF'] = '/app/webroot/index.php'; $request = new CakeRequest(); @@ -1704,7 +1699,6 @@ XML; ); } - /** * Test is('requested') and isRequested() * diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 1232e198a..d5d6a07c0 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -40,9 +40,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the request object constructor -* -*/ + * Tests the request object constructor + * + */ public function testConstruct() { $response = new CakeResponse(); $this->assertNull($response->body()); @@ -64,9 +64,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the body method -* -*/ + * Tests the body method + * + */ public function testBody() { $response = new CakeResponse(); $this->assertNull($response->body()); @@ -76,9 +76,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the charset method -* -*/ + * Tests the charset method + * + */ public function testCharset() { $response = new CakeResponse(); $this->assertEquals($response->charset(), 'UTF-8'); @@ -88,10 +88,10 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the statusCode method -* -* @expectedException CakeException -*/ + * Tests the statusCode method + * + * @expectedException CakeException + */ public function testStatusCode() { $response = new CakeResponse(); $this->assertEquals($response->statusCode(), 200); @@ -104,9 +104,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the type method -* -*/ + * Tests the type method + * + */ public function testType() { $response = new CakeResponse(); $this->assertEquals($response->type(), 'text/html'); @@ -125,9 +125,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the header method -* -*/ + * Tests the header method + * + */ public function testHeader() { $response = new CakeResponse(); $headers = array(); @@ -169,9 +169,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the send method -* -*/ + * Tests the send method + * + */ public function testSend() { $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies')); $response->header(array( @@ -195,9 +195,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the send method and changing the content type -* -*/ + * Tests the send method and changing the content type + * + */ public function testSendChangingContentYype() { $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies')); $response->type('mp3'); @@ -214,9 +214,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the send method and changing the content type -* -*/ + * Tests the send method and changing the content type + * + */ public function testSendChangingContentType() { $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies')); $response->type('mp3'); @@ -233,9 +233,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the send method and changing the content type -* -*/ + * Tests the send method and changing the content type + * + */ public function testSendWithLocation() { $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies')); $response->header('Location', 'http://www.example.com'); @@ -245,14 +245,14 @@ class CakeResponseTest extends CakeTestCase { $response->expects($this->at(2)) ->method('_sendHeader')->with('Location', 'http://www.example.com'); $response->expects($this->at(3)) - ->method('_sendHeader')->with('Content-Type', 'text/html; charset=UTF-8'); + ->method('_sendHeader')->with('Content-Type', 'text/html; charset=UTF-8'); $response->send(); } /** -* Tests the disableCache method -* -*/ + * Tests the disableCache method + * + */ public function testDisableCache() { $response = new CakeResponse(); $expected = array( @@ -265,9 +265,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the cache method -* -*/ + * Tests the cache method + * + */ public function testCache() { $response = new CakeResponse(); $since = time(); @@ -336,15 +336,15 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the httpCodes method -* -*/ + * Tests the httpCodes method + * + */ public function testHttpCodes() { $response = new CakeResponse(); $result = $response->httpCodes(); $this->assertEquals(count($result), 39); - $result = $response->httpCodes(100); + $result = $response->httpCodes(100); $expected = array(100 => 'Continue'); $this->assertEquals($expected, $result); @@ -353,7 +353,7 @@ class CakeResponseTest extends CakeTestCase { 1729 => 'Hardy-Ramanujan Located' ); - $result = $response->httpCodes($codes); + $result = $response->httpCodes($codes); $this->assertTrue($result); $this->assertEquals(count($response->httpCodes()), 41); @@ -372,9 +372,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the download method -* -*/ + * Tests the download method + * + */ public function testDownload() { $response = new CakeResponse(); $expected = array( @@ -385,9 +385,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the mapType method -* -*/ + * Tests the mapType method + * + */ public function testMapType() { $response = new CakeResponse(); $this->assertEquals('wav', $response->mapType('audio/x-wav')); @@ -401,9 +401,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the outputCompressed method -* -*/ + * Tests the outputCompressed method + * + */ public function testOutputCompressed() { $response = new CakeResponse(); @@ -438,9 +438,9 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the send and setting of Content-Length -* -*/ + * Tests the send and setting of Content-Length + * + */ public function testSendContentLength() { $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); $response->body('the response body'); @@ -479,7 +479,7 @@ class CakeResponseTest extends CakeTestCase { $response->header('Content-Length', 1); $response->expects($this->never())->method('outputCompressed'); $response->expects($this->once())->method('_sendContent')->with($body); - $response->expects($this->at(1)) + $response->expects($this->at(1)) ->method('_sendHeader')->with('Content-Length', 1); $response->send(); @@ -652,7 +652,6 @@ class CakeResponseTest extends CakeTestCase { ->method('_sendHeader')->with('Cache-Control', 'public'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); $response->sharable(false); $headers = $response->header(); @@ -765,7 +764,6 @@ class CakeResponseTest extends CakeTestCase { $response->expects($this->at(1)) ->method('_sendHeader')->with('Cache-Control', 's-maxage=3600, must-revalidate'); $response->send(); - } /** @@ -835,7 +833,7 @@ class CakeResponseTest extends CakeTestCase { **/ public function testCheckNotModifiedByEtagStar() { $_SERVER['HTTP_IF_NONE_MATCH'] = '*'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', array('notModified')); $response->etag('something'); $response->expects($this->once())->method('notModified'); $response->checkNotModified(new CakeRequest); @@ -848,7 +846,7 @@ class CakeResponseTest extends CakeTestCase { **/ public function testCheckNotModifiedByEtagExact() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', array('notModified')); $response->etag('something', true); $response->expects($this->once())->method('notModified'); $this->assertTrue($response->checkNotModified(new CakeRequest)); @@ -862,7 +860,7 @@ class CakeResponseTest extends CakeTestCase { public function testCheckNotModifiedByEtagAndTime() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', array('notModified')); $response->etag('something', true); $response->modified('2012-01-01 00:00:00'); $response->expects($this->once())->method('notModified'); @@ -877,7 +875,7 @@ class CakeResponseTest extends CakeTestCase { public function testCheckNotModifiedByEtagAndTimeMismatch() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', array('notModified')); $response->etag('something', true); $response->modified('2012-01-01 00:00:01'); $response->expects($this->never())->method('notModified'); @@ -892,14 +890,13 @@ class CakeResponseTest extends CakeTestCase { public function testCheckNotModifiedByEtagMismatch() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something-else", "other"'; $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', array('notModified')); $response->etag('something', true); $response->modified('2012-01-01 00:00:00'); $response->expects($this->never())->method('notModified'); $this->assertFalse($response->checkNotModified(new CakeRequest)); } - /** * Test checkNotModified method * @@ -907,7 +904,7 @@ class CakeResponseTest extends CakeTestCase { **/ public function testCheckNotModifiedByTime() { $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', array('notModified')); $response->modified('2012-01-01 00:00:00'); $response->expects($this->once())->method('notModified'); $this->assertTrue($response->checkNotModified(new CakeRequest)); @@ -921,7 +918,7 @@ class CakeResponseTest extends CakeTestCase { public function testCheckNotModifiedNoHints() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', array('notModified')); $response->expects($this->never())->method('notModified'); $this->assertFalse($response->checkNotModified(new CakeRequest)); } diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 9aedb0b5f..a06a02947 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -62,6 +62,7 @@ class TestCakeEmail extends CakeEmail { public function encode($text) { return $this->_encode($text); } + } /* @@ -110,7 +111,7 @@ class CakeEmailTest extends CakeTestCase { $this->CakeEmail = new TestCakeEmail(); App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS) + 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) )); } @@ -308,12 +309,12 @@ class CakeEmailTest extends CakeTestCase { $this->assertSame($expected, $result); $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => '寿限無寿限無五劫の擦り切れ海砂利水魚の水行末雲来末風来末食う寝る処に住む処やぶら小路の藪柑子パイポパイポパイポのシューリンガンシューリンガンのグーリンダイグーリンダイのポンポコピーのポンポコナーの長久命の長助')); - $expected = array("=?ISO-2022-JP?B?GyRCPHc4Qkw1PHc4Qkw1OF45ZSROOyQkakBaJGwzJDo9TXg/ZTV7GyhC?=\r\n" - ." =?ISO-2022-JP?B?GyRCJE4/ZTlUS3YxQE1oS3ZJd01oS3Y/KSQmPzIkaz1oJEs9OyRgGyhC?=\r\n" - ." =?ISO-2022-JP?B?GyRCPWgkZCRWJGk+Lk8pJE5pLjQ7O1IlUSUkJV0lUSUkJV0lUSUkGyhC?=\r\n" - ." =?ISO-2022-JP?B?GyRCJV0kTiU3JWUhPCVqJXMlLCVzJTclZSE8JWolcyUsJXMkTiUwGyhC?=\r\n" - ." =?ISO-2022-JP?B?GyRCITwlaiVzJUAlJCUwITwlaiVzJUAlJCROJV0lcyVdJTMlVCE8GyhC?=\r\n" - ." =?ISO-2022-JP?B?GyRCJE4lXSVzJV0lMyVKITwkTkQ5NVdMPyRORDk9dRsoQg==?= "); + $expected = array("=?ISO-2022-JP?B?GyRCPHc4Qkw1PHc4Qkw1OF45ZSROOyQkakBaJGwzJDo9TXg/ZTV7GyhC?=\r\n" . + " =?ISO-2022-JP?B?GyRCJE4/ZTlUS3YxQE1oS3ZJd01oS3Y/KSQmPzIkaz1oJEs9OyRgGyhC?=\r\n" . + " =?ISO-2022-JP?B?GyRCPWgkZCRWJGk+Lk8pJE5pLjQ7O1IlUSUkJV0lUSUkJV0lUSUkGyhC?=\r\n" . + " =?ISO-2022-JP?B?GyRCJV0kTiU3JWUhPCVqJXMlLCVzJTclZSE8JWolcyUsJXMkTiUwGyhC?=\r\n" . + " =?ISO-2022-JP?B?GyRCITwlaiVzJUAlJCUwITwlaiVzJUAlJCROJV0lcyVdJTMlVCE8GyhC?=\r\n" . + " =?ISO-2022-JP?B?GyRCJE4lXSVzJV0lMyVKITwkTkQ5NVdMPyRORDk9dRsoQg==?= "); $this->assertSame($expected, $result); } @@ -420,13 +421,12 @@ class CakeEmailTest extends CakeTestCase { $this->assertSame($this->CakeEmail->subject(), $expected); $this->CakeEmail->subject('長い長い長いSubjectの場合はfoldingするのが正しいんだけどいったいどうなるんだろう?'); - $expected = "=?ISO-2022-JP?B?GyRCRDkkJEQ5JCREOSQkGyhCU3ViamVjdBskQiROPmw5ZyRPGyhCZm9s?=\r\n" - ." =?ISO-2022-JP?B?ZGluZxskQiQ5JGskTiQsQDUkNyQkJHMkQCQxJEkkJCRDJD8kJCRJGyhC?=\r\n" - ." =?ISO-2022-JP?B?GyRCJCYkSiRrJHMkQCRtJCYhKRsoQg==?="; + $expected = "=?ISO-2022-JP?B?GyRCRDkkJEQ5JCREOSQkGyhCU3ViamVjdBskQiROPmw5ZyRPGyhCZm9s?=\r\n" . + " =?ISO-2022-JP?B?ZGluZxskQiQ5JGskTiQsQDUkNyQkJHMkQCQxJEkkJCRDJD8kJCRJGyhC?=\r\n" . + " =?ISO-2022-JP?B?GyRCJCYkSiRrJHMkQCRtJCYhKRsoQg==?="; $this->assertSame($this->CakeEmail->subject(), $expected); } - /** * testHeaders method * @@ -659,7 +659,6 @@ class CakeEmailTest extends CakeTestCase { $this->CakeEmail->config(array()); $this->assertSame($transportClass->config(), array()); - } /** @@ -883,7 +882,7 @@ class CakeEmailTest extends CakeTestCase { $this->assertContains($expected, $result['message']); $this->assertContains('--rel-' . $boundary . '--', $result['message']); $this->assertContains('--' . $boundary . '--', $result['message']); -} + } /** * testSendWithLog method @@ -1209,7 +1208,6 @@ class CakeEmailTest extends CakeTestCase { $this->assertTrue($this->checkContentTransferEncoding($message, '7bit')); } - /** * testReset method * @@ -1493,9 +1491,9 @@ class CakeEmailTest extends CakeTestCase { $this->CakeEmail->headerCharset = 'ISO-2022-JP'; $result = $this->CakeEmail->encode('長い長い長いSubjectの場合はfoldingするのが正しいんだけどいったいどうなるんだろう?'); - $expected = "=?ISO-2022-JP?B?GyRCRDkkJEQ5JCREOSQkGyhCU3ViamVjdBskQiROPmw5ZyRPGyhCZm9s?=\r\n" - . " =?ISO-2022-JP?B?ZGluZxskQiQ5JGskTiQsQDUkNyQkJHMkQCQxJEkkJCRDJD8kJCRJGyhC?=\r\n" - . " =?ISO-2022-JP?B?GyRCJCYkSiRrJHMkQCRtJCYhKRsoQg==?="; + $expected = "=?ISO-2022-JP?B?GyRCRDkkJEQ5JCREOSQkGyhCU3ViamVjdBskQiROPmw5ZyRPGyhCZm9s?=\r\n" . + " =?ISO-2022-JP?B?ZGluZxskQiQ5JGskTiQsQDUkNyQkJHMkQCQxJEkkJCRDJD8kJCRJGyhC?=\r\n" . + " =?ISO-2022-JP?B?GyRCJCYkSiRrJHMkQCRtJCYhKRsoQg==?="; $this->assertSame($expected, $result); } } diff --git a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php index 6b1ecaadf..86591d5f8 100644 --- a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php @@ -52,7 +52,6 @@ class SmtpTestTransport extends SmtpTransport { * @return void */ protected function _generateSocket() { - return; } /** diff --git a/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php b/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php index b024106df..8abc783f5 100644 --- a/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php +++ b/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php @@ -160,8 +160,8 @@ class DigestAuthenticationTest extends CakeTestCase { $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000003') > 0); $this->assertEquals($auth['nc'], 4); $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); - $response2 = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); - $this->assertNotEquals($response, $response2); + $responseB = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); + $this->assertNotEquals($response, $responseB); } /** diff --git a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php index afd34283d..c3919d640 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php @@ -85,6 +85,7 @@ class TestHttpResponse extends HttpResponse { * @package Cake.Test.Case.Network.Http */ class HttpResponseTest extends CakeTestCase { + /** * This function sets up a HttpResponse * @@ -491,7 +492,7 @@ class HttpResponseTest extends CakeTestCase { $unescapedToken = $this->HttpResponse->unescapeToken($token); $expectedToken = 'My-special-' . $char . '-Token'; - $this->assertEquals($unescapedToken, $expectedToken, 'Test token unescaping for ASCII '.ord($char)); + $this->assertEquals($unescapedToken, $expectedToken, 'Test token unescaping for ASCII ' . ord($char)); } $token = 'Extreme-":"Token-" "-""""@"-test'; @@ -519,14 +520,13 @@ class HttpResponseTest extends CakeTestCase { ); $this->HttpResponse->body = 'This is a test!'; $this->HttpResponse->raw = "HTTP/1.1 200 OK\r\nServer: CakePHP\r\nContEnt-Type: text/plain\r\n\r\nThis is a test!"; - - $expected1 = "HTTP/1.1 200 OK\r\n"; - $this->assertEquals($this->HttpResponse['raw']['status-line'], $expected1); - $expected2 = "Server: CakePHP\r\nContEnt-Type: text/plain\r\n"; - $this->assertEquals($this->HttpResponse['raw']['header'], $expected2); - $expected3 = 'This is a test!'; - $this->assertEquals($this->HttpResponse['raw']['body'], $expected3); - $expected = $expected1 . $expected2 . "\r\n" . $expected3; + $expectedOne = "HTTP/1.1 200 OK\r\n"; + $this->assertEquals($this->HttpResponse['raw']['status-line'], $expectedOne); + $expectedTwo = "Server: CakePHP\r\nContEnt-Type: text/plain\r\n"; + $this->assertEquals($this->HttpResponse['raw']['header'], $expectedTwo); + $expectedThree = 'This is a test!'; + $this->assertEquals($this->HttpResponse['raw']['body'], $expectedThree); + $expected = $expectedOne . $expectedTwo . "\r\n" . $expectedThree; $this->assertEquals($this->HttpResponse['raw']['response'], $expected); $expected = 'HTTP/1.1'; @@ -555,4 +555,4 @@ class HttpResponseTest extends CakeTestCase { $this->assertSame($this->HttpResponse['raw']['header'], null); } -} \ No newline at end of file +} diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php index 946077c3f..0bbe5c598 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php @@ -160,7 +160,7 @@ class TestHttpSocket extends HttpSocket { * @param string $token Token to escape * @return string Escaped token */ - public function EscapeToken($token, $chars = null) { + public function escapeToken($token, $chars = null) { return parent::_escapeToken($token, $chars); } @@ -761,7 +761,6 @@ class HttpSocketTest extends CakeTestCase { $this->assertInstanceOf('CustomResponse', $response); $this->assertEquals($response->first10, 'HTTP/1.x 2'); } - /** * testRequestWithRedirect method @@ -777,11 +776,11 @@ class HttpSocketTest extends CakeTestCase { $serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

You have been redirected

"; $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1)); $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2)); - + $response = $this->Socket->request($request); $this->assertEquals('

You have been redirected

', $response->body()); } - + public function testRequestWithRedirectAsInt() { $request = array( 'uri' => 'http://localhost/oneuri', @@ -791,11 +790,11 @@ class HttpSocketTest extends CakeTestCase { $serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

You have been redirected

"; $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1)); $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2)); - + $response = $this->Socket->request($request); $this->assertEquals(1, $this->Socket->request['redirect']); } - + public function testRequestWithRedirectAsIntReachingZero() { $request = array( 'uri' => 'http://localhost/oneuri', @@ -805,13 +804,12 @@ class HttpSocketTest extends CakeTestCase { $serverResponse2 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n"; $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1)); $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2)); - + $response = $this->Socket->request($request); $this->assertEquals(0, $this->Socket->request['redirect']); $this->assertEquals(302, $response->code); $this->assertEquals('http://localhost/anotheruri', $response->getHeader('Location')); } - /** * testProxy method @@ -1496,7 +1494,6 @@ class HttpSocketTest extends CakeTestCase { $r = $this->Socket->buildHeader(array('Test@Field' => "My value")); $this->assertEquals($r, "Test\"@\"Field: My value\r\n"); - } /** @@ -1561,7 +1558,7 @@ class HttpSocketTest extends CakeTestCase { $escapedToken = $this->Socket->escapeToken($token); $expectedToken = 'My-special-"' . $char . '"-Token'; - $this->assertEquals($escapedToken, $expectedToken, 'Test token escaping for ASCII '.ord($char)); + $this->assertEquals($escapedToken, $expectedToken, 'Test token escaping for ASCII ' . ord($char)); } $token = 'Extreme-:Token- -"@-test';