mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-12-17 14:13:58 +01: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,20 +2,20 @@
|
|||
/**
|
||||
* ClassRegistryTest 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.Utility
|
||||
* @since CakePHP(tm) v 1.2.0.5432
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('ClassRegistry', 'Utility');
|
||||
|
||||
/**
|
||||
|
|
@ -28,7 +28,7 @@ class ClassRegisterModel extends CakeTestModel {
|
|||
/**
|
||||
* useTable property
|
||||
*
|
||||
* @var bool false
|
||||
* @var bool
|
||||
*/
|
||||
public $useTable = false;
|
||||
}
|
||||
|
|
@ -39,13 +39,6 @@ class ClassRegisterModel extends CakeTestModel {
|
|||
* @package Cake.Test.Case.Utility
|
||||
*/
|
||||
class RegisterArticle extends ClassRegisterModel {
|
||||
|
||||
/**
|
||||
* name property
|
||||
*
|
||||
* @var string 'RegisterArticle'
|
||||
*/
|
||||
public $name = 'RegisterArticle';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,13 +47,6 @@ class RegisterArticle extends ClassRegisterModel {
|
|||
* @package Cake.Test.Case.Utility
|
||||
*/
|
||||
class RegisterArticleFeatured extends ClassRegisterModel {
|
||||
|
||||
/**
|
||||
* name property
|
||||
*
|
||||
* @var string 'RegisterArticleFeatured'
|
||||
*/
|
||||
public $name = 'RegisterArticleFeatured';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -69,13 +55,6 @@ class RegisterArticleFeatured extends ClassRegisterModel {
|
|||
* @package Cake.Test.Case.Utility
|
||||
*/
|
||||
class RegisterArticleTag extends ClassRegisterModel {
|
||||
|
||||
/**
|
||||
* name property
|
||||
*
|
||||
* @var string 'RegisterArticleTag'
|
||||
*/
|
||||
public $name = 'RegisterArticleTag';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,7 +67,7 @@ class RegistryPluginAppModel extends ClassRegisterModel {
|
|||
/**
|
||||
* tablePrefix property
|
||||
*
|
||||
* @var string 'something_'
|
||||
* @var string
|
||||
*/
|
||||
public $tablePrefix = 'something_';
|
||||
}
|
||||
|
|
@ -99,13 +78,6 @@ class RegistryPluginAppModel extends ClassRegisterModel {
|
|||
* @package Cake.Test.Case.Utility
|
||||
*/
|
||||
class TestRegistryPluginModel extends RegistryPluginAppModel {
|
||||
|
||||
/**
|
||||
* name property
|
||||
*
|
||||
* @var string 'TestRegistryPluginModel'
|
||||
*/
|
||||
public $name = 'TestRegistryPluginModel';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,13 +86,6 @@ class TestRegistryPluginModel extends RegistryPluginAppModel {
|
|||
* @package Cake.Test.Case.Utility
|
||||
*/
|
||||
class RegisterCategory extends ClassRegisterModel {
|
||||
|
||||
/**
|
||||
* name property
|
||||
*
|
||||
* @var string 'RegisterCategory'
|
||||
*/
|
||||
public $name = 'RegisterCategory';
|
||||
}
|
||||
/**
|
||||
* RegisterPrefixedDs class
|
||||
|
|
@ -132,7 +97,7 @@ class RegisterPrefixedDs extends ClassRegisterModel {
|
|||
/**
|
||||
* useDbConfig property
|
||||
*
|
||||
* @var string 'doesnotexist'
|
||||
* @var string
|
||||
*/
|
||||
public $useDbConfig = 'doesnotexist';
|
||||
}
|
||||
|
|
@ -169,7 +134,7 @@ class ClassRegistryTest extends CakeTestCase {
|
|||
*/
|
||||
public function testAddModel() {
|
||||
$Tag = ClassRegistry::init('RegisterArticleTag');
|
||||
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
|
||||
$this->assertInstanceOf('RegisterArticleTag', $Tag);
|
||||
|
||||
$TagCopy = ClassRegistry::isKeySet('RegisterArticleTag');
|
||||
$this->assertTrue($TagCopy);
|
||||
|
|
@ -178,11 +143,11 @@ class ClassRegistryTest extends CakeTestCase {
|
|||
|
||||
$TagCopy = ClassRegistry::getObject('RegisterArticleTag');
|
||||
|
||||
$this->assertTrue(is_a($TagCopy, 'RegisterArticleTag'));
|
||||
$this->assertInstanceOf('RegisterArticleTag', $TagCopy);
|
||||
$this->assertSame($Tag, $TagCopy);
|
||||
|
||||
$NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
|
||||
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
|
||||
$this->assertInstanceOf('RegisterArticleTag', $NewTag);
|
||||
|
||||
$NewTagCopy = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
|
||||
|
||||
|
|
@ -199,17 +164,17 @@ class ClassRegistryTest extends CakeTestCase {
|
|||
$this->assertTrue($TagCopy->name === 'SomeOtherName');
|
||||
|
||||
$User = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false));
|
||||
$this->assertTrue(is_a($User, 'AppModel'));
|
||||
$this->assertInstanceOf('AppModel', $User);
|
||||
|
||||
$UserCopy = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false));
|
||||
$this->assertTrue(is_a($UserCopy, 'AppModel'));
|
||||
$this->assertInstanceOf('AppModel', $UserCopy);
|
||||
$this->assertEquals($User, $UserCopy);
|
||||
|
||||
$Category = ClassRegistry::init(array('class' => 'RegisterCategory'));
|
||||
$this->assertTrue(is_a($Category, 'RegisterCategory'));
|
||||
$this->assertInstanceOf('RegisterCategory', $Category);
|
||||
|
||||
$ParentCategory = ClassRegistry::init(array('class' => 'RegisterCategory', 'alias' => 'ParentCategory'));
|
||||
$this->assertTrue(is_a($ParentCategory, 'RegisterCategory'));
|
||||
$this->assertInstanceOf('RegisterCategory', $ParentCategory);
|
||||
$this->assertNotSame($Category, $ParentCategory);
|
||||
|
||||
$this->assertNotEquals($Category->alias, $ParentCategory->alias);
|
||||
|
|
@ -217,21 +182,50 @@ class ClassRegistryTest extends CakeTestCase {
|
|||
$this->assertEquals('ParentCategory', $ParentCategory->alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that init() can make models with alias set properly
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddModelWithAlias() {
|
||||
$tag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
|
||||
$this->assertInstanceOf('RegisterArticleTag', $tag);
|
||||
$this->assertSame('NewTag', $tag->alias);
|
||||
$this->assertSame('RegisterArticleTag', $tag->name);
|
||||
|
||||
$newTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'OtherTag'));
|
||||
$this->assertInstanceOf('RegisterArticleTag', $tag);
|
||||
$this->assertSame('OtherTag', $newTag->alias);
|
||||
$this->assertSame('RegisterArticleTag', $newTag->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that init() can make the Aco models with alias set properly
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddModelWithAliasAco() {
|
||||
$aco = ClassRegistry::init(array('class' => 'Aco', 'alias' => 'CustomAco'));
|
||||
$this->assertInstanceOf('Aco', $aco);
|
||||
$this->assertSame('Aco', $aco->name);
|
||||
$this->assertSame('CustomAco', $aco->alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* testClassRegistryFlush method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testClassRegistryFlush() {
|
||||
$Tag = ClassRegistry::init('RegisterArticleTag');
|
||||
ClassRegistry::init('RegisterArticleTag');
|
||||
|
||||
$ArticleTag = ClassRegistry::getObject('RegisterArticleTag');
|
||||
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
|
||||
$this->assertInstanceOf('RegisterArticleTag', $ArticleTag);
|
||||
ClassRegistry::flush();
|
||||
|
||||
$NoArticleTag = ClassRegistry::isKeySet('RegisterArticleTag');
|
||||
$this->assertFalse($NoArticleTag);
|
||||
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
|
||||
$this->assertInstanceOf('RegisterArticleTag', $ArticleTag);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -266,13 +260,13 @@ class ClassRegistryTest extends CakeTestCase {
|
|||
$this->assertTrue($Tag);
|
||||
|
||||
$Article = ClassRegistry::getObject('Article');
|
||||
$this->assertTrue(is_a($Article, 'RegisterArticle'));
|
||||
$this->assertInstanceOf('RegisterArticle', $Article);
|
||||
|
||||
$Featured = ClassRegistry::getObject('Featured');
|
||||
$this->assertTrue(is_a($Featured, 'RegisterArticleFeatured'));
|
||||
$this->assertInstanceOf('RegisterArticleFeatured', $Featured);
|
||||
|
||||
$Tag = ClassRegistry::getObject('Tag');
|
||||
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
|
||||
$this->assertInstanceOf('RegisterArticleTag', $Tag);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -287,15 +281,15 @@ class ClassRegistryTest extends CakeTestCase {
|
|||
//Faking a plugin
|
||||
CakePlugin::load('RegistryPlugin', array('path' => '/fake/path'));
|
||||
$TestRegistryPluginModel = ClassRegistry::init('RegistryPlugin.TestRegistryPluginModel');
|
||||
$this->assertTrue(is_a($TestRegistryPluginModel, 'TestRegistryPluginModel'));
|
||||
$this->assertInstanceOf('TestRegistryPluginModel', $TestRegistryPluginModel);
|
||||
|
||||
$this->assertEquals('something_', $TestRegistryPluginModel->tablePrefix);
|
||||
|
||||
$PluginUser = ClassRegistry::init(array('class' => 'RegistryPlugin.RegisterUser', 'alias' => 'RegistryPluginUser', 'table' => false));
|
||||
$this->assertTrue(is_a($PluginUser, 'RegistryPluginAppModel'));
|
||||
$this->assertInstanceOf('RegistryPluginAppModel', $PluginUser);
|
||||
|
||||
$PluginUserCopy = ClassRegistry::getObject('RegistryPluginUser');
|
||||
$this->assertTrue(is_a($PluginUserCopy, 'RegistryPluginAppModel'));
|
||||
$this->assertInstanceOf('RegistryPluginAppModel', $PluginUserCopy);
|
||||
$this->assertSame($PluginUser, $PluginUserCopy);
|
||||
CakePlugin::unload();
|
||||
}
|
||||
|
|
@ -303,6 +297,7 @@ class ClassRegistryTest extends CakeTestCase {
|
|||
/**
|
||||
* Tests prefixed datasource names for test purposes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPrefixedTestDatasource() {
|
||||
ClassRegistry::config(array('testing' => true));
|
||||
|
|
@ -322,6 +317,7 @@ class ClassRegistryTest extends CakeTestCase {
|
|||
/**
|
||||
* Tests that passing the string parameter to init() will return false if the model does not exists
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInitStrict() {
|
||||
$this->assertFalse(ClassRegistry::init('NonExistent', true));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue