mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-04 07:03:41 +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,25 +2,29 @@
|
|||
/**
|
||||
* CacheSessionTest
|
||||
*
|
||||
* 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://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Test.Case.Model.Datasource.Session
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('CakeSession', 'Model/Datasource');
|
||||
App::uses('CacheSession', 'Model/Datasource/Session');
|
||||
class_exists('CakeSession');
|
||||
|
||||
/**
|
||||
* CacheSessionTest
|
||||
*
|
||||
* @package Cake.Test.Case.Model.Datasource.Session
|
||||
*/
|
||||
class CacheSessionTest extends CakeTestCase {
|
||||
|
||||
protected static $_sessionBackup;
|
||||
|
@ -35,7 +39,7 @@ class CacheSessionTest extends CakeTestCase {
|
|||
'engine' => 'File',
|
||||
'prefix' => 'session_test_'
|
||||
));
|
||||
self::$_sessionBackup = Configure::read('Session');
|
||||
static::$_sessionBackup = Configure::read('Session');
|
||||
|
||||
Configure::write('Session.handler.config', 'session_test');
|
||||
}
|
||||
|
@ -49,7 +53,7 @@ class CacheSessionTest extends CakeTestCase {
|
|||
Cache::clear(false, 'session_test');
|
||||
Cache::drop('session_test');
|
||||
|
||||
Configure::write('Session', self::$_sessionBackup);
|
||||
Configure::write('Session', static::$_sessionBackup);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,6 +104,8 @@ class CacheSessionTest extends CakeTestCase {
|
|||
public function testRead() {
|
||||
$this->storage->write('test_one', 'Some other value');
|
||||
$this->assertEquals('Some other value', $this->storage->read('test_one'), 'Incorrect value.');
|
||||
$this->storage->write('test_two', 0);
|
||||
$this->assertEquals(0, $this->storage->read('test_two'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,4 +120,4 @@ class CacheSessionTest extends CakeTestCase {
|
|||
$this->assertFalse(Cache::read('test_one', 'session_test'), 'Value stuck around.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,19 +2,18 @@
|
|||
/**
|
||||
* DatabaseSessionTest 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://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Test.Case.Model.Datasource.Session
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('Model', 'Model');
|
||||
|
@ -22,10 +21,13 @@ App::uses('CakeSession', 'Model/Datasource');
|
|||
App::uses('DatabaseSession', 'Model/Datasource/Session');
|
||||
class_exists('CakeSession');
|
||||
|
||||
/**
|
||||
* SessionTestModel
|
||||
*
|
||||
* @package Cake.Test.Case.Model.Datasource.Session
|
||||
*/
|
||||
class SessionTestModel extends Model {
|
||||
|
||||
public $name = 'SessionTestModel';
|
||||
|
||||
public $useTable = 'sessions';
|
||||
|
||||
}
|
||||
|
@ -52,7 +54,7 @@ class DatabaseSessionTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public static function setupBeforeClass() {
|
||||
self::$_sessionBackup = Configure::read('Session');
|
||||
static::$_sessionBackup = Configure::read('Session');
|
||||
Configure::write('Session.handler', array(
|
||||
'model' => 'SessionTestModel',
|
||||
));
|
||||
|
@ -65,7 +67,7 @@ class DatabaseSessionTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public static function teardownAfterClass() {
|
||||
Configure::write('Session', self::$_sessionBackup);
|
||||
Configure::write('Session', static::$_sessionBackup);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,7 +98,7 @@ class DatabaseSessionTest extends CakeTestCase {
|
|||
*/
|
||||
public function testConstructionSettings() {
|
||||
ClassRegistry::flush();
|
||||
$storage = new DatabaseSession();
|
||||
new DatabaseSession();
|
||||
|
||||
$session = ClassRegistry::getObject('session');
|
||||
$this->assertInstanceOf('SessionTestModel', $session);
|
||||
|
@ -120,19 +122,8 @@ class DatabaseSessionTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testWrite() {
|
||||
$result = $this->storage->write('foo', 'Some value');
|
||||
$expected = array(
|
||||
'Session' => array(
|
||||
'id' => 'foo',
|
||||
'data' => 'Some value',
|
||||
)
|
||||
);
|
||||
$expires = $result['Session']['expires'];
|
||||
unset($result['Session']['expires']);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$expected = time() + (Configure::read('Session.timeout') * 60);
|
||||
$this->assertWithinMargin($expires, $expected, 1);
|
||||
$this->storage->write('foo', 'Some value');
|
||||
$this->assertEquals($this->storage->read('foo'), 'Some value');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -152,13 +143,10 @@ class DatabaseSessionTest extends CakeTestCase {
|
|||
*/
|
||||
public function testRead() {
|
||||
$this->storage->write('foo', 'Some value');
|
||||
|
||||
$result = $this->storage->read('foo');
|
||||
$expected = 'Some value';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$result = $this->storage->read('made up value');
|
||||
$this->assertFalse($result);
|
||||
$this->assertEquals($this->storage->read('foo'), 'Some value');
|
||||
$this->storage->write('bar', 0);
|
||||
$this->assertEquals(0, $this->storage->read('bar'));
|
||||
$this->assertSame('', $this->storage->read('made up value'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,7 +158,7 @@ class DatabaseSessionTest extends CakeTestCase {
|
|||
$this->storage->write('foo', 'Some value');
|
||||
|
||||
$this->assertTrue($this->storage->destroy('foo'), 'Destroy failed');
|
||||
$this->assertFalse($this->storage->read('foo'), 'Value still present.');
|
||||
$this->assertSame($this->storage->read('foo'), '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,6 +175,58 @@ class DatabaseSessionTest extends CakeTestCase {
|
|||
|
||||
sleep(1);
|
||||
$storage->gc();
|
||||
$this->assertFalse($storage->read('foo'));
|
||||
$this->assertSame($storage->read('foo'), '');
|
||||
}
|
||||
|
||||
/**
|
||||
* testConcurrentInsert
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConcurrentInsert() {
|
||||
$this->skipIf(
|
||||
$this->db instanceof Sqlite,
|
||||
'Sqlite does not throw exceptions when attempting to insert a duplicate primary key'
|
||||
);
|
||||
|
||||
ClassRegistry::removeObject('Session');
|
||||
|
||||
$mockedModel = $this->getMockForModel(
|
||||
'SessionTestModel',
|
||||
array('exists'),
|
||||
array('alias' => 'MockedSessionTestModel', 'table' => 'sessions')
|
||||
);
|
||||
Configure::write('Session.handler.model', 'MockedSessionTestModel');
|
||||
|
||||
$counter = 0;
|
||||
// First save
|
||||
$mockedModel->expects($this->at($counter++))
|
||||
->method('exists')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
// Second save
|
||||
$mockedModel->expects($this->at($counter++))
|
||||
->method('exists')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
// Second save retry
|
||||
$mockedModel->expects($this->at($counter++))
|
||||
->method('exists')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
// Datasource exists check
|
||||
$mockedModel->expects($this->at($counter++))
|
||||
->method('exists')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->storage = new DatabaseSession();
|
||||
|
||||
$this->storage->write('foo', 'Some value');
|
||||
$return = $this->storage->read('foo');
|
||||
$this->assertSame('Some value', $return);
|
||||
|
||||
$this->storage->write('foo', 'Some other value');
|
||||
$return = $this->storage->read('foo');
|
||||
$this->assertSame('Some other value', $return);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue