mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '2.6' into 2.7
Conflicts: lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php lib/Cake/VERSION.txt
This commit is contained in:
commit
096a2ebb72
11 changed files with 55 additions and 9 deletions
|
@ -747,7 +747,7 @@ class CakeSession {
|
|||
* @return void
|
||||
*/
|
||||
public static function renew() {
|
||||
if (!session_id()) {
|
||||
if (session_id() === '') {
|
||||
return;
|
||||
}
|
||||
if (isset($_COOKIE[session_name()])) {
|
||||
|
|
|
@ -3566,6 +3566,7 @@ class DboSource extends DataSource {
|
|||
if ($this->_methodCacheChange) {
|
||||
Cache::write('method_cache', self::$methodCache, '_cake_core_');
|
||||
}
|
||||
parent::__destruct();
|
||||
}
|
||||
|
||||
}
|
|
@ -731,7 +731,7 @@ class CakeRequest implements ArrayAccess {
|
|||
*/
|
||||
public static function header($name) {
|
||||
$name = 'HTTP_' . strtoupper(str_replace('-', '_', $name));
|
||||
if (!empty($_SERVER[$name])) {
|
||||
if (isset($_SERVER[$name])) {
|
||||
return $_SERVER[$name];
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1131,12 +1131,14 @@ class CakeRequestTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testHeader() {
|
||||
$_SERVER['HTTP_X_THING'] = '';
|
||||
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-ca) AppleWebKit/534.8+ (KHTML, like Gecko) Version/5.0 Safari/533.16';
|
||||
$request = new CakeRequest('/', false);
|
||||
|
||||
$this->assertEquals($_SERVER['HTTP_HOST'], $request->header('host'));
|
||||
$this->assertEquals($_SERVER['HTTP_USER_AGENT'], $request->header('User-Agent'));
|
||||
$this->assertSame('', $request->header('X-thing'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -311,6 +311,18 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
$this->assertInternalType('array', $this->Case->controller->viewVars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that file responses don't trigger errors.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testActionWithFile() {
|
||||
$Controller = $this->Case->generate('TestsApps');
|
||||
$this->Case->testAction('/tests_apps/file');
|
||||
$this->assertArrayHasKey('Content-Disposition', $Controller->response->header());
|
||||
$this->assertArrayHasKey('Content-Length', $Controller->response->header());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure testAction() can hit plugin controllers.
|
||||
*
|
||||
|
|
|
@ -239,6 +239,19 @@ class HashTest extends CakeTestCase {
|
|||
Hash::get(array('one' => 'two'), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test testGetNullPath()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetNullPath() {
|
||||
$result = Hash::get(array('one' => 'two'), null, '-');
|
||||
$this->assertEquals('-', $result);
|
||||
|
||||
$result = Hash::get(array('one' => 'two'), '', '-');
|
||||
$this->assertEquals('-', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test dimensions.
|
||||
*
|
||||
|
@ -275,6 +288,14 @@ class HashTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testMaxDimensions() {
|
||||
$data = array();
|
||||
$result = Hash::maxDimensions($data);
|
||||
$this->assertEquals(0, $result);
|
||||
|
||||
$data = array('a', 'b');
|
||||
$result = Hash::maxDimensions($data);
|
||||
$this->assertEquals(1, $result);
|
||||
|
||||
$data = array('1' => '1.1', '2', '3' => array('3.1' => '3.1.1'));
|
||||
$result = Hash::maxDimensions($data);
|
||||
$this->assertEquals($result, 2);
|
||||
|
|
|
@ -177,6 +177,7 @@ class InflectorTest extends CakeTestCase {
|
|||
$this->assertEquals(Inflector::singularize('body_curves'), 'body_curve');
|
||||
$this->assertEquals(Inflector::singularize('metadata'), 'metadata');
|
||||
$this->assertEquals(Inflector::singularize('files_metadata'), 'files_metadata');
|
||||
$this->assertEquals(Inflector::singularize('sieves'), 'sieve');
|
||||
$this->assertEquals(Inflector::singularize(''), '');
|
||||
}
|
||||
|
||||
|
@ -248,6 +249,7 @@ class InflectorTest extends CakeTestCase {
|
|||
$this->assertEquals(Inflector::pluralize('metadata'), 'metadata');
|
||||
$this->assertEquals(Inflector::pluralize('files_metadata'), 'files_metadata');
|
||||
$this->assertEquals(Inflector::pluralize('stadia'), 'stadia');
|
||||
$this->assertEquals(Inflector::pluralize('sieve'), 'sieves');
|
||||
$this->assertEquals(Inflector::pluralize(''), '');
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,10 @@ class TestsAppsController extends AppController {
|
|||
$this->render('index');
|
||||
}
|
||||
|
||||
public function file() {
|
||||
$this->response->file(__FILE__);
|
||||
}
|
||||
|
||||
public function redirect_to() {
|
||||
return $this->redirect('http://cakephp.org');
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ abstract class ControllerTestCase extends CakeTestCase {
|
|||
$params['requested'] = 1;
|
||||
}
|
||||
$Dispatch->testController = $this->controller;
|
||||
$Dispatch->response = $this->getMock('CakeResponse', array('send'));
|
||||
$Dispatch->response = $this->getMock('CakeResponse', array('send', '_clearBuffer'));
|
||||
$this->result = $Dispatch->dispatch($request, $Dispatch->response, $params);
|
||||
$this->controller = $Dispatch->testController;
|
||||
$this->vars = $this->controller->viewVars;
|
||||
|
|
|
@ -43,7 +43,7 @@ class Hash {
|
|||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::get
|
||||
*/
|
||||
public static function get(array $data, $path, $default = null) {
|
||||
if (empty($data)) {
|
||||
if (empty($data) || $path === '' || $path === null) {
|
||||
return $default;
|
||||
}
|
||||
if (is_string($path) || is_numeric($path)) {
|
||||
|
@ -55,7 +55,6 @@ class Hash {
|
|||
$path
|
||||
));
|
||||
}
|
||||
|
||||
$parts = $path;
|
||||
}
|
||||
|
||||
|
@ -250,7 +249,7 @@ class Hash {
|
|||
*
|
||||
* @param array $data The data to insert into.
|
||||
* @param string $path The path to insert at.
|
||||
* @param array $values The values to insert.
|
||||
* @param mixed $values The values to insert.
|
||||
* @return array The data with $values inserted.
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::insert
|
||||
*/
|
||||
|
@ -763,10 +762,14 @@ class Hash {
|
|||
$depth = array();
|
||||
if (is_array($data) && reset($data) !== false) {
|
||||
foreach ($data as $value) {
|
||||
$depth[] = self::dimensions((array)$value) + 1;
|
||||
if (is_array($value)) {
|
||||
$depth[] = self::dimensions($value) + 1;
|
||||
} else {
|
||||
$depth[] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max($depth);
|
||||
return empty($depth) ? 0 : max($depth);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,7 +107,8 @@ class Inflector {
|
|||
'hero' => 'heroes',
|
||||
'tooth' => 'teeth',
|
||||
'goose' => 'geese',
|
||||
'foot' => 'feet'
|
||||
'foot' => 'feet',
|
||||
'sieve' => 'sieves'
|
||||
)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue