cakephp2-php8/cake/tests/cases/libs/model/model_behavior.test.php
Mark Story 4f67f84ff8 Merge branch '1.2' into 1.3-merger
Conflicts:
	app/config/acl.ini.php
	app/config/bootstrap.php
	app/config/core.php
	app/config/database.php.default
	app/config/inflections.php
	app/config/routes.php
	app/config/schema/db_acl.php
	app/config/schema/i18n.php
	app/config/schema/sessions.php
	app/config/sql/db_acl.sql
	app/config/sql/i18n.sql
	app/index.php
	app/webroot/css.php
	app/webroot/css/cake.generic.css
	app/webroot/index.php
	app/webroot/js/vendors.php
	app/webroot/test.php
	cake/LICENSE.txt
	cake/basics.php
	cake/bootstrap.php
	cake/config/config.php
	cake/config/paths.php
	cake/config/unicode/casefolding/0080_00ff.php
	cake/config/unicode/casefolding/0100_017f.php
	cake/config/unicode/casefolding/0180_024F.php
	cake/config/unicode/casefolding/0250_02af.php
	cake/config/unicode/casefolding/0370_03ff.php
	cake/config/unicode/casefolding/0400_04ff.php
	cake/config/unicode/casefolding/0500_052f.php
	cake/config/unicode/casefolding/0530_058f.php
	cake/config/unicode/casefolding/1e00_1eff.php
	cake/config/unicode/casefolding/1f00_1fff.php
	cake/config/unicode/casefolding/2100_214f.php
	cake/config/unicode/casefolding/2150_218f.php
	cake/config/unicode/casefolding/2460_24ff.php
	cake/config/unicode/casefolding/2c00_2c5f.php
	cake/config/unicode/casefolding/2c60_2c7f.php
	cake/config/unicode/casefolding/2c80_2cff.php
	cake/config/unicode/casefolding/ff00_ffef.php
	cake/console/cake
	cake/console/cake.bat
	cake/console/cake.php
	cake/console/error.php
	cake/console/libs/acl.php
	cake/console/libs/api.php
	cake/console/libs/bake.php
	cake/console/libs/console.php
	cake/console/libs/i18n.php
	cake/console/libs/schema.php
	cake/console/libs/shell.php
	cake/console/libs/tasks/controller.php
	cake/console/libs/tasks/db_config.php
	cake/console/libs/tasks/extract.php
	cake/console/libs/tasks/model.php
	cake/console/libs/tasks/plugin.php
	cake/console/libs/tasks/project.php
	cake/console/libs/tasks/test.php
	cake/console/libs/tasks/view.php
	cake/console/libs/templates/skel/config/bootstrap.php
	cake/console/libs/templates/skel/config/inflections.php
	cake/console/libs/templates/skel/config/sql/sessions.sql
	cake/console/libs/templates/skel/index.php
	cake/console/libs/templates/skel/views/elements/email/html/default.ctp
	cake/console/libs/templates/skel/views/elements/email/text/default.ctp
	cake/console/libs/templates/skel/views/layouts/ajax.ctp
	cake/console/libs/templates/skel/views/layouts/default.ctp
	cake/console/libs/templates/skel/views/layouts/email/html/default.ctp
	cake/console/libs/templates/skel/views/layouts/email/text/default.ctp
	cake/console/libs/templates/skel/webroot/js/vendors.php
	cake/console/libs/templates/skel/webroot/test.php
	cake/console/libs/templates/views/form.ctp
	cake/console/libs/templates/views/index.ctp
	cake/console/libs/testsuite.php
	cake/console/templates/default/views/view.ctp
	cake/console/templates/skel/app_controller.php
	cake/console/templates/skel/app_helper.php
	cake/console/templates/skel/app_model.php
	cake/console/templates/skel/config/acl.ini.php
	cake/console/templates/skel/config/core.php
	cake/console/templates/skel/config/database.php.default
	cake/console/templates/skel/config/routes.php
	cake/console/templates/skel/config/schema/db_acl.php
	cake/console/templates/skel/config/schema/db_acl.sql
	cake/console/templates/skel/config/schema/i18n.php
	cake/console/templates/skel/config/schema/i18n.sql
	cake/console/templates/skel/config/schema/sessions.php
	cake/console/templates/skel/config/schema/sessions.sql
	cake/console/templates/skel/controllers/pages_controller.php
	cake/console/templates/skel/views/layouts/flash.ctp
	cake/console/templates/skel/webroot/css.php
	cake/console/templates/skel/webroot/css/cake.generic.css
	cake/console/templates/skel/webroot/index.php
	cake/dispatcher.php
	cake/libs/cache.php
	cake/libs/cache/apc.php
	cake/libs/cache/file.php
	cake/libs/cache/memcache.php
	cake/libs/cache/xcache.php
	cake/libs/cake_log.php
	cake/libs/cake_session.php
	cake/libs/cake_socket.php
	cake/libs/class_registry.php
	cake/libs/configure.php
	cake/libs/controller/app_controller.php
	cake/libs/controller/component.php
	cake/libs/controller/components/acl.php
	cake/libs/controller/components/auth.php
	cake/libs/controller/components/cookie.php
	cake/libs/controller/components/email.php
	cake/libs/controller/components/request_handler.php
	cake/libs/controller/components/security.php
	cake/libs/controller/components/session.php
	cake/libs/controller/controller.php
	cake/libs/controller/pages_controller.php
	cake/libs/controller/scaffold.php
	cake/libs/debugger.php
	cake/libs/error.php
	cake/libs/file.php
	cake/libs/flay.php
	cake/libs/folder.php
	cake/libs/http_socket.php
	cake/libs/i18n.php
	cake/libs/inflector.php
	cake/libs/l10n.php
	cake/libs/magic_db.php
	cake/libs/model/app_model.php
	cake/libs/model/behaviors/acl.php
	cake/libs/model/behaviors/containable.php
	cake/libs/model/behaviors/translate.php
	cake/libs/model/behaviors/tree.php
	cake/libs/model/cake_schema.php
	cake/libs/model/connection_manager.php
	cake/libs/model/datasources/datasource.php
	cake/libs/model/datasources/dbo/dbo_adodb.php
	cake/libs/model/datasources/dbo/dbo_db2.php
	cake/libs/model/datasources/dbo/dbo_firebird.php
	cake/libs/model/datasources/dbo/dbo_mssql.php
	cake/libs/model/datasources/dbo/dbo_mysql.php
	cake/libs/model/datasources/dbo/dbo_mysqli.php
	cake/libs/model/datasources/dbo/dbo_odbc.php
	cake/libs/model/datasources/dbo/dbo_oracle.php
	cake/libs/model/datasources/dbo/dbo_postgres.php
	cake/libs/model/datasources/dbo/dbo_sqlite.php
	cake/libs/model/datasources/dbo/dbo_sybase.php
	cake/libs/model/datasources/dbo_source.php
	cake/libs/model/db_acl.php
	cake/libs/model/model.php
	cake/libs/model/model_behavior.php
	cake/libs/multibyte.php
	cake/libs/object.php
	cake/libs/overloadable.php
	cake/libs/overloadable_php4.php
	cake/libs/overloadable_php5.php
	cake/libs/router.php
	cake/libs/sanitize.php
	cake/libs/security.php
	cake/libs/set.php
	cake/libs/string.php
	cake/libs/validation.php
	cake/libs/view/elements/dump.ctp
	cake/libs/view/elements/email/html/default.ctp
	cake/libs/view/elements/email/text/default.ctp
	cake/libs/view/errors/error404.ctp
	cake/libs/view/errors/missing_action.ctp
	cake/libs/view/errors/missing_component_class.ctp
	cake/libs/view/errors/missing_component_file.ctp
	cake/libs/view/errors/missing_connection.ctp
	cake/libs/view/errors/missing_controller.ctp
	cake/libs/view/errors/missing_helper_class.ctp
	cake/libs/view/errors/missing_helper_file.ctp
	cake/libs/view/errors/missing_layout.ctp
	cake/libs/view/errors/missing_model.ctp
	cake/libs/view/errors/missing_scaffolddb.ctp
	cake/libs/view/errors/missing_table.ctp
	cake/libs/view/errors/missing_view.ctp
	cake/libs/view/errors/private_action.ctp
	cake/libs/view/errors/scaffold_error.ctp
	cake/libs/view/helper.php
	cake/libs/view/helpers/ajax.php
	cake/libs/view/helpers/app_helper.php
	cake/libs/view/helpers/cache.php
	cake/libs/view/helpers/form.php
	cake/libs/view/helpers/html.php
	cake/libs/view/helpers/javascript.php
	cake/libs/view/helpers/js.php
	cake/libs/view/helpers/number.php
	cake/libs/view/helpers/paginator.php
	cake/libs/view/helpers/rss.php
	cake/libs/view/helpers/session.php
	cake/libs/view/helpers/text.php
	cake/libs/view/helpers/time.php
	cake/libs/view/helpers/xml.php
	cake/libs/view/layouts/ajax.ctp
	cake/libs/view/layouts/default.ctp
	cake/libs/view/layouts/email/html/default.ctp
	cake/libs/view/layouts/email/text/default.ctp
	cake/libs/view/layouts/flash.ctp
	cake/libs/view/media.php
	cake/libs/view/pages/home.ctp
	cake/libs/view/scaffolds/edit.ctp
	cake/libs/view/scaffolds/index.ctp
	cake/libs/view/scaffolds/view.ctp
	cake/libs/view/theme.php
	cake/libs/view/view.php
	cake/libs/xml.php
	cake/tests/cases/basics.test.php
	cake/tests/cases/console/cake.test.php
	cake/tests/cases/console/libs/acl.test.php
	cake/tests/cases/console/libs/api.test.php
	cake/tests/cases/console/libs/schema.test.php
	cake/tests/cases/console/libs/shell.test.php
	cake/tests/cases/console/libs/tasks/extract.test.php
	cake/tests/cases/console/libs/tasks/model.test.php
	cake/tests/cases/console/libs/tasks/test.test.php
	cake/tests/cases/dispatcher.test.php
	cake/tests/cases/libs/cache.test.php
	cake/tests/cases/libs/cache/apc.test.php
	cake/tests/cases/libs/cache/file.test.php
	cake/tests/cases/libs/cache/memcache.test.php
	cake/tests/cases/libs/cache/xcache.test.php
	cake/tests/cases/libs/cake_log.test.php
	cake/tests/cases/libs/cake_session.test.php
	cake/tests/cases/libs/cake_socket.test.php
	cake/tests/cases/libs/cake_test_case.test.php
	cake/tests/cases/libs/cake_test_fixture.test.php
	cake/tests/cases/libs/class_registry.test.php
	cake/tests/cases/libs/code_coverage_manager.test.php
	cake/tests/cases/libs/configure.test.php
	cake/tests/cases/libs/controller/component.test.php
	cake/tests/cases/libs/controller/components/acl.test.php
	cake/tests/cases/libs/controller/components/auth.test.php
	cake/tests/cases/libs/controller/components/cookie.test.php
	cake/tests/cases/libs/controller/components/email.test.php
	cake/tests/cases/libs/controller/components/request_handler.test.php
	cake/tests/cases/libs/controller/components/security.test.php
	cake/tests/cases/libs/controller/components/session.test.php
	cake/tests/cases/libs/controller/controller.test.php
	cake/tests/cases/libs/controller/controller_merge_vars.test.php
	cake/tests/cases/libs/controller/pages_controller.test.php
	cake/tests/cases/libs/controller/scaffold.test.php
	cake/tests/cases/libs/debugger.test.php
	cake/tests/cases/libs/error.test.php
	cake/tests/cases/libs/file.test.php
	cake/tests/cases/libs/flay.test.php
	cake/tests/cases/libs/folder.test.php
	cake/tests/cases/libs/http_socket.test.php
	cake/tests/cases/libs/i18n.test.php
	cake/tests/cases/libs/inflector.test.php
	cake/tests/cases/libs/l10n.test.php
	cake/tests/cases/libs/magic_db.test.php
	cake/tests/cases/libs/model/behaviors/acl.test.php
	cake/tests/cases/libs/model/behaviors/containable.test.php
	cake/tests/cases/libs/model/behaviors/translate.test.php
	cake/tests/cases/libs/model/behaviors/tree.test.php
	cake/tests/cases/libs/model/cake_schema.test.php
	cake/tests/cases/libs/model/connection_manager.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_adodb.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
	cake/tests/cases/libs/model/datasources/dbo_source.test.php
	cake/tests/cases/libs/model/db_acl.test.php
	cake/tests/cases/libs/model/model.test.php
	cake/tests/cases/libs/model/model_behavior.test.php
	cake/tests/cases/libs/model/model_delete.test.php
	cake/tests/cases/libs/model/model_integration.test.php
	cake/tests/cases/libs/model/model_read.test.php
	cake/tests/cases/libs/model/model_validation.test.php
	cake/tests/cases/libs/model/model_write.test.php
	cake/tests/cases/libs/model/models.php
	cake/tests/cases/libs/multibyte.test.php
	cake/tests/cases/libs/object.test.php
	cake/tests/cases/libs/overloadable.test.php
	cake/tests/cases/libs/router.test.php
	cake/tests/cases/libs/sanitize.test.php
	cake/tests/cases/libs/security.test.php
	cake/tests/cases/libs/set.test.php
	cake/tests/cases/libs/string.test.php
	cake/tests/cases/libs/test_manager.test.php
	cake/tests/cases/libs/validation.test.php
	cake/tests/cases/libs/view/helper.test.php
	cake/tests/cases/libs/view/helpers/ajax.test.php
	cake/tests/cases/libs/view/helpers/cache.test.php
	cake/tests/cases/libs/view/helpers/form.test.php
	cake/tests/cases/libs/view/helpers/html.test.php
	cake/tests/cases/libs/view/helpers/javascript.test.php
	cake/tests/cases/libs/view/helpers/js.test.php
	cake/tests/cases/libs/view/helpers/number.test.php
	cake/tests/cases/libs/view/helpers/paginator.test.php
	cake/tests/cases/libs/view/helpers/rss.test.php
	cake/tests/cases/libs/view/helpers/session.test.php
	cake/tests/cases/libs/view/helpers/text.test.php
	cake/tests/cases/libs/view/helpers/time.test.php
	cake/tests/cases/libs/view/helpers/xml.test.php
	cake/tests/cases/libs/view/theme.test.php
	cake/tests/cases/libs/view/view.test.php
	cake/tests/cases/libs/xml.test.php
	cake/tests/fixtures/account_fixture.php
	cake/tests/fixtures/aco_action_fixture.php
	cake/tests/fixtures/aco_fixture.php
	cake/tests/fixtures/aco_two_fixture.php
	cake/tests/fixtures/advertisement_fixture.php
	cake/tests/fixtures/another_article_fixture.php
	cake/tests/fixtures/apple_fixture.php
	cake/tests/fixtures/aro_fixture.php
	cake/tests/fixtures/aro_two_fixture.php
	cake/tests/fixtures/aros_aco_fixture.php
	cake/tests/fixtures/aros_aco_two_fixture.php
	cake/tests/fixtures/article_featured_fixture.php
	cake/tests/fixtures/article_featureds_tags_fixture.php
	cake/tests/fixtures/article_fixture.php
	cake/tests/fixtures/articles_tag_fixture.php
	cake/tests/fixtures/attachment_fixture.php
	cake/tests/fixtures/auth_user_custom_field_fixture.php
	cake/tests/fixtures/auth_user_fixture.php
	cake/tests/fixtures/author_fixture.php
	cake/tests/fixtures/basket_fixture.php
	cake/tests/fixtures/bid_fixture.php
	cake/tests/fixtures/binary_test_fixture.php
	cake/tests/fixtures/book_fixture.php
	cake/tests/fixtures/cache_test_model_fixture.php
	cake/tests/fixtures/callback_fixture.php
	cake/tests/fixtures/category_fixture.php
	cake/tests/fixtures/category_thread_fixture.php
	cake/tests/fixtures/cd_fixture.php
	cake/tests/fixtures/comment_fixture.php
	cake/tests/fixtures/content_account_fixture.php
	cake/tests/fixtures/content_fixture.php
	cake/tests/fixtures/counter_cache_post_fixture.php
	cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php
	cake/tests/fixtures/counter_cache_user_fixture.php
	cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php
	cake/tests/fixtures/data_test_fixture.php
	cake/tests/fixtures/datatype_fixture.php
	cake/tests/fixtures/dependency_fixture.php
	cake/tests/fixtures/device_fixture.php
	cake/tests/fixtures/device_type_category_fixture.php
	cake/tests/fixtures/device_type_fixture.php
	cake/tests/fixtures/document_directory_fixture.php
	cake/tests/fixtures/document_fixture.php
	cake/tests/fixtures/exterior_type_category_fixture.php
	cake/tests/fixtures/feature_set_fixture.php
	cake/tests/fixtures/featured_fixture.php
	cake/tests/fixtures/film_file_fixture.php
	cake/tests/fixtures/flag_tree_fixture.php
	cake/tests/fixtures/fruit_fixture.php
	cake/tests/fixtures/fruits_uuid_tag_fixture.php
	cake/tests/fixtures/home_fixture.php
	cake/tests/fixtures/image_fixture.php
	cake/tests/fixtures/item_fixture.php
	cake/tests/fixtures/items_portfolio_fixture.php
	cake/tests/fixtures/join_a_b_fixture.php
	cake/tests/fixtures/join_a_c_fixture.php
	cake/tests/fixtures/join_a_fixture.php
	cake/tests/fixtures/join_b_fixture.php
	cake/tests/fixtures/join_c_fixture.php
	cake/tests/fixtures/join_thing_fixture.php
	cake/tests/fixtures/message_fixture.php
	cake/tests/fixtures/my_categories_my_products_fixture.php
	cake/tests/fixtures/my_categories_my_users_fixture.php
	cake/tests/fixtures/my_category_fixture.php
	cake/tests/fixtures/my_product_fixture.php
	cake/tests/fixtures/my_user_fixture.php
	cake/tests/fixtures/node_fixture.php
	cake/tests/fixtures/number_tree_fixture.php
	cake/tests/fixtures/number_tree_two_fixture.php
	cake/tests/fixtures/numeric_article_fixture.php
	cake/tests/fixtures/overall_favorite_fixture.php
	cake/tests/fixtures/person_fixture.php
	cake/tests/fixtures/portfolio_fixture.php
	cake/tests/fixtures/post_fixture.php
	cake/tests/fixtures/posts_tag_fixture.php
	cake/tests/fixtures/primary_model_fixture.php
	cake/tests/fixtures/product_fixture.php
	cake/tests/fixtures/project_fixture.php
	cake/tests/fixtures/sample_fixture.php
	cake/tests/fixtures/secondary_model_fixture.php
	cake/tests/fixtures/session_fixture.php
	cake/tests/fixtures/something_else_fixture.php
	cake/tests/fixtures/something_fixture.php
	cake/tests/fixtures/stories_tag_fixture.php
	cake/tests/fixtures/story_fixture.php
	cake/tests/fixtures/syfile_fixture.php
	cake/tests/fixtures/tag_fixture.php
	cake/tests/fixtures/test_plugin_article_fixture.php
	cake/tests/fixtures/test_plugin_comment_fixture.php
	cake/tests/fixtures/the_paper_monkies_fixture.php
	cake/tests/fixtures/thread_fixture.php
	cake/tests/fixtures/translate_article_fixture.php
	cake/tests/fixtures/translate_fixture.php
	cake/tests/fixtures/translate_table_fixture.php
	cake/tests/fixtures/translated_article_fixture.php
	cake/tests/fixtures/translated_item_fixture.php
	cake/tests/fixtures/unconventional_tree_fixture.php
	cake/tests/fixtures/underscore_field_fixture.php
	cake/tests/fixtures/user_fixture.php
	cake/tests/fixtures/uuid_fixture.php
	cake/tests/fixtures/uuid_tag_fixture.php
	cake/tests/fixtures/uuid_tree_fixture.php
	cake/tests/fixtures/uuiditem_fixture.php
	cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php
	cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php
	cake/tests/fixtures/uuidportfolio_fixture.php
	cake/tests/groups/acl.group.php
	cake/tests/groups/cache.group.php
	cake/tests/groups/components.group.php
	cake/tests/groups/configure.group.php
	cake/tests/groups/console.group.php
	cake/tests/groups/controller.group.php
	cake/tests/groups/database.group.php
	cake/tests/groups/helpers.group.php
	cake/tests/groups/lib.group.php
	cake/tests/groups/model.group.php
	cake/tests/groups/no_cross_contamination.group.php
	cake/tests/groups/routing_system.group.php
	cake/tests/groups/socket.group.php
	cake/tests/groups/test_suite.group.php
	cake/tests/groups/view.group.php
	cake/tests/groups/xml.group.php
	cake/tests/lib/cake_reporter.php
	cake/tests/lib/cake_test_case.php
	cake/tests/lib/cake_test_fixture.php
	cake/tests/lib/cake_test_model.php
	cake/tests/lib/cake_web_test_case.php
	cake/tests/lib/cli_reporter.php
	cake/tests/lib/code_coverage_manager.php
	cake/tests/lib/templates/footer.php
	cake/tests/lib/templates/header.php
	cake/tests/lib/templates/menu.php
	cake/tests/lib/templates/simpletest.php
	cake/tests/lib/test_manager.php
	cake/tests/lib/xdebug.php
	cake/tests/test_app/config/acl.ini.php
	cake/tests/test_app/controllers/tests_apps_controller.php
	cake/tests/test_app/controllers/tests_apps_posts_controller.php
	cake/tests/test_app/models/behaviors/persister_one_behavior.php
	cake/tests/test_app/models/behaviors/persister_two_behavior.php
	cake/tests/test_app/models/comment.php
	cake/tests/test_app/models/persister_one.php
	cake/tests/test_app/models/persister_two.php
	cake/tests/test_app/models/post.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php
	cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php
	cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php
	cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php
	cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php
	cake/tests/test_app/plugins/test_plugin/vendors/shells/example.php
	cake/tests/test_app/plugins/test_plugin/vendors/welcome.php
	cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php
	cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php
	cake/tests/test_app/plugins/test_plugin_two/vendors/shells/example.php
	cake/tests/test_app/plugins/test_plugin_two/vendors/shells/welcome.php
	cake/tests/test_app/vendors/Test/MyTest.php
	cake/tests/test_app/vendors/Test/hello.php
	cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php
	cake/tests/test_app/vendors/shells/sample.php
	cake/tests/test_app/vendors/somename/some.name.php
	cake/tests/test_app/vendors/welcome.php
	cake/tests/test_app/views/elements/email/html/default.ctp
	cake/tests/test_app/views/elements/email/text/default.ctp
	cake/tests/test_app/views/elements/email/text/wide.ctp
	cake/tests/test_app/views/layouts/ajax.ctp
	cake/tests/test_app/views/layouts/ajax2.ctp
	cake/tests/test_app/views/layouts/cache_layout.ctp
	cake/tests/test_app/views/layouts/default.ctp
	cake/tests/test_app/views/layouts/email/html/default.ctp
	cake/tests/test_app/views/layouts/email/html/thin.ctp
	cake/tests/test_app/views/layouts/email/text/default.ctp
	cake/tests/test_app/views/layouts/flash.ctp
	cake/tests/test_app/views/layouts/multi_cache.ctp
	cake/tests/test_app/views/posts/sequencial_nocache.ctp
	cake/tests/test_app/views/posts/test_nocache_tags.ctp
	index.php
2010-01-26 17:54:34 -05:00

1117 lines
No EOL
38 KiB
PHP

<?php
/**
* BehaviorTest file
*
* Long description for behavior.test.php
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake
* @subpackage cake.tests.cases.libs.model
* @since 1.2
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Model', 'AppModel');
require_once dirname(__FILE__) . DS . 'models.php';
Mock::generatePartial('BehaviorCollection', 'MockModelBehaviorCollection', array('cakeError', '_stop'));
/**
* TestBehavior class
*
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TestBehavior extends ModelBehavior {
/**
* mapMethods property
*
* @var array
* @access public
*/
var $mapMethods = array('/test(\w+)/' => 'testMethod', '/look for\s+(.+)/' => 'speakEnglish');
/**
* setup method
*
* @param mixed $model
* @param array $config
* @access public
* @return void
*/
function setup(&$model, $config = array()) {
parent::setup($model, $config);
if (isset($config['mangle'])) {
$config['mangle'] .= ' mangled';
}
$this->settings[$model->alias] = array_merge(array('beforeFind' => 'on', 'afterFind' => 'off'), $config);
}
/**
* beforeFind method
*
* @param mixed $model
* @param mixed $query
* @access public
* @return void
*/
function beforeFind(&$model, $query) {
$settings = $this->settings[$model->alias];
if (!isset($settings['beforeFind']) || $settings['beforeFind'] == 'off') {
return parent::beforeFind($model, $query);
}
switch ($settings['beforeFind']) {
case 'on':
return false;
break;
case 'test':
return null;
break;
case 'modify':
$query['fields'] = array($model->alias . '.id', $model->alias . '.name', $model->alias . '.mytime');
$query['recursive'] = -1;
return $query;
break;
}
}
/**
* afterFind method
*
* @param mixed $model
* @param mixed $results
* @param mixed $primary
* @access public
* @return void
*/
function afterFind(&$model, $results, $primary) {
$settings = $this->settings[$model->alias];
if (!isset($settings['afterFind']) || $settings['afterFind'] == 'off') {
return parent::afterFind($model, $results, $primary);
}
switch ($settings['afterFind']) {
case 'on':
return array();
break;
case 'test':
return true;
break;
case 'test2':
return null;
break;
case 'modify':
return Set::extract($results, "{n}.{$model->alias}");
break;
}
}
/**
* beforeSave method
*
* @param mixed $model
* @access public
* @return void
*/
function beforeSave(&$model) {
$settings = $this->settings[$model->alias];
if (!isset($settings['beforeSave']) || $settings['beforeSave'] == 'off') {
return parent::beforeSave($model);
}
switch ($settings['beforeSave']) {
case 'on':
return false;
break;
case 'test':
return null;
break;
case 'modify':
$model->data[$model->alias]['name'] .= ' modified before';
return true;
break;
}
}
/**
* afterSave method
*
* @param mixed $model
* @param mixed $created
* @access public
* @return void
*/
function afterSave(&$model, $created) {
$settings = $this->settings[$model->alias];
if (!isset($settings['afterSave']) || $settings['afterSave'] == 'off') {
return parent::afterSave($model, $created);
}
$string = 'modified after';
if ($created) {
$string .= ' on create';
}
switch ($settings['afterSave']) {
case 'on':
$model->data[$model->alias]['aftersave'] = $string;
break;
case 'test':
unset($model->data[$model->alias]['name']);
break;
case 'test2':
return false;
break;
case 'modify':
$model->data[$model->alias]['name'] .= ' ' . $string;
break;
}
}
/**
* beforeValidate method
*
* @param mixed $model
* @access public
* @return void
*/
function beforeValidate(&$model) {
$settings = $this->settings[$model->alias];
if (!isset($settings['validate']) || $settings['validate'] == 'off') {
return parent::beforeValidate($model);
}
switch ($settings['validate']) {
case 'on':
$model->invalidate('name');
return true;
break;
case 'test':
return null;
break;
case 'whitelist':
$this->_addToWhitelist($model, array('name'));
return true;
break;
case 'stop':
$model->invalidate('name');
return false;
break;
}
}
/**
* beforeDelete method
*
* @param mixed $model
* @param bool $cascade
* @access public
* @return void
*/
function beforeDelete(&$model, $cascade = true) {
$settings =& $this->settings[$model->alias];
if (!isset($settings['beforeDelete']) || $settings['beforeDelete'] == 'off') {
return parent::beforeDelete($model, $cascade);
}
switch ($settings['beforeDelete']) {
case 'on':
return false;
break;
case 'test':
return null;
break;
case 'test2':
echo 'beforeDelete success';
if ($cascade) {
echo ' (cascading) ';
}
break;
}
}
/**
* afterDelete method
*
* @param mixed $model
* @access public
* @return void
*/
function afterDelete(&$model) {
$settings =& $this->settings[$model->alias];
if (!isset($settings['afterDelete']) || $settings['afterDelete'] == 'off') {
return parent::afterDelete($model);
}
switch ($settings['afterDelete']) {
case 'on':
echo 'afterDelete success';
break;
}
}
/**
* onError method
*
* @param mixed $model
* @access public
* @return void
*/
function onError(&$model) {
$settings = $this->settings[$model->alias];
if (!isset($settings['onError']) || $settings['onError'] == 'off') {
return parent::onError($model, $cascade);
}
echo "onError trigger success";
}
/**
* beforeTest method
*
* @param mixed $model
* @access public
* @return void
*/
function beforeTest(&$model) {
$model->beforeTestResult[] = strtolower(get_class($this));
return strtolower(get_class($this));
}
/**
* testMethod method
*
* @param mixed $model
* @param bool $param
* @access public
* @return void
*/
function testMethod(&$model, $param = true) {
if ($param === true) {
return 'working';
}
}
/**
* testData method
*
* @param mixed $model
* @access public
* @return void
*/
function testData(&$model) {
if (!isset($model->data['Apple']['field'])) {
return false;
}
$model->data['Apple']['field_2'] = true;
return true;
}
/**
* validateField method
*
* @param mixed $model
* @param mixed $field
* @access public
* @return void
*/
function validateField(&$model, $field) {
return current($field) === 'Orange';
}
/**
* speakEnglish method
*
* @param mixed $model
* @param mixed $method
* @param mixed $query
* @access public
* @return void
*/
function speakEnglish(&$model, $method, $query) {
$method = preg_replace('/look for\s+/', 'Item.name = \'', $method);
$query = preg_replace('/^in\s+/', 'Location.name = \'', $query);
return $method . '\' AND ' . $query . '\'';
}
}
/**
* Test2Behavior class
*
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Test2Behavior extends TestBehavior{
}
/**
* Test3Behavior class
*
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Test3Behavior extends TestBehavior{
}
/**
* Test4Behavior class
*
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Test4Behavior extends ModelBehavior{
function setup(&$model, $config = null) {
$model->bindModel(
array('hasMany' => array('Comment'))
);
}
}
/**
* Test5Behavior class
*
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Test5Behavior extends ModelBehavior{
function setup(&$model, $config = null) {
$model->bindModel(
array('belongsTo' => array('User'))
);
}
}
/**
* Test6Behavior class
*
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Test6Behavior extends ModelBehavior{
function setup(&$model, $config = null) {
$model->bindModel(
array('hasAndBelongsToMany' => array('Tag'))
);
}
}
/**
* Test7Behavior class
*
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Test7Behavior extends ModelBehavior{
function setup(&$model, $config = null) {
$model->bindModel(
array('hasOne' => array('Attachment'))
);
}
}
/**
* BehaviorTest class
*
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class BehaviorTest extends CakeTestCase {
/**
* fixtures property
*
* @var array
* @access public
*/
var $fixtures = array(
'core.apple', 'core.sample', 'core.article', 'core.user', 'core.comment',
'core.attachment', 'core.tag', 'core.articles_tag'
);
/**
* tearDown method
*
* @access public
* @return void
*/
function endTest() {
ClassRegistry::flush();
}
/**
* testBehaviorBinding method
*
* @access public
* @return void
*/
function testBehaviorBinding() {
$Apple = new Apple();
$this->assertIdentical($Apple->Behaviors->attached(), array());
$Apple->Behaviors->attach('Test', array('key' => 'value'));
$this->assertIdentical($Apple->Behaviors->attached(), array('Test'));
$this->assertEqual(strtolower(get_class($Apple->Behaviors->Test)), 'testbehavior');
$expected = array('beforeFind' => 'on', 'afterFind' => 'off', 'key' => 'value');
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], $expected);
$this->assertEqual(array_keys($Apple->Behaviors->Test->settings), array('Apple'));
$this->assertIdentical($Apple->Sample->Behaviors->attached(), array());
$Apple->Sample->Behaviors->attach('Test', array('key2' => 'value2'));
$this->assertIdentical($Apple->Sample->Behaviors->attached(), array('Test'));
$this->assertEqual($Apple->Sample->Behaviors->Test->settings['Sample'], array('beforeFind' => 'on', 'afterFind' => 'off', 'key2' => 'value2'));
$this->assertEqual(array_keys($Apple->Behaviors->Test->settings), array('Apple', 'Sample'));
$this->assertIdentical(
$Apple->Sample->Behaviors->Test->settings,
$Apple->Behaviors->Test->settings
);
$this->assertNotIdentical($Apple->Behaviors->Test->settings['Apple'], $Apple->Sample->Behaviors->Test->settings['Sample']);
$Apple->Behaviors->attach('Test', array('key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off'));
$Apple->Sample->Behaviors->attach('Test', array('key' => 'value', 'key3' => 'value3', 'beforeFind' => 'off'));
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], array('beforeFind' => 'off', 'afterFind' => 'off', 'key' => 'value', 'key2' => 'value2', 'key3' => 'value3'));
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], $Apple->Sample->Behaviors->Test->settings['Sample']);
$this->assertFalse(isset($Apple->Child->Behaviors->Test));
$Apple->Child->Behaviors->attach('Test', array('key' => 'value', 'key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off'));
$this->assertEqual($Apple->Child->Behaviors->Test->settings['Child'], $Apple->Sample->Behaviors->Test->settings['Sample']);
$this->assertFalse(isset($Apple->Parent->Behaviors->Test));
$Apple->Parent->Behaviors->attach('Test', array('key' => 'value', 'key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off'));
$this->assertEqual($Apple->Parent->Behaviors->Test->settings['Parent'], $Apple->Sample->Behaviors->Test->settings['Sample']);
$Apple->Parent->Behaviors->attach('Test', array('key' => 'value', 'key2' => 'value', 'key3' => 'value', 'beforeFind' => 'off'));
$this->assertNotEqual($Apple->Parent->Behaviors->Test->settings['Parent'], $Apple->Sample->Behaviors->Test->settings['Sample']);
$Apple->Behaviors->attach('Plugin.Test', array('key' => 'new value'));
$expected = array(
'beforeFind' => 'off', 'afterFind' => 'off', 'key' => 'new value',
'key2' => 'value2', 'key3' => 'value3'
);
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], $expected);
$current = $Apple->Behaviors->Test->settings['Apple'];
$expected = array_merge($current, array('mangle' => 'trigger mangled'));
$Apple->Behaviors->attach('Test', array('mangle' => 'trigger'));
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], $expected);
$Apple->Behaviors->attach('Test');
$expected = array_merge($current, array('mangle' => 'trigger mangled mangled'));
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], $expected);
$Apple->Behaviors->attach('Test', array('mangle' => 'trigger'));
$expected = array_merge($current, array('mangle' => 'trigger mangled'));
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], $expected);
}
/**
* test that attaching a non existant Behavior triggers a cake error.
*
* @return void
*/
function testInvalidBehaviorCausingCakeError() {
$Apple =& new Apple();
$Apple->Behaviors =& new MockModelBehaviorCollection();
$Apple->Behaviors->expectOnce('cakeError');
$Apple->Behaviors->expectAt(0, 'cakeError', array('missingBehaviorFile', '*'));
$this->assertFalse($Apple->Behaviors->attach('NoSuchBehavior'));
}
/**
* testBehaviorToggling method
*
* @access public
* @return void
*/
function testBehaviorToggling() {
$Apple = new Apple();
$this->assertIdentical($Apple->Behaviors->enabled(), array());
$Apple->Behaviors->init('Apple', array('Test' => array('key' => 'value')));
$this->assertIdentical($Apple->Behaviors->enabled(), array('Test'));
$Apple->Behaviors->disable('Test');
$this->assertIdentical($Apple->Behaviors->attached(), array('Test'));
$this->assertIdentical($Apple->Behaviors->enabled(), array());
$Apple->Sample->Behaviors->attach('Test');
$this->assertIdentical($Apple->Sample->Behaviors->enabled('Test'), true);
$this->assertIdentical($Apple->Behaviors->enabled(), array());
$Apple->Behaviors->enable('Test');
$this->assertIdentical($Apple->Behaviors->attached('Test'), true);
$this->assertIdentical($Apple->Behaviors->enabled(), array('Test'));
$Apple->Behaviors->disable('Test');
$this->assertIdentical($Apple->Behaviors->enabled(), array());
$Apple->Behaviors->attach('Test', array('enabled' => true));
$this->assertIdentical($Apple->Behaviors->enabled(), array('Test'));
$Apple->Behaviors->attach('Test', array('enabled' => false));
$this->assertIdentical($Apple->Behaviors->enabled(), array());
$Apple->Behaviors->detach('Test');
$this->assertIdentical($Apple->Behaviors->enabled(), array());
}
/**
* testBehaviorFindCallbacks method
*
* @access public
* @return void
*/
function testBehaviorFindCallbacks() {
$Apple = new Apple();
$expected = $Apple->find('all');
$Apple->Behaviors->attach('Test');
$this->assertIdentical($Apple->find('all'), null);
$Apple->Behaviors->attach('Test', array('beforeFind' => 'off'));
$this->assertIdentical($Apple->find('all'), $expected);
$Apple->Behaviors->attach('Test', array('beforeFind' => 'test'));
$this->assertIdentical($Apple->find('all'), $expected);
$Apple->Behaviors->attach('Test', array('beforeFind' => 'modify'));
$expected2 = array(
array('Apple' => array('id' => '1', 'name' => 'Red Apple 1', 'mytime' => '22:57:17')),
array('Apple' => array('id' => '2', 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')),
array('Apple' => array('id' => '3', 'name' => 'green blue', 'mytime' => '22:57:17'))
);
$result = $Apple->find('all', array('conditions' => array('Apple.id <' => '4')));
$this->assertEqual($result, $expected2);
$Apple->Behaviors->disable('Test');
$result = $Apple->find('all');
$this->assertEqual($result, $expected);
$Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'afterFind' => 'on'));
$this->assertIdentical($Apple->find('all'), array());
$Apple->Behaviors->attach('Test', array('afterFind' => 'off'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Behaviors->attach('Test', array('afterFind' => 'test'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Behaviors->attach('Test', array('afterFind' => 'test2'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Behaviors->attach('Test', array('afterFind' => 'modify'));
$expected = array(
array('id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'),
array('id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'),
array('id' => '3', 'apple_id' => '2', 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17'),
array('id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17'),
array('id' => '5', 'apple_id' => '5', 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17'),
array('id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17'),
array('id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17')
);
$this->assertEqual($Apple->find('all'), $expected);
}
/**
* testBehaviorHasManyFindCallbacks method
*
* @access public
* @return void
*/
function testBehaviorHasManyFindCallbacks() {
$Apple = new Apple();
$Apple->unbindModel(array('hasOne' => array('Sample'), 'belongsTo' => array('Parent')), false);
$expected = $Apple->find('all');
$Apple->unbindModel(array('hasMany' => array('Child')));
$wellBehaved = $Apple->find('all');
$Apple->Child->Behaviors->attach('Test', array('afterFind' => 'modify'));
$Apple->unbindModel(array('hasMany' => array('Child')));
$this->assertIdentical($Apple->find('all'), $wellBehaved);
$Apple->Child->Behaviors->attach('Test', array('before' => 'off'));
$this->assertIdentical($Apple->find('all'), $expected);
$Apple->Child->Behaviors->attach('Test', array('before' => 'test'));
$this->assertIdentical($Apple->find('all'), $expected);
$expected2 = array(
array(
'Apple' => array('id' => 1),
'Child' => array(
array('id' => 2,'name' => 'Bright Red Apple', 'mytime' => '22:57:17'))),
array(
'Apple' => array('id' => 2),
'Child' => array(
array('id' => 1, 'name' => 'Red Apple 1', 'mytime' => '22:57:17'),
array('id' => 3, 'name' => 'green blue', 'mytime' => '22:57:17'),
array('id' => 4, 'name' => 'Test Name', 'mytime' => '22:57:17'))),
array(
'Apple' => array('id' => 3),
'Child' => array())
);
$Apple->Child->Behaviors->attach('Test', array('before' => 'modify'));
$result = $Apple->find('all', array('fields' => array('Apple.id'), 'conditions' => array('Apple.id <' => '4')));
//$this->assertEqual($result, $expected2);
$Apple->Child->Behaviors->disable('Test');
$result = $Apple->find('all');
$this->assertEqual($result, $expected);
$Apple->Child->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on'));
//$this->assertIdentical($Apple->find('all'), array());
$Apple->Child->Behaviors->attach('Test', array('after' => 'off'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Child->Behaviors->attach('Test', array('after' => 'test'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Child->Behaviors->attach('Test', array('after' => 'test2'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Child->Behaviors->attach('Test', array('after' => 'modify'));
$expected = array(
array('id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'),
array('id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'),
array('id' => '3', 'apple_id' => '2', 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17'),
array('id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17'),
array('id' => '5', 'apple_id' => '5', 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17'),
array('id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17'),
array('id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17')
);
//$this->assertEqual($Apple->find('all'), $expected);
}
/**
* testBehaviorHasOneFindCallbacks method
*
* @access public
* @return void
*/
function testBehaviorHasOneFindCallbacks() {
$Apple = new Apple();
$Apple->unbindModel(array('hasMany' => array('Child'), 'belongsTo' => array('Parent')), false);
$expected = $Apple->find('all');
$Apple->unbindModel(array('hasOne' => array('Sample')));
$wellBehaved = $Apple->find('all');
$Apple->Sample->Behaviors->attach('Test');
$Apple->unbindModel(array('hasOne' => array('Sample')));
$this->assertIdentical($Apple->find('all'), $wellBehaved);
$Apple->Sample->Behaviors->attach('Test', array('before' => 'off'));
$this->assertIdentical($Apple->find('all'), $expected);
$Apple->Sample->Behaviors->attach('Test', array('before' => 'test'));
$this->assertIdentical($Apple->find('all'), $expected);
$Apple->Sample->Behaviors->attach('Test', array('before' => 'modify'));
$expected2 = array(
array(
'Apple' => array('id' => 1),
'Child' => array(
array('id' => 2,'name' => 'Bright Red Apple', 'mytime' => '22:57:17'))),
array(
'Apple' => array('id' => 2),
'Child' => array(
array('id' => 1, 'name' => 'Red Apple 1', 'mytime' => '22:57:17'),
array('id' => 3, 'name' => 'green blue', 'mytime' => '22:57:17'),
array('id' => 4, 'name' => 'Test Name', 'mytime' => '22:57:17'))),
array(
'Apple' => array('id' => 3),
'Child' => array())
);
$result = $Apple->find('all', array('fields' => array('Apple.id'), 'conditions' => array('Apple.id <' => '4')));
//$this->assertEqual($result, $expected2);
$Apple->Sample->Behaviors->disable('Test');
$result = $Apple->find('all');
$this->assertEqual($result, $expected);
$Apple->Sample->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on'));
//$this->assertIdentical($Apple->find('all'), array());
$Apple->Sample->Behaviors->attach('Test', array('after' => 'off'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Sample->Behaviors->attach('Test', array('after' => 'test'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Sample->Behaviors->attach('Test', array('after' => 'test2'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Sample->Behaviors->attach('Test', array('after' => 'modify'));
$expected = array(
array('id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'),
array('id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'),
array('id' => '3', 'apple_id' => '2', 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17'),
array('id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17'),
array('id' => '5', 'apple_id' => '5', 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17'),
array('id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17'),
array('id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17')
);
//$this->assertEqual($Apple->find('all'), $expected);
}
/**
* testBehaviorBelongsToFindCallbacks method
*
* @access public
* @return void
*/
function testBehaviorBelongsToFindCallbacks() {
$Apple = new Apple();
$Apple->unbindModel(array('hasMany' => array('Child'), 'hasOne' => array('Sample')), false);
$expected = $Apple->find('all');
$Apple->unbindModel(array('belongsTo' => array('Parent')));
$wellBehaved = $Apple->find('all');
$Apple->Parent->Behaviors->attach('Test');
$Apple->unbindModel(array('belongsTo' => array('Parent')));
$this->assertIdentical($Apple->find('all'), $wellBehaved);
$Apple->Parent->Behaviors->attach('Test', array('before' => 'off'));
$this->assertIdentical($Apple->find('all'), $expected);
$Apple->Parent->Behaviors->attach('Test', array('before' => 'test'));
$this->assertIdentical($Apple->find('all'), $expected);
$Apple->Parent->Behaviors->attach('Test', array('before' => 'modify'));
$expected2 = array(
array(
'Apple' => array('id' => 1),
'Parent' => array('id' => 2,'name' => 'Bright Red Apple', 'mytime' => '22:57:17')),
array(
'Apple' => array('id' => 2),
'Parent' => array('id' => 1, 'name' => 'Red Apple 1', 'mytime' => '22:57:17')),
array(
'Apple' => array('id' => 3),
'Parent' => array('id' => 2,'name' => 'Bright Red Apple', 'mytime' => '22:57:17'))
);
$result = $Apple->find('all', array('fields' => array('Apple.id', 'Parent.*'), 'conditions' => array('Apple.id <' => '4')));
//$this->assertEqual($result, $expected2);
$Apple->Parent->Behaviors->disable('Test');
$result = $Apple->find('all');
$this->assertEqual($result, $expected);
$Apple->Parent->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on'));
//$this->assertIdentical($Apple->find('all'), array());
$Apple->Parent->Behaviors->attach('Test', array('after' => 'off'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Parent->Behaviors->attach('Test', array('after' => 'test'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Parent->Behaviors->attach('Test', array('after' => 'test2'));
$this->assertEqual($Apple->find('all'), $expected);
$Apple->Parent->Behaviors->attach('Test', array('after' => 'modify'));
$expected = array(
array('id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'),
array('id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'),
array('id' => '3', 'apple_id' => '2', 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17'),
array('id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17'),
array('id' => '5', 'apple_id' => '5', 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17'),
array('id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17'),
array('id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17')
);
//$this->assertEqual($Apple->find('all'), $expected);
}
/**
* testBehaviorSaveCallbacks method
*
* @access public
* @return void
*/
function testBehaviorSaveCallbacks() {
$Sample = new Sample();
$record = array('Sample' => array('apple_id' => 6, 'name' => 'sample99'));
$Sample->Behaviors->attach('Test', array('beforeSave' => 'on'));
$Sample->create();
$this->assertIdentical($Sample->save($record), false);
$Sample->Behaviors->attach('Test', array('beforeSave' => 'off'));
$Sample->create();
$this->assertIdentical($Sample->save($record), $record);
$Sample->Behaviors->attach('Test', array('beforeSave' => 'test'));
$Sample->create();
$this->assertIdentical($Sample->save($record), $record);
$Sample->Behaviors->attach('Test', array('beforeSave' => 'modify'));
$expected = Set::insert($record, 'Sample.name', 'sample99 modified before');
$Sample->create();
$this->assertIdentical($Sample->save($record), $expected);
$Sample->Behaviors->disable('Test');
$this->assertIdentical($Sample->save($record), $record);
$Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'on'));
$expected = Set::merge($record, array('Sample' => array('aftersave' => 'modified after on create')));
$Sample->create();
$this->assertIdentical($Sample->save($record), $expected);
$Sample->Behaviors->attach('Test', array('beforeSave' => 'modify', 'afterSave' => 'modify'));
$expected = Set::merge($record, array('Sample' => array('name' => 'sample99 modified before modified after on create')));
$Sample->create();
$this->assertIdentical($Sample->save($record), $expected);
$Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'test'));
$Sample->create();
$this->assertIdentical($Sample->save($record), $record);
$Sample->Behaviors->attach('Test', array('afterSave' => 'test2'));
$Sample->create();
$this->assertIdentical($Sample->save($record), $record);
$Sample->Behaviors->attach('Test', array('beforeFind' => 'off', 'afterFind' => 'off'));
$Sample->recursive = -1;
$record2 = $Sample->read(null, 1);
$Sample->Behaviors->attach('Test', array('afterSave' => 'on'));
$expected = Set::merge($record2, array('Sample' => array('aftersave' => 'modified after')));
$Sample->create();
$this->assertIdentical($Sample->save($record2), $expected);
$Sample->Behaviors->attach('Test', array('afterSave' => 'modify'));
$expected = Set::merge($record2, array('Sample' => array('name' => 'sample1 modified after')));
$Sample->create();
$this->assertIdentical($Sample->save($record2), $expected);
}
/**
* testBehaviorDeleteCallbacks method
*
* @access public
* @return void
*/
function testBehaviorDeleteCallbacks() {
$Apple = new Apple();
$Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'beforeDelete' => 'off'));
$this->assertIdentical($Apple->delete(6), true);
$Apple->Behaviors->attach('Test', array('beforeDelete' => 'on'));
$this->assertIdentical($Apple->delete(4), false);
$Apple->Behaviors->attach('Test', array('beforeDelete' => 'test2'));
if (ob_start()) {
$results = $Apple->delete(4);
$this->assertIdentical(trim(ob_get_clean()), 'beforeDelete success (cascading)');
$this->assertIdentical($results, true);
}
if (ob_start()) {
$results = $Apple->delete(3, false);
$this->assertIdentical(trim(ob_get_clean()), 'beforeDelete success');
$this->assertIdentical($results, true);
}
$Apple->Behaviors->attach('Test', array('beforeDelete' => 'off', 'afterDelete' => 'on'));
if (ob_start()) {
$results = $Apple->delete(2, false);
$this->assertIdentical(trim(ob_get_clean()), 'afterDelete success');
$this->assertIdentical($results, true);
}
}
/**
* testBehaviorOnErrorCallback method
*
* @access public
* @return void
*/
function testBehaviorOnErrorCallback() {
$Apple = new Apple();
$Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'onError' => 'on'));
if (ob_start()) {
$Apple->Behaviors->Test->onError($Apple);
$this->assertIdentical(trim(ob_get_clean()), 'onError trigger success');
}
if (ob_start()) {
$Apple->delete(99);
//$this->assertIdentical(trim(ob_get_clean()), 'onError trigger success');
}
}
/**
* testBehaviorValidateCallback method
*
* @access public
* @return void
*/
function testBehaviorValidateCallback() {
$Apple = new Apple();
$Apple->Behaviors->attach('Test');
$this->assertIdentical($Apple->validates(), true);
$Apple->Behaviors->attach('Test', array('validate' => 'on'));
$this->assertIdentical($Apple->validates(), false);
$this->assertIdentical($Apple->validationErrors, array('name' => true));
$Apple->Behaviors->attach('Test', array('validate' => 'stop'));
$this->assertIdentical($Apple->validates(), false);
$this->assertIdentical($Apple->validationErrors, array('name' => true));
$Apple->Behaviors->attach('Test', array('validate' => 'whitelist'));
$Apple->validates();
$this->assertIdentical($Apple->whitelist, array());
$Apple->whitelist = array('unknown');
$Apple->validates();
$this->assertIdentical($Apple->whitelist, array('unknown', 'name'));
}
/**
* testBehaviorValidateMethods method
*
* @access public
* @return void
*/
function testBehaviorValidateMethods() {
$Apple = new Apple();
$Apple->Behaviors->attach('Test');
$Apple->validate['color'] = 'validateField';
$result = $Apple->save(array('name' => 'Genetically Modified Apple', 'color' => 'Orange'));
$this->assertEqual(array_keys($result['Apple']), array('name', 'color', 'modified', 'created'));
$Apple->create();
$result = $Apple->save(array('name' => 'Regular Apple', 'color' => 'Red'));
$this->assertFalse($result);
}
/**
* testBehaviorMethodDispatching method
*
* @access public
* @return void
*/
function testBehaviorMethodDispatching() {
$Apple = new Apple();
$Apple->Behaviors->attach('Test');
$expected = 'working';
$this->assertEqual($Apple->testMethod(), $expected);
$this->assertEqual($Apple->Behaviors->dispatchMethod($Apple, 'testMethod'), $expected);
$result = $Apple->Behaviors->dispatchMethod($Apple, 'wtf');
$this->assertEqual($result, array('unhandled'));
$result = $Apple->{'look for the remote'}('in the couch');
$expected = "Item.name = 'the remote' AND Location.name = 'the couch'";
$this->assertEqual($result, $expected);
}
/**
* testBehaviorMethodDispatchingWithData method
*
* @access public
* @return void
*/
function testBehaviorMethodDispatchingWithData() {
$Apple = new Apple();
$Apple->Behaviors->attach('Test');
$Apple->set('field', 'value');
$this->assertTrue($Apple->testData());
$this->assertTrue($Apple->data['Apple']['field_2']);
$this->assertTrue($Apple->testData('one', 'two', 'three', 'four', 'five', 'six'));
}
/**
* testBehaviorTrigger method
*
* @access public
* @return void
*/
function testBehaviorTrigger() {
$Apple =& new Apple();
$Apple->Behaviors->attach('Test');
$Apple->Behaviors->attach('Test2');
$Apple->Behaviors->attach('Test3');
$Apple->beforeTestResult = array();
$Apple->Behaviors->trigger($Apple, 'beforeTest');
$expected = array('testbehavior', 'test2behavior', 'test3behavior');
$this->assertIdentical($Apple->beforeTestResult, $expected);
$Apple->beforeTestResult = array();
$Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => 'test2behavior'));
$expected = array('testbehavior', 'test2behavior');
$this->assertIdentical($Apple->beforeTestResult, $expected);
$Apple->beforeTestResult = array();
$Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => array('test2behavior', 'test3behavior')));
$expected = array('testbehavior', 'test2behavior');
$this->assertIdentical($Apple->beforeTestResult, $expected);
}
/**
* undocumented function
*
* @return void
* @access public
*/
function testBindModelCallsInBehaviors() {
$this->loadFixtures('Article', 'Comment');
// hasMany
$Article = new Article();
$Article->unbindModel(array('hasMany' => array('Comment')));
$result = $Article->find('first');
$this->assertFalse(array_key_exists('Comment', $result));
$Article->Behaviors->attach('Test4');
$result = $Article->find('first');
$this->assertTrue(array_key_exists('Comment', $result));
// belongsTo
$Article->unbindModel(array('belongsTo' => array('User')));
$result = $Article->find('first');
$this->assertFalse(array_key_exists('User', $result));
$Article->Behaviors->attach('Test5');
$result = $Article->find('first');
$this->assertTrue(array_key_exists('User', $result));
// hasAndBelongsToMany
$Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')));
$result = $Article->find('first');
$this->assertFalse(array_key_exists('Tag', $result));
$Article->Behaviors->attach('Test6');
$result = $Article->find('first');
$this->assertTrue(array_key_exists('Comment', $result));
// hasOne
$Comment = new Comment();
$Comment->unbindModel(array('hasOne' => array('Attachment')));
$result = $Comment->find('first');
$this->assertFalse(array_key_exists('Attachment', $result));
$Comment->Behaviors->attach('Test7');
$result = $Comment->find('first');
$this->assertTrue(array_key_exists('Attachment', $result));
}
/**
* Test attach and detaching
*
* @access public
* @return void
*/
function testBehaviorAttachAndDetach() {
$Sample =& new Sample();
$Sample->actsAs = array('Test3' => array('bar'), 'Test2' => array('foo', 'bar'));
$Sample->Behaviors->init($Sample->alias, $Sample->actsAs);
$Sample->Behaviors->attach('Test2');
$Sample->Behaviors->detach('Test3');
$Sample->Behaviors->trigger($Sample, 'beforeTest');
}
}
?>