diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 834237934c7..9bfa3bf96c4 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -51,6 +51,10 @@ public static function proxyAuthentication(HttpSocket $http, &$proxyInfo) { } +/** + * TestHttpSocket + * + */ class TestHttpSocket extends HttpSocket { /** @@ -59,7 +63,7 @@ class TestHttpSocket extends HttpSocket { * @param mixed $uri URI (see {@link _parseUri()}) * @return array Current configuration settings */ - function configUri($uri = null) { + public function configUri($uri = null) { return parent::_configUri($uri); } @@ -70,7 +74,7 @@ function configUri($uri = null) { * @param mixed $base If true use default URI config, otherwise indexed array to set 'scheme', 'host', 'port', etc. * @return array Parsed URI */ - function parseUri($uri = null, $base = array()) { + public function parseUri($uri = null, $base = array()) { return parent::_parseUri($uri, $base); } @@ -81,7 +85,7 @@ function parseUri($uri = null, $base = array()) { * @param string $uriTemplate The Uri template/format to use * @return string A fully qualified URL formated according to $uriTemplate */ - function buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') { + public function buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') { return parent::_buildUri($uri, $uriTemplate); } @@ -91,7 +95,7 @@ function buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%p * @param array $header Header to build * @return string Header built from array */ - function buildHeader($header, $mode = 'standard') { + public function buildHeader($header, $mode = 'standard') { return parent::_buildHeader($header, $mode); } @@ -101,7 +105,7 @@ function buildHeader($header, $mode = 'standard') { * @param string $message Message to parse * @return array Parsed message (with indexed elements such as raw, status, header, body) */ - function parseResponse($message) { + public function parseResponse($message) { return parent::_parseResponse($message); } @@ -111,7 +115,7 @@ function parseResponse($message) { * @param array $header Header as an indexed array (field => value) * @return array Parsed header */ - function parseHeader($header) { + public function parseHeader($header) { return parent::_parseHeader($header); } @@ -121,7 +125,7 @@ function parseHeader($header) { * @param mixed $query A query string to parse into an array or an array to return directly "as is" * @return array The $query parsed into a possibly multi-level array. If an empty $query is given, an empty array is returned. */ - function parseQuery($query) { + public function parseQuery($query) { return parent::_parseQuery($query); } @@ -132,7 +136,7 @@ function parseQuery($query) { * @param mixed $encoding Can be false in case no encoding is being used, or a string representing the encoding * @return mixed Array or false */ - function decodeBody($body, $encoding = 'chunked') { + public function decodeBody($body, $encoding = 'chunked') { return parent::_decodeBody($body, $encoding); } @@ -142,7 +146,7 @@ function decodeBody($body, $encoding = 'chunked') { * @param string $body A string continaing the chunked body to decode * @return mixed Array or false */ - function decodeChunkedBody($body) { + public function decodeChunkedBody($body) { return parent::_decodeChunkedBody($body); } @@ -153,7 +157,7 @@ function decodeChunkedBody($body) { * @param string $versionToken The version token to use, defaults to HTTP/1.1 * @return string Request line */ - function buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') { + public function buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') { return parent::_buildRequestLine($request, $versionToken); } @@ -163,7 +167,7 @@ function buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') { * @param boolean $hex true to get them as HEX values, false otherwise * @return array Escape chars */ - function tokenEscapeChars($hex = true, $chars = null) { + public function tokenEscapeChars($hex = true, $chars = null) { return parent::_tokenEscapeChars($hex, $chars); } @@ -173,7 +177,7 @@ function tokenEscapeChars($hex = true, $chars = null) { * @param string $token Token to escape * @return string Escaped token */ - function EscapeToken($token, $chars = null) { + public function EscapeToken($token, $chars = null) { return parent::_escapeToken($token, $chars); } @@ -183,7 +187,7 @@ function EscapeToken($token, $chars = null) { * @param string $token Token to unescape * @return string Unescaped token */ - function unescapeToken($token, $chars = null) { + public function unescapeToken($token, $chars = null) { return parent::_unescapeToken($token, $chars); } } @@ -200,7 +204,6 @@ class HttpSocketTest extends CakeTestCase { * Socket property * * @var mixed null - * @access public */ public $Socket = null; @@ -208,17 +211,15 @@ class HttpSocketTest extends CakeTestCase { * RequestSocket property * * @var mixed null - * @access public */ public $RequestSocket = null; /** * This function sets up a TestHttpSocket instance we are going to use for testing * - * @access public * @return void */ - function setUp() { + public function setUp() { if (!class_exists('MockHttpSocket')) { $this->getMock('TestHttpSocket', array('read', 'write', 'connect'), array(), 'MockHttpSocket'); $this->getMock('TestHttpSocket', array('read', 'write', 'connect', 'request'), array(), 'MockHttpSocketRequests'); @@ -231,20 +232,18 @@ function setUp() { /** * We use this function to clean up after the test case was executed * - * @access public * @return void */ - function tearDown() { + public function tearDown() { unset($this->Socket, $this->RequestSocket); } /** * Test that HttpSocket::__construct does what one would expect it to do * - * @access public * @return void */ - function testConstruct() { + public function testConstruct() { $this->Socket->reset(); $baseConfig = $this->Socket->config; $this->Socket->expects($this->never())->method('connect'); @@ -270,25 +269,24 @@ function testConstruct() { /** * Test that HttpSocket::configUri works properly with different types of arguments * - * @access public * @return void */ - function testConfigUri() { + public function testConfigUri() { $this->Socket->reset(); $r = $this->Socket->configUri('https://bob:secret@www.cakephp.org:23/?query=foo'); $expected = array( 'persistent' => false, - 'host' => 'www.cakephp.org', - 'protocol' => 'tcp', - 'port' => 23, - 'timeout' => 30, + 'host' => 'www.cakephp.org', + 'protocol' => 'tcp', + 'port' => 23, + 'timeout' => 30, 'request' => array( 'uri' => array( - 'scheme' => 'https' - , 'host' => 'www.cakephp.org' - , 'port' => 23 + 'scheme' => 'https', + 'host' => 'www.cakephp.org', + 'port' => 23 ), - 'cookies' => array(), + 'cookies' => array() ) ); $this->assertEquals($this->Socket->config, $expected); @@ -302,15 +300,15 @@ function testConfigUri() { $r = $this->Socket->configUri('http://www.foo.com'); $expected = array( 'persistent' => false, - 'host' => 'www.foo.com', - 'protocol' => 'tcp', - 'port' => 80, - 'timeout' => 30, + 'host' => 'www.foo.com', + 'protocol' => 'tcp', + 'port' => 80, + 'timeout' => 30, 'request' => array( 'uri' => array( - 'scheme' => 'http' - , 'host' => 'www.foo.com' - , 'port' => 80 + 'scheme' => 'http', + 'host' => 'www.foo.com', + 'port' => 80 ), 'cookies' => array() ) @@ -328,191 +326,216 @@ function testConfigUri() { /** * Tests that HttpSocket::request (the heart of the HttpSocket) is working properly. * - * @access public * @return void */ - function testRequest() { + public function testRequest() { $this->Socket->reset(); $response = $this->Socket->request(true); $this->assertFalse($response); $tests = array( - 0 => array( - 'request' => 'http://www.cakephp.org/?foo=bar' - , 'expectation' => array( + array( + 'request' => 'http://www.cakephp.org/?foo=bar', + 'expectation' => array( 'config' => array( - 'persistent' => false - , 'host' => 'www.cakephp.org' - , 'protocol' => 'tcp' - , 'port' => 80 - , 'timeout' => 30 - , 'request' => array( + 'persistent' => false, + 'host' => 'www.cakephp.org', + 'protocol' => 'tcp', + 'port' => 80, + 'timeout' => 30, + 'request' => array( 'uri' => array ( - 'scheme' => 'http' - , 'host' => 'www.cakephp.org' - , 'port' => 80, + 'scheme' => 'http', + 'host' => 'www.cakephp.org', + 'port' => 80 ), - 'cookies' => array(), - ), - ) - , 'request' => array( - 'method' => 'GET' - , 'uri' => array( - 'scheme' => 'http' - , 'host' => 'www.cakephp.org' - , 'port' => 80 - , 'user' => null - , 'pass' => null - , 'path' => '/' - , 'query' => array('foo' => 'bar') - , 'fragment' => null + 'cookies' => array() ) - , 'version' => '1.1' - , 'body' => '' - , 'line' => "GET /?foo=bar HTTP/1.1\r\n" - , 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n" - , 'raw' => "" - , 'cookies' => array(), + ), + 'request' => array( + 'method' => 'GET', + 'uri' => array( + 'scheme' => 'http', + 'host' => 'www.cakephp.org', + 'port' => 80, + 'user' => null, + 'pass' => null, + 'path' => '/', + 'query' => array('foo' => 'bar'), + 'fragment' => null + ), + 'version' => '1.1', + 'body' => '', + 'line' => "GET /?foo=bar HTTP/1.1\r\n", + 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n", + 'raw' => "", + 'cookies' => array() ) ) - ) - , 1 => array( + ), + array( 'request' => array( 'uri' => array( - 'host' => 'www.cakephp.org' - , 'query' => '?foo=bar' + 'host' => 'www.cakephp.org', + 'query' => '?foo=bar' ) ) - ) - , 2 => array( + ), + array( 'request' => 'www.cakephp.org/?foo=bar' - ) - , 3 => array( - 'request' => array('host' => '192.168.0.1', 'uri' => 'http://www.cakephp.org/?foo=bar') - , 'expectation' => array( + ), + array( + 'request' => array( + 'host' => '192.168.0.1', + 'uri' => 'http://www.cakephp.org/?foo=bar' + ), + 'expectation' => array( 'request' => array( 'uri' => array('host' => 'www.cakephp.org') - ) - , 'config' => array( + ), + 'config' => array( 'request' => array( 'uri' => array('host' => 'www.cakephp.org') - ) - , 'host' => '192.168.0.1' + ), + 'host' => '192.168.0.1' ) ) - ) - , 'reset4' => array( + ), + 'reset4' => array( 'request.uri.query' => array() - ) - , 4 => array( - 'request' => array('header' => array('Foo@woo' => 'bar-value')) - , 'expectation' => array( + ), + array( + 'request' => array( + 'header' => array('Foo@woo' => 'bar-value') + ), + 'expectation' => array( 'request' => array( - 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nFoo\"@\"woo: bar-value\r\n" - , 'line' => "GET / HTTP/1.1\r\n" + 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nFoo\"@\"woo: bar-value\r\n", + 'line' => "GET / HTTP/1.1\r\n" ) ) - ) - , 5 => array( - 'request' => array('header' => array('Foo@woo' => 'bar-value', 'host' => 'foo.com'), 'uri' => 'http://www.cakephp.org/') - , 'expectation' => array( + ), + array( + 'request' => array('header' => array('Foo@woo' => 'bar-value', 'host' => 'foo.com'), 'uri' => 'http://www.cakephp.org/'), + 'expectation' => array( 'request' => array( 'header' => "Host: foo.com\r\nConnection: close\r\nUser-Agent: CakePHP\r\nFoo\"@\"woo: bar-value\r\n" - ) - , 'config' => array( + ), + 'config' => array( 'host' => 'www.cakephp.org' ) ) - ) - , 6 => array( - 'request' => array('header' => "Foo: bar\r\n") - , 'expectation' => array( + ), + array( + 'request' => array('header' => "Foo: bar\r\n"), + 'expectation' => array( 'request' => array( 'header' => "Foo: bar\r\n" ) ) - ) - , 7 => array( - 'request' => array('header' => "Foo: bar\r\n", 'uri' => 'http://www.cakephp.org/search?q=http_socket#ignore-me') - , 'expectation' => array( + ), + array( + 'request' => array('header' => "Foo: bar\r\n", 'uri' => 'http://www.cakephp.org/search?q=http_socket#ignore-me'), + 'expectation' => array( 'request' => array( 'uri' => array( - 'path' => '/search' - , 'query' => array('q' => 'http_socket') - , 'fragment' => 'ignore-me' - ) - , 'line' => "GET /search?q=http_socket HTTP/1.1\r\n" + 'path' => '/search', + 'query' => array('q' => 'http_socket'), + 'fragment' => 'ignore-me' + ), + 'line' => "GET /search?q=http_socket HTTP/1.1\r\n" ) ) - ) - , 'reset8' => array( + ), + 'reset8' => array( 'request.uri.query' => array() - ) - , 8 => array( - 'request' => array('method' => 'POST', 'uri' => 'http://www.cakephp.org/posts/add', 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today')) - , 'expectation' => array( + ), + array( + 'request' => array( + 'method' => 'POST', + 'uri' => 'http://www.cakephp.org/posts/add', + 'body' => array( + 'name' => 'HttpSocket-is-released', + 'date' => 'today' + ) + ), + 'expectation' => array( 'request' => array( - 'method' => 'POST' - , 'uri' => array( - 'path' => '/posts/add' - , 'fragment' => null - ) - , 'body' => "name=HttpSocket-is-released&date=today" - , 'line' => "POST /posts/add HTTP/1.1\r\n" - , 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" - , 'raw' => "name=HttpSocket-is-released&date=today" + 'method' => 'POST', + 'uri' => array( + 'path' => '/posts/add', + 'fragment' => null + ), + 'body' => "name=HttpSocket-is-released&date=today", + 'line' => "POST /posts/add HTTP/1.1\r\n", + 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n", + 'raw' => "name=HttpSocket-is-released&date=today" ) ) - ) - , 9 => array( - 'request' => array('method' => 'POST', 'uri' => 'http://www.cakephp.org:8080/posts/add', 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today')) - , 'expectation' => array( + ), + array( + 'request' => array( + 'method' => 'POST', + 'uri' => 'http://www.cakephp.org:8080/posts/add', + 'body' => array( + 'name' => 'HttpSocket-is-released', + 'date' => 'today' + ) + ), + 'expectation' => array( 'config' => array( - 'port' => 8080 - , 'request' => array( + 'port' => 8080, + 'request' => array( 'uri' => array( 'port' => 8080 ) ) - ) - , 'request' => array( + ), + 'request' => array( 'uri' => array( 'port' => 8080 - ) - , 'header' => "Host: www.cakephp.org:8080\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" + ), + 'header' => "Host: www.cakephp.org:8080\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" ) ) - ) - , 10 => array( - 'request' => array('method' => 'POST', 'uri' => 'https://www.cakephp.org/posts/add', 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today')) - , 'expectation' => array( + ), + array( + 'request' => array( + 'method' => 'POST', + 'uri' => 'https://www.cakephp.org/posts/add', + 'body' => array( + 'name' => 'HttpSocket-is-released', + 'date' => 'today' + ) + ), + 'expectation' => array( 'config' => array( - 'port' => 443 - , 'request' => array( + 'port' => 443, + 'request' => array( 'uri' => array( - 'scheme' => 'https' - , 'port' => 443 + 'scheme' => 'https', + 'port' => 443 ) ) - ) - , 'request' => array( + ), + 'request' => array( 'uri' => array( - 'scheme' => 'https' - , 'port' => 443 - ) - , 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" + 'scheme' => 'https', + 'port' => 443 + ), + 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" ) ) - ) - , 11 => array( + ), + array( 'request' => array( - 'method' => 'POST', - 'uri' => 'https://www.cakephp.org/posts/add', - 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today'), - 'cookies' => array('foo' => array('value' => 'bar')) - ) - , 'expectation' => array( + 'method' => 'POST', + 'uri' => 'https://www.cakephp.org/posts/add', + 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today'), + 'cookies' => array('foo' => array('value' => 'bar')) + ), + 'expectation' => array( 'request' => array( 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\nCookie: foo=bar\r\n", 'cookies' => array( @@ -538,10 +561,10 @@ function testRequest() { $this->Socket->request($test['request']); $raw = $expectation['request']['raw']; - $expectation['request']['raw'] = $expectation['request']['line'].$expectation['request']['header']."\r\n".$raw; + $expectation['request']['raw'] = $expectation['request']['line'] . $expectation['request']['header'] . "\r\n" . $raw; $r = array('config' => $this->Socket->config, 'request' => $this->Socket->request); - $v = $this->assertEquals($r, $expectation, 'Failed test #'.$i.' '); + $v = $this->assertEquals($r, $expectation, 'Failed test #' . $i . ' '); $expectation['request']['raw'] = $raw; } @@ -560,10 +583,9 @@ function testRequest() { /** * testRequest2 method * - * @access public * @return void */ - function testRequest2() { + public function testRequest2() { $this->Socket->reset(); $request = array('uri' => 'htpp://www.cakephp.org/'); $number = mt_rand(0, 9999999); @@ -580,10 +602,9 @@ function testRequest2() { /** * testRequest3 method * - * @access public * @return void */ - function testRequest3() { + public function testRequest3() { $request = array('uri' => 'htpp://www.cakephp.org/'); $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a cookie test!

"; $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); @@ -605,7 +626,7 @@ function testRequest3() { * * @return void */ - function testProxy() { + public function testProxy() { $this->Socket->reset(); $this->Socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $this->Socket->expects($this->any())->method('read')->will($this->returnValue(false)); @@ -633,10 +654,9 @@ function testProxy() { /** * testUrl method * - * @access public * @return void */ - function testUrl() { + public function testUrl() { $this->Socket->reset(true); $this->assertEquals($this->Socket->url(true), false); @@ -688,10 +708,9 @@ function testUrl() { /** * testGet method * - * @access public * @return void */ - function testGet() { + public function testGet() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) @@ -701,7 +720,7 @@ function testGet() { $this->RequestSocket->expects($this->at(1)) ->method('request') ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/?foo=bar')); - + $this->RequestSocket->expects($this->at(2)) ->method('request') ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/?foo=bar')); @@ -745,7 +764,7 @@ public function testAuth() { * * @return void */ - function testConsecutiveGetResetsAuthCredentials() { + public function testConsecutiveGetResetsAuthCredentials() { $socket = new MockHttpSocket(); $socket->get('http://mark:secret@example.com/test'); $this->assertEqual($socket->request['uri']['user'], 'mark'); @@ -762,10 +781,9 @@ function testConsecutiveGetResetsAuthCredentials() { /** * testPostPutDelete method * - * @access public * @return void */ - function testPost() { + public function testPost() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') @@ -784,7 +802,12 @@ function testPost() { $this->RequestSocket->post('http://www.google.com/', null, array('line' => 'Hey Server')); } - function testPut() { +/** + * testPut + * + * @return void + */ + public function testPut() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') @@ -803,7 +826,12 @@ function testPut() { $this->RequestSocket->put('http://www.google.com/', null, array('line' => 'Hey Server')); } - function testDelete() { +/** + * testDelete + * + * @return void + */ + public function testDelete() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') @@ -825,10 +853,9 @@ function testDelete() { /** * testParseResponse method * - * @access public * @return void */ - function testParseResponse() { + public function testParseResponse() { $this->Socket->reset(); $r = $this->Socket->parseResponse(array('foo' => 'bar')); @@ -846,8 +873,8 @@ function testParseResponse() { 'status-line' => "HTTP/1.x 200 OK\r\n", 'header' => "Date: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\n", 'body' => "

Hello World

\r\n

It's good to be html

" - ) - , 'expectations' => array( + ), + 'expectations' => array( 'status.http-version' => 'HTTP/1.x', 'status.code' => 200, 'status.reason-phrase' => 'OK', @@ -858,9 +885,9 @@ function testParseResponse() { 'no-header' => array( 'response' => array( 'status-line' => "HTTP/1.x 404 OK\r\n", - 'header' => null, - ) - , 'expectations' => array( + 'header' => null + ), + 'expectations' => array( 'status.code' => 404, 'header' => array() ) @@ -897,19 +924,18 @@ function testParseResponse() { $expectations = array(); foreach ($tests as $name => $test) { - $testResponse = array_merge($testResponse, $test['response']); - $testResponse['response'] = $testResponse['status-line'].$testResponse['header']."\r\n".$testResponse['body']; + $testResponse['response'] = $testResponse['status-line'] . $testResponse['header'] . "\r\n" . $testResponse['body']; $r = $this->Socket->parseResponse($testResponse['response']); $expectations = array_merge($expectations, $test['expectations']); foreach ($expectations as $property => $expectedVal) { $val = Set::extract($r, $property); - $this->assertEquals($val, $expectedVal, 'Test "'.$name.'": response.'.$property.' - %s'); + $this->assertEquals($val, $expectedVal, 'Test "' . $name . '": response.' . $property . ' - %s'); } foreach (array('status-line', 'header', 'body', 'response') as $field) { - $this->assertEquals($r['raw'][$field], $testResponse[$field], 'Test response.raw.'.$field.': %s'); + $this->assertEquals($r['raw'][$field], $testResponse[$field], 'Test response.raw.' . $field . ': %s'); } } } @@ -917,10 +943,9 @@ function testParseResponse() { /** * testDecodeBody method * - * @access public * @return void */ - function testDecodeBody() { + public function testDecodeBody() { $this->Socket->reset(); $r = $this->Socket->decodeBody(true); @@ -939,7 +964,12 @@ function testDecodeBody() { $this->assertEquals($r, $sample['decoded']); } - function testDecodeFooCoded() { +/** + * testDecodeFooCoded + * + * @return void + */ + public function testDecodeFooCoded() { $this->Socket->reset(); $r = $this->Socket->decodeBody(true); @@ -967,10 +997,9 @@ function testDecodeFooCoded() { /** * testDecodeChunkedBody method * - * @access public * @return void */ - function testDecodeChunkedBody() { + public function testDecodeChunkedBody() { $this->Socket->reset(); $r = $this->Socket->decodeChunkedBody(true); @@ -1023,10 +1052,9 @@ function testDecodeChunkedBody() { /** * testBuildRequestLine method * - * @access public * @return void */ - function testBuildRequestLine() { + public function testBuildRequestLine() { $this->Socket->reset(); $this->Socket->quirksMode = true; @@ -1067,7 +1095,7 @@ function testBuildRequestLine() { $request['method'] = 'GET'; $this->Socket->quirksMode = true; $r = $this->Socket->buildRequestLine($request); - $this->assertEquals($r, "GET * HTTP/1.1\r\n"); + $this->assertEquals($r, "GET * HTTP/1.1\r\n"); $r = $this->Socket->buildRequestLine("GET * HTTP/1.1\r\n"); $this->assertEquals($r, "GET * HTTP/1.1\r\n"); @@ -1076,10 +1104,9 @@ function testBuildRequestLine() { /** * testBadBuildRequestLine method * - * @access public * @return void */ - function testBadBuildRequestLine() { + public function testBadBuildRequestLine() { $this->expectError(); $r = $this->Socket->buildRequestLine('Foo'); } @@ -1087,10 +1114,9 @@ function testBadBuildRequestLine() { /** * testBadBuildRequestLine2 method * - * @access public * @return void */ - function testBadBuildRequestLine2() { + public function testBadBuildRequestLine2() { $this->expectError(); $r = $this->Socket->buildRequestLine("GET * HTTP/1.1\r\n"); } @@ -1098,10 +1124,9 @@ function testBadBuildRequestLine2() { /** * Asserts that HttpSocket::parseUri is working properly * - * @access public * @return void */ - function testParseUri() { + public function testParseUri() { $this->Socket->reset(); $uri = $this->Socket->parseUri(array('invalid' => 'uri-string')); @@ -1132,7 +1157,7 @@ function testParseUri() { $this->assertEquals($uri, array( 'scheme' => 'http', 'host' => 'www.cakephp.org', - 'path' => '/', + 'path' => '/' )); $uri = $this->Socket->parseUri('http://www.cakephp.org', true); @@ -1197,7 +1222,7 @@ function testParseUri() { $this->assertEquals($uri, array( 'scheme' => 'http', 'host' => 'www.google.com', - 'port' => 8080, + 'port' => 8080 )); $uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1¶m2=value2%3Dvalue3'); @@ -1226,10 +1251,9 @@ function testParseUri() { /** * Tests that HttpSocket::buildUri can turn all kinds of uri arrays (and strings) into fully or partially qualified URI's * - * @access public * @return void */ - function testBuildUri() { + public function testBuildUri() { $this->Socket->reset(); $r = $this->Socket->buildUri(true); @@ -1293,10 +1317,9 @@ function testBuildUri() { /** * Asserts that HttpSocket::parseQuery is working properly * - * @access public * @return void */ - function testParseQuery() { + public function testParseQuery() { $this->Socket->reset(); $query = $this->Socket->parseQuery(array('framework' => 'cakephp')); @@ -1345,16 +1368,10 @@ function testParseQuery() { $query = $this->Socket->parseQuery('a[][]=foo&a[bar]=php&a[][]=bar&a[][]=cake'); $expectedQuery = array( 'a' => array( - 0 => array( - 0 => 'foo' - ), + array('foo'), 'bar' => 'php', - 1 => array( - 0 => 'bar' - ), - array( - 0 => 'cake' - ) + array('bar'), + array('cake') ) ); $this->assertEquals($query, $expectedQuery); @@ -1400,10 +1417,9 @@ function testParseQuery() { * Tests that HttpSocket::buildHeader can turn a given $header array into a proper header string according to * HTTP 1.1 specs. * - * @access public * @return void */ - function testBuildHeader() { + public function testBuildHeader() { $this->Socket->reset(); $r = $this->Socket->buildHeader(true); @@ -1438,10 +1454,9 @@ function testBuildHeader() { /** * Test that HttpSocket::parseHeader can take apart a given (and valid) $header string and turn it into an array. * - * @access public * @return void */ - function testParseHeader() { + public function testParseHeader() { $this->Socket->reset(); $r = $this->Socket->parseHeader(array('foo' => 'Bar', 'fOO-bAr' => 'quux')); @@ -1460,32 +1475,32 @@ function testParseHeader() { $header = "Date:Sat, 07 Apr 2007 10:10:25 GMT\r\nX-Powered-By: PHP/5.1.2\r\n"; $r = $this->Socket->parseHeader($header); $expected = array( - 'Date' => 'Sat, 07 Apr 2007 10:10:25 GMT' - , 'X-Powered-By' => 'PHP/5.1.2' + 'Date' => 'Sat, 07 Apr 2007 10:10:25 GMT', + 'X-Powered-By' => 'PHP/5.1.2' ); $this->assertEquals($r, $expected); $header = "people: Jim,John\r\nfoo-LAND: Bar\r\ncAKe-PHP: rocks\r\n"; $r = $this->Socket->parseHeader($header); $expected = array( - 'people' => 'Jim,John' - , 'foo-LAND' => 'Bar' - , 'cAKe-PHP' => 'rocks' + 'people' => 'Jim,John', + 'foo-LAND' => 'Bar', + 'cAKe-PHP' => 'rocks' ); $this->assertEquals($r, $expected); $header = "People: Jim,John,Tim\r\nPeople: Lisa,Tina,Chelsea\r\n"; $r = $this->Socket->parseHeader($header); $expected = array( - 'People' => array('Jim,John,Tim', 'Lisa,Tina,Chelsea') + 'People' => array('Jim,John,Tim', 'Lisa,Tina,Chelsea') ); $this->assertEquals($r, $expected); $header = "Multi-Line: I am a \r\nmulti line\t\r\nfield value.\r\nSingle-Line: I am not\r\n"; $r = $this->Socket->parseHeader($header); $expected = array( - 'Multi-Line' => "I am a\r\nmulti line\r\nfield value." - , 'Single-Line' => 'I am not' + 'Multi-Line' => "I am a\r\nmulti line\r\nfield value.", + 'Single-Line' => 'I am not' ); $this->assertEquals($r, $expected); @@ -1500,10 +1515,9 @@ function testParseHeader() { /** * testParseCookies method * - * @access public * @return void */ - function testParseCookies() { + public function testParseCookies() { $header = array( 'Set-Cookie' => array( 'foo=bar', @@ -1543,10 +1557,9 @@ function testParseCookies() { * testBuildCookies method * * @return void - * @access public * @todo Test more scenarios */ - function testBuildCookies() { + public function testBuildCookies() { $cookies = array( 'foo' => array( 'value' => 'bar' @@ -1564,10 +1577,9 @@ function testBuildCookies() { /** * Tests that HttpSocket::_tokenEscapeChars() returns the right characters. * - * @access public * @return void */ - function testTokenEscapeChars() { + public function testTokenEscapeChars() { $this->Socket->reset(); $expected = array( @@ -1590,19 +1602,18 @@ function testTokenEscapeChars() { /** * Test that HttpSocket::escapeToken is escaping all characters as descriped in RFC 2616 (HTTP 1.1 specs) * - * @access public * @return void */ - function testEscapeToken() { + public function testEscapeToken() { $this->Socket->reset(); $this->assertEquals($this->Socket->escapeToken('Foo'), 'Foo'); $escape = $this->Socket->tokenEscapeChars(false); foreach ($escape as $char) { - $token = 'My-special-'.$char.'-Token'; + $token = 'My-special-' . $char . '-Token'; $escapedToken = $this->Socket->escapeToken($token); - $expectedToken = 'My-special-"'.$char.'"-Token'; + $expectedToken = 'My-special-"' . $char . '"-Token'; $this->assertEquals($escapedToken, $expectedToken, 'Test token escaping for ASCII '.ord($char)); } @@ -1616,19 +1627,18 @@ function testEscapeToken() { /** * Test that escaped token strings are properly unescaped by HttpSocket::unescapeToken * - * @access public * @return void */ - function testUnescapeToken() { + public function testUnescapeToken() { $this->Socket->reset(); $this->assertEquals($this->Socket->unescapeToken('Foo'), 'Foo'); $escape = $this->Socket->tokenEscapeChars(false); foreach ($escape as $char) { - $token = 'My-special-"'.$char.'"-Token'; + $token = 'My-special-"' . $char . '"-Token'; $unescapedToken = $this->Socket->unescapeToken($token); - $expectedToken = 'My-special-'.$char.'-Token'; + $expectedToken = 'My-special-' . $char . '-Token'; $this->assertEquals($unescapedToken, $expectedToken, 'Test token unescaping for ASCII '.ord($char)); } @@ -1643,10 +1653,9 @@ function testUnescapeToken() { * This tests asserts HttpSocket::reset() resets a HttpSocket instance to it's initial state (before Object::__construct * got executed) * - * @access public * @return void */ - function testReset() { + public function testReset() { $this->Socket->reset(); $initialState = get_class_vars('HttpSocket'); @@ -1667,10 +1676,9 @@ function testReset() { * This tests asserts HttpSocket::reset(false) resets certain HttpSocket properties to their initial state (before * Object::__construct got executed). * - * @access public * @return void */ - function testPartialReset() { + public function testPartialReset() { $this->Socket->reset(); $partialResetProperties = array('request', 'response');