mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-05 23:53:38 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -2,21 +2,19 @@
|
|||
/**
|
||||
* HttpResponseTest file
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
||||
* @package Cake.Test.Case.Network.Http
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('HttpResponse', 'Network/Http');
|
||||
|
||||
/**
|
||||
|
@ -40,7 +38,7 @@ class TestHttpResponse extends HttpResponse {
|
|||
* Convenience method for testing protected method
|
||||
*
|
||||
* @param string $body A string containing the body to decode
|
||||
* @param boolean|string $encoding Can be false in case no encoding is being used, or a string representing the encoding
|
||||
* @param bool|string $encoding Can be false in case no encoding is being used, or a string representing the encoding
|
||||
* @return mixed Array or false
|
||||
*/
|
||||
public function decodeBody($body, $encoding = 'chunked') {
|
||||
|
@ -70,7 +68,7 @@ class TestHttpResponse extends HttpResponse {
|
|||
/**
|
||||
* Convenience method for testing protected method
|
||||
*
|
||||
* @param boolean $hex true to get them as HEX values, false otherwise
|
||||
* @param bool $hex true to get them as HEX values, false otherwise
|
||||
* @return array Escape chars
|
||||
*/
|
||||
public function tokenEscapeChars($hex = true, $chars = null) {
|
||||
|
@ -92,6 +90,7 @@ class HttpResponseTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->HttpResponse = new TestHttpResponse();
|
||||
}
|
||||
|
||||
|
@ -141,7 +140,7 @@ class HttpResponseTest extends CakeTestCase {
|
|||
$this->assertEquals('Bar', $this->HttpResponse->getHeader('FOO'));
|
||||
$this->assertEquals('value', $this->HttpResponse->getHeader('header'));
|
||||
$this->assertEquals('text/plain', $this->HttpResponse->getHeader('Content-Type'));
|
||||
$this->assertSame($this->HttpResponse->getHeader(0), null);
|
||||
$this->assertNull($this->HttpResponse->getHeader(0));
|
||||
|
||||
$this->assertEquals('Bar', $this->HttpResponse->getHeader('foo', false));
|
||||
$this->assertEquals('not from class', $this->HttpResponse->getHeader('foo', array('foo' => 'not from class')));
|
||||
|
@ -157,12 +156,36 @@ class HttpResponseTest extends CakeTestCase {
|
|||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = -1;
|
||||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 201;
|
||||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 'what?';
|
||||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 200;
|
||||
$this->assertTrue($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 201;
|
||||
$this->assertTrue($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 202;
|
||||
$this->assertTrue($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 203;
|
||||
$this->assertTrue($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 204;
|
||||
$this->assertTrue($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 205;
|
||||
$this->assertTrue($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 206;
|
||||
$this->assertTrue($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 207;
|
||||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 208;
|
||||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 209;
|
||||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 210;
|
||||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 226;
|
||||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 288;
|
||||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
$this->HttpResponse->code = 301;
|
||||
$this->assertFalse($this->HttpResponse->isOk());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -244,10 +267,19 @@ class HttpResponseTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertEquals($expected, $r);
|
||||
|
||||
$header = "Multi-Line: I am a \r\nmulti line\t\r\nfield value.\r\nSingle-Line: I am not\r\n";
|
||||
$header = "Date:Sat, 07 Apr 2007 10:10:25 GMT\r\nLink: \r\nX-Total-Count: 19\r\n";
|
||||
$r = $this->HttpResponse->parseHeader($header);
|
||||
$expected = array(
|
||||
'Multi-Line' => "I am a\r\nmulti line\r\nfield value.",
|
||||
'Date' => 'Sat, 07 Apr 2007 10:10:25 GMT',
|
||||
'Link' => '',
|
||||
'X-Total-Count' => '19',
|
||||
);
|
||||
$this->assertEquals($expected, $r);
|
||||
|
||||
$header = "Multi-Line: I am a\r\n multi line \r\n\tfield value.\r\nSingle-Line: I am not\r\n";
|
||||
$r = $this->HttpResponse->parseHeader($header);
|
||||
$expected = array(
|
||||
'Multi-Line' => "I am a multi line field value.",
|
||||
'Single-Line' => 'I am not'
|
||||
);
|
||||
$this->assertEquals($expected, $r);
|
||||
|
@ -331,7 +363,7 @@ class HttpResponseTest extends CakeTestCase {
|
|||
*
|
||||
* @dataProvider invalidParseResponseDataProvider
|
||||
* @expectedException SocketException
|
||||
* return void
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidParseResponseData($value) {
|
||||
$this->HttpResponse->parseResponse($value);
|
||||
|
@ -429,12 +461,13 @@ class HttpResponseTest extends CakeTestCase {
|
|||
/**
|
||||
* testDecodeChunkedBodyError method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testDecodeChunkedBodyError() {
|
||||
$encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n";
|
||||
$r = $this->HttpResponse->decodeChunkedBody($encoded);
|
||||
$result = $this->HttpResponse->decodeChunkedBody($encoded);
|
||||
$expected = "This is a chunked message\nThat is cool\n";
|
||||
$this->assertEquals($expected, $result['body']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -447,7 +480,9 @@ class HttpResponseTest extends CakeTestCase {
|
|||
'Set-Cookie' => array(
|
||||
'foo=bar',
|
||||
'people=jim,jack,johnny";";Path=/accounts',
|
||||
'google=not=nice'
|
||||
'google=not=nice',
|
||||
'1271; domain=.example.com; expires=Fri, 04-Nov-2016 12:50:26 GMT; path=/',
|
||||
'cakephp=great; Secure'
|
||||
),
|
||||
'Transfer-Encoding' => 'chunked',
|
||||
'Date' => 'Sun, 18 Nov 2007 18:57:42 GMT',
|
||||
|
@ -463,17 +498,24 @@ class HttpResponseTest extends CakeTestCase {
|
|||
),
|
||||
'google' => array(
|
||||
'value' => 'not=nice',
|
||||
),
|
||||
'' => array(
|
||||
'value' => '1271',
|
||||
'domain' => '.example.com',
|
||||
'expires' => 'Fri, 04-Nov-2016 12:50:26 GMT',
|
||||
'path' => '/'
|
||||
),
|
||||
'cakephp' => array(
|
||||
'value' => 'great',
|
||||
'secure' => true,
|
||||
)
|
||||
);
|
||||
$this->assertEquals($expected, $cookies);
|
||||
|
||||
$header['Set-Cookie'][] = 'cakephp=great; Secure';
|
||||
$expected['cakephp'] = array('value' => 'great', 'secure' => true);
|
||||
$cookies = $this->HttpResponse->parseCookies($header);
|
||||
$this->assertEquals($expected, $cookies);
|
||||
|
||||
$header['Set-Cookie'] = 'foo=bar';
|
||||
unset($expected['people'], $expected['cakephp'], $expected['google']);
|
||||
$expected = array(
|
||||
'foo' => array('value' => 'bar')
|
||||
);
|
||||
$cookies = $this->HttpResponse->parseCookies($header);
|
||||
$this->assertEquals($expected, $cookies);
|
||||
}
|
||||
|
@ -552,7 +594,7 @@ class HttpResponseTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $this->HttpResponse['cookies']);
|
||||
|
||||
$this->HttpResponse->raw = "HTTP/1.1 200 OK\r\n\r\nThis is a test!";
|
||||
$this->assertSame($this->HttpResponse['raw']['header'], null);
|
||||
$this->assertNull($this->HttpResponse['raw']['header']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue