2007-07-09 19:26:37 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
|
|
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
|
|
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs
|
|
|
|
* @since CakePHP(tm) v 1.2.0.5432
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
|
|
*/
|
|
|
|
uses('class_registry');
|
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
|
|
|
class ClassRegisterModel extends CakeTestModel {
|
|
|
|
var $useTable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
class RegisterArticle extends ClassRegisterModel {
|
|
|
|
var $name = 'RegisterArticle';
|
|
|
|
}
|
|
|
|
class RegisterArticleFeatured extends ClassRegisterModel {
|
|
|
|
var $name = 'RegisterArticlFeatured';
|
|
|
|
}
|
|
|
|
|
|
|
|
class RegisterArticleTag extends ClassRegisterModel {
|
|
|
|
var $name = 'RegisterArticlTag';
|
|
|
|
}
|
|
|
|
|
2007-07-09 19:26:37 +00:00
|
|
|
class ClassRegistryTest extends UnitTestCase {
|
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
|
|
|
function testAddModel() {
|
|
|
|
if (PHP5) {
|
|
|
|
$Tag = ClassRegistry::init('RegisterArticleTag');
|
|
|
|
} else {
|
|
|
|
$Tag =& ClassRegistry::init('RegisterArticleTag');
|
|
|
|
}
|
|
|
|
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
|
|
|
|
|
|
|
|
$TagCopy = ClassRegistry::isKeySet('RegisterArticleTag');
|
|
|
|
$this->assertTrue($TagCopy);
|
|
|
|
|
|
|
|
$Tag->name = 'SomeNewName';
|
|
|
|
|
|
|
|
$TagCopy = ClassRegistry::getObject('RegisterArticleTag');
|
|
|
|
$this->assertTrue(is_a($TagCopy, 'RegisterArticleTag'));
|
|
|
|
$this->assertIdentical($Tag, $TagCopy);
|
|
|
|
|
|
|
|
$NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
|
|
|
|
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
|
|
|
|
|
|
|
|
$this->assertNotIdentical($Tag, $NewTag);
|
|
|
|
|
|
|
|
$NewTag->name = 'SomeOtherName';
|
|
|
|
$this->assertNotIdentical($Tag, $NewTag);
|
|
|
|
|
|
|
|
$Tag->name = 'SomeOtherName';
|
|
|
|
$this->assertNotIdentical($Tag, $NewTag);
|
|
|
|
|
|
|
|
$this->assertTrue($TagCopy->name === 'SomeOtherName');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testClassRegistryFlush () {
|
|
|
|
$ArticleTag = ClassRegistry::getObject('RegisterArticleTag');
|
|
|
|
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
|
|
|
|
ClassRegistry::flush();
|
|
|
|
|
|
|
|
$NoArticleTag = ClassRegistry::isKeySet('RegisterArticleTag');
|
|
|
|
$this->assertFalse($NoArticleTag);
|
|
|
|
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
|
|
|
|
}
|
|
|
|
|
|
|
|
function testAddMultiplModels () {
|
|
|
|
$Article = ClassRegistry::isKeySet('Article');
|
|
|
|
$this->assertFalse($Article);
|
|
|
|
|
|
|
|
$Featured = ClassRegistry::isKeySet('Featured');
|
|
|
|
$this->assertFalse($Featured);
|
|
|
|
|
|
|
|
$Tag = ClassRegistry::isKeySet('Tag');
|
|
|
|
$this->assertFalse($Tag);
|
|
|
|
|
|
|
|
$models = array(array('class' => 'RegisterArticle', 'alias' => 'Article'),
|
|
|
|
array('class' => 'RegisterArticleFeatured', 'alias' => 'Featured'),
|
|
|
|
array('class' => 'RegisterArticleTag', 'alias' => 'Tag'));
|
|
|
|
|
|
|
|
$added = ClassRegistry::init($models);
|
|
|
|
$this->assertTrue($added);
|
|
|
|
|
|
|
|
$Article = ClassRegistry::isKeySet('Article');
|
|
|
|
$this->assertTrue($Article);
|
|
|
|
|
|
|
|
$Featured = ClassRegistry::isKeySet('Featured');
|
|
|
|
$this->assertTrue($Featured);
|
|
|
|
|
|
|
|
$Tag = ClassRegistry::isKeySet('Tag');
|
|
|
|
$this->assertTrue($Tag);
|
|
|
|
|
|
|
|
$Article = ClassRegistry::getObject('Article');
|
|
|
|
$this->assertTrue(is_a($Article, 'RegisterArticle'));
|
|
|
|
|
|
|
|
$Featured = ClassRegistry::getObject('Featured');
|
|
|
|
$this->assertTrue(is_a($Featured, 'RegisterArticleFeatured'));
|
2007-07-09 19:26:37 +00:00
|
|
|
|
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
|
|
|
$Tag = ClassRegistry::getObject('Tag');
|
|
|
|
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
|
2007-07-09 19:26:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|