mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
4f67f84ff8
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
2451 lines
No EOL
71 KiB
PHP
2451 lines
No EOL
71 KiB
PHP
<?php
|
|
/**
|
|
* DispatcherTest file
|
|
*
|
|
* PHP versions 4 and 5
|
|
*
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
|
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
*
|
|
* Licensed under The Open Group Test Suite License
|
|
* Redistributions of files must retain the above copyright notice.
|
|
*
|
|
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
* @since CakePHP(tm) v 1.2.0.4206
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
*/
|
|
require_once CAKE . 'dispatcher.php';
|
|
|
|
if (!class_exists('AppController')) {
|
|
require_once LIBS . 'controller' . DS . 'app_controller.php';
|
|
} elseif (!defined('APP_CONTROLLER_EXISTS')){
|
|
define('APP_CONTROLLER_EXISTS', true);
|
|
}
|
|
|
|
/**
|
|
* TestDispatcher class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class TestDispatcher extends Dispatcher {
|
|
|
|
/**
|
|
* invoke method
|
|
*
|
|
* @param mixed $controller
|
|
* @param mixed $params
|
|
* @param mixed $missingAction
|
|
* @return void
|
|
* @access protected
|
|
*/
|
|
function _invoke(&$controller, $params) {
|
|
restore_error_handler();
|
|
if ($result = parent::_invoke($controller, $params)) {
|
|
if ($result[0] === 'missingAction') {
|
|
return $result;
|
|
}
|
|
}
|
|
set_error_handler('simpleTestErrorHandler');
|
|
|
|
return $controller;
|
|
}
|
|
|
|
/**
|
|
* cakeError method
|
|
*
|
|
* @param mixed $filename
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function cakeError($filename, $params) {
|
|
return array($filename, $params);
|
|
}
|
|
|
|
/**
|
|
* _stop method
|
|
*
|
|
* @return void
|
|
* @access protected
|
|
*/
|
|
function _stop() {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* MyPluginAppController class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class MyPluginAppController extends AppController {
|
|
}
|
|
|
|
/**
|
|
* MyPluginController class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class MyPluginController extends MyPluginAppController {
|
|
|
|
/**
|
|
* name property
|
|
*
|
|
* @var string 'MyPlugin'
|
|
* @access public
|
|
*/
|
|
var $name = 'MyPlugin';
|
|
|
|
/**
|
|
* uses property
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $uses = array();
|
|
|
|
/**
|
|
* index method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function index() {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* add method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function add() {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* admin_add method
|
|
*
|
|
* @param mixed $id
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function admin_add($id = null) {
|
|
return $id;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* SomePagesController class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class SomePagesController extends AppController {
|
|
|
|
/**
|
|
* name property
|
|
*
|
|
* @var string 'SomePages'
|
|
* @access public
|
|
*/
|
|
var $name = 'SomePages';
|
|
|
|
/**
|
|
* uses property
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $uses = array();
|
|
|
|
/**
|
|
* display method
|
|
*
|
|
* @param mixed $page
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function display($page = null) {
|
|
return $page;
|
|
}
|
|
|
|
/**
|
|
* index method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function index() {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* protected method
|
|
*
|
|
* @return void
|
|
* @access protected
|
|
*/
|
|
function _protected() {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* redirect method overriding
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function redirect() {
|
|
echo 'this should not be accessible';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* OtherPagesController class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class OtherPagesController extends MyPluginAppController {
|
|
|
|
/**
|
|
* name property
|
|
*
|
|
* @var string 'OtherPages'
|
|
* @access public
|
|
*/
|
|
var $name = 'OtherPages';
|
|
|
|
/**
|
|
* uses property
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $uses = array();
|
|
|
|
/**
|
|
* display method
|
|
*
|
|
* @param mixed $page
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function display($page = null) {
|
|
return $page;
|
|
}
|
|
|
|
/**
|
|
* index method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function index() {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* TestDispatchPagesController class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class TestDispatchPagesController extends AppController {
|
|
|
|
/**
|
|
* name property
|
|
*
|
|
* @var string 'TestDispatchPages'
|
|
* @access public
|
|
*/
|
|
var $name = 'TestDispatchPages';
|
|
|
|
/**
|
|
* uses property
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $uses = array();
|
|
|
|
/**
|
|
* admin_index method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function admin_index() {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* camelCased method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function camelCased() {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* ArticlesTestAppController class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class ArticlesTestAppController extends AppController {
|
|
}
|
|
|
|
/**
|
|
* ArticlesTestController class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class ArticlesTestController extends ArticlesTestAppController {
|
|
|
|
/**
|
|
* name property
|
|
*
|
|
* @var string 'ArticlesTest'
|
|
* @access public
|
|
*/
|
|
var $name = 'ArticlesTest';
|
|
|
|
/**
|
|
* uses property
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $uses = array();
|
|
|
|
/**
|
|
* admin_index method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function admin_index() {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* SomePostsController class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class SomePostsController extends AppController {
|
|
|
|
/**
|
|
* name property
|
|
*
|
|
* @var string 'SomePosts'
|
|
* @access public
|
|
*/
|
|
var $name = 'SomePosts';
|
|
|
|
/**
|
|
* uses property
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $uses = array();
|
|
|
|
/**
|
|
* autoRender property
|
|
*
|
|
* @var bool false
|
|
* @access public
|
|
*/
|
|
var $autoRender = false;
|
|
|
|
/**
|
|
* beforeFilter method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function beforeFilter() {
|
|
if ($this->params['action'] == 'index') {
|
|
$this->params['action'] = 'view';
|
|
} else {
|
|
$this->params['action'] = 'change';
|
|
}
|
|
$this->params['pass'] = array('changed');
|
|
}
|
|
|
|
/**
|
|
* index method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function index() {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* change method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function change() {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* TestCachedPagesController class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class TestCachedPagesController extends AppController {
|
|
|
|
/**
|
|
* name property
|
|
*
|
|
* @var string 'TestCachedPages'
|
|
* @access public
|
|
*/
|
|
var $name = 'TestCachedPages';
|
|
|
|
/**
|
|
* uses property
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $uses = array();
|
|
|
|
/**
|
|
* helpers property
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $helpers = array('Cache');
|
|
|
|
/**
|
|
* cacheAction property
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $cacheAction = array(
|
|
'index' => '+2 sec',
|
|
'test_nocache_tags' => '+2 sec',
|
|
'view' => '+2 sec'
|
|
);
|
|
|
|
/**
|
|
* viewPath property
|
|
*
|
|
* @var string 'posts'
|
|
* @access public
|
|
*/
|
|
var $viewPath = 'posts';
|
|
|
|
/**
|
|
* index method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function index() {
|
|
$this->render();
|
|
}
|
|
|
|
/**
|
|
* test_nocache_tags method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function test_nocache_tags() {
|
|
$this->render();
|
|
}
|
|
|
|
/**
|
|
* view method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function view($id = null) {
|
|
$this->render('index');
|
|
}
|
|
/**
|
|
* test cached forms / tests view object being registered
|
|
*
|
|
* @return void
|
|
*/
|
|
function cache_form() {
|
|
$this->cacheAction = 10;
|
|
$this->helpers[] = 'Form';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* TimesheetsController class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class TimesheetsController extends AppController {
|
|
|
|
/**
|
|
* name property
|
|
*
|
|
* @var string 'Timesheets'
|
|
* @access public
|
|
*/
|
|
var $name = 'Timesheets';
|
|
|
|
/**
|
|
* uses property
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $uses = array();
|
|
|
|
/**
|
|
* index method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function index() {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* DispatcherTest class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases
|
|
*/
|
|
class DispatcherTest extends CakeTestCase {
|
|
|
|
/**
|
|
* setUp method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function startTest() {
|
|
$this->_get = $_GET;
|
|
$_GET = array();
|
|
$this->_post = $_POST;
|
|
$this->_files = $_FILES;
|
|
$this->_server = $_SERVER;
|
|
|
|
$this->_app = Configure::read('App');
|
|
Configure::write('App.base', false);
|
|
Configure::write('App.baseUrl', false);
|
|
Configure::write('App.dir', 'app');
|
|
Configure::write('App.webroot', 'webroot');
|
|
|
|
$this->_cache = Configure::read('Cache');
|
|
Configure::write('Cache.disable', true);
|
|
|
|
$this->_debug = Configure::read('debug');
|
|
|
|
App::build(App::core());
|
|
}
|
|
|
|
/**
|
|
* tearDown method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function endTest() {
|
|
$_GET = $this->_get;
|
|
$_POST = $this->_post;
|
|
$_FILES = $this->_files;
|
|
$_SERVER = $this->_server;
|
|
App::build();
|
|
Configure::write('App', $this->_app);
|
|
Configure::write('Cache', $this->_cache);
|
|
Configure::write('debug', $this->_debug);
|
|
}
|
|
|
|
/**
|
|
* testParseParamsWithoutZerosAndEmptyPost method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testParseParamsWithoutZerosAndEmptyPost() {
|
|
$Dispatcher =& new Dispatcher();
|
|
$test = $Dispatcher->parseParams("/testcontroller/testaction/params1/params2/params3");
|
|
$this->assertIdentical($test['controller'], 'testcontroller');
|
|
$this->assertIdentical($test['action'], 'testaction');
|
|
$this->assertIdentical($test['pass'][0], 'params1');
|
|
$this->assertIdentical($test['pass'][1], 'params2');
|
|
$this->assertIdentical($test['pass'][2], 'params3');
|
|
$this->assertFalse(!empty($test['form']));
|
|
}
|
|
|
|
/**
|
|
* testParseParamsReturnsPostedData method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testParseParamsReturnsPostedData() {
|
|
$_POST['testdata'] = "My Posted Content";
|
|
$Dispatcher =& new Dispatcher();
|
|
$test = $Dispatcher->parseParams("/");
|
|
$this->assertTrue($test['form'], "Parsed URL not returning post data");
|
|
$this->assertIdentical($test['form']['testdata'], "My Posted Content");
|
|
}
|
|
|
|
/**
|
|
* testParseParamsWithSingleZero method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testParseParamsWithSingleZero() {
|
|
$Dispatcher =& new Dispatcher();
|
|
$test = $Dispatcher->parseParams("/testcontroller/testaction/1/0/23");
|
|
$this->assertIdentical($test['controller'], 'testcontroller');
|
|
$this->assertIdentical($test['action'], 'testaction');
|
|
$this->assertIdentical($test['pass'][0], '1');
|
|
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][1]);
|
|
$this->assertIdentical($test['pass'][2], '23');
|
|
}
|
|
|
|
/**
|
|
* testParseParamsWithManySingleZeros method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testParseParamsWithManySingleZeros() {
|
|
$Dispatcher =& new Dispatcher();
|
|
$test = $Dispatcher->parseParams("/testcontroller/testaction/0/0/0/0/0/0");
|
|
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][0]);
|
|
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][1]);
|
|
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][2]);
|
|
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][3]);
|
|
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][4]);
|
|
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][5]);
|
|
}
|
|
|
|
/**
|
|
* testParseParamsWithManyZerosInEachSectionOfUrl method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testParseParamsWithManyZerosInEachSectionOfUrl() {
|
|
$Dispatcher =& new Dispatcher();
|
|
$test = $Dispatcher->parseParams("/testcontroller/testaction/000/0000/00000/000000/000000/0000000");
|
|
$this->assertPattern('/\\A(?:000)\\z/', $test['pass'][0]);
|
|
$this->assertPattern('/\\A(?:0000)\\z/', $test['pass'][1]);
|
|
$this->assertPattern('/\\A(?:00000)\\z/', $test['pass'][2]);
|
|
$this->assertPattern('/\\A(?:000000)\\z/', $test['pass'][3]);
|
|
$this->assertPattern('/\\A(?:000000)\\z/', $test['pass'][4]);
|
|
$this->assertPattern('/\\A(?:0000000)\\z/', $test['pass'][5]);
|
|
}
|
|
|
|
/**
|
|
* testParseParamsWithMixedOneToManyZerosInEachSectionOfUrl method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testParseParamsWithMixedOneToManyZerosInEachSectionOfUrl() {
|
|
$Dispatcher =& new Dispatcher();
|
|
$test = $Dispatcher->parseParams("/testcontroller/testaction/01/0403/04010/000002/000030/0000400");
|
|
$this->assertPattern('/\\A(?:01)\\z/', $test['pass'][0]);
|
|
$this->assertPattern('/\\A(?:0403)\\z/', $test['pass'][1]);
|
|
$this->assertPattern('/\\A(?:04010)\\z/', $test['pass'][2]);
|
|
$this->assertPattern('/\\A(?:000002)\\z/', $test['pass'][3]);
|
|
$this->assertPattern('/\\A(?:000030)\\z/', $test['pass'][4]);
|
|
$this->assertPattern('/\\A(?:0000400)\\z/', $test['pass'][5]);
|
|
}
|
|
|
|
/**
|
|
* testQueryStringOnRoot method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testQueryStringOnRoot() {
|
|
Router::reload();
|
|
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
|
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
|
|
|
|
$_GET = array('coffee' => 'life', 'sleep' => 'sissies');
|
|
$Dispatcher =& new Dispatcher();
|
|
$uri = 'posts/home/?coffee=life&sleep=sissies';
|
|
$result = $Dispatcher->parseParams($uri);
|
|
$this->assertPattern('/posts/', $result['controller']);
|
|
$this->assertPattern('/home/', $result['action']);
|
|
$this->assertTrue(isset($result['url']['sleep']));
|
|
$this->assertTrue(isset($result['url']['coffee']));
|
|
|
|
$Dispatcher =& new Dispatcher();
|
|
$uri = '/?coffee=life&sleep=sissy';
|
|
$result = $Dispatcher->parseParams($uri);
|
|
$this->assertPattern('/pages/', $result['controller']);
|
|
$this->assertPattern('/display/', $result['action']);
|
|
$this->assertTrue(isset($result['url']['sleep']));
|
|
$this->assertTrue(isset($result['url']['coffee']));
|
|
$this->assertEqual($result['url']['coffee'], 'life');
|
|
}
|
|
|
|
/**
|
|
* testFileUploadArrayStructure method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testFileUploadArrayStructure() {
|
|
$_FILES = array('data' => array('name' => array(
|
|
'File' => array(
|
|
array('data' => 'cake_mssql_patch.patch'),
|
|
array('data' => 'controller.diff'),
|
|
array('data' => ''),
|
|
array('data' => ''),
|
|
),
|
|
'Post' => array('attachment' => 'jquery-1.2.1.js'),
|
|
),
|
|
'type' => array(
|
|
'File' => array(
|
|
array('data' => ''),
|
|
array('data' => ''),
|
|
array('data' => ''),
|
|
array('data' => ''),
|
|
),
|
|
'Post' => array('attachment' => 'application/x-javascript'),
|
|
),
|
|
'tmp_name' => array(
|
|
'File' => array(
|
|
array('data' => '/private/var/tmp/phpy05Ywj'),
|
|
array('data' => '/private/var/tmp/php7MBztY'),
|
|
array('data' => ''),
|
|
array('data' => ''),
|
|
),
|
|
'Post' => array('attachment' => '/private/var/tmp/phpEwlrIo'),
|
|
),
|
|
'error' => array(
|
|
'File' => array(
|
|
array('data' => 0),
|
|
array('data' => 0),
|
|
array('data' => 4),
|
|
array('data' => 4)
|
|
),
|
|
'Post' => array('attachment' => 0)
|
|
),
|
|
'size' => array(
|
|
'File' => array(
|
|
array('data' => 6271),
|
|
array('data' => 350),
|
|
array('data' => 0),
|
|
array('data' => 0),
|
|
),
|
|
'Post' => array('attachment' => 80469)
|
|
),
|
|
));
|
|
|
|
$Dispatcher =& new Dispatcher();
|
|
$result = $Dispatcher->parseParams('/');
|
|
|
|
$expected = array(
|
|
'File' => array(
|
|
array('data' => array(
|
|
'name' => 'cake_mssql_patch.patch',
|
|
'type' => '',
|
|
'tmp_name' => '/private/var/tmp/phpy05Ywj',
|
|
'error' => 0,
|
|
'size' => 6271,
|
|
),
|
|
),
|
|
array('data' => array(
|
|
'name' => 'controller.diff',
|
|
'type' => '',
|
|
'tmp_name' => '/private/var/tmp/php7MBztY',
|
|
'error' => 0,
|
|
'size' => 350,
|
|
)),
|
|
array('data' => array(
|
|
'name' => '',
|
|
'type' => '',
|
|
'tmp_name' => '',
|
|
'error' => 4,
|
|
'size' => 0,
|
|
)),
|
|
array('data' => array(
|
|
'name' => '',
|
|
'type' => '',
|
|
'tmp_name' => '',
|
|
'error' => 4,
|
|
'size' => 0,
|
|
)),
|
|
),
|
|
'Post' => array('attachment' => array(
|
|
'name' => 'jquery-1.2.1.js',
|
|
'type' => 'application/x-javascript',
|
|
'tmp_name' => '/private/var/tmp/phpEwlrIo',
|
|
'error' => 0,
|
|
'size' => 80469,
|
|
)));
|
|
$this->assertEqual($result['data'], $expected);
|
|
|
|
$_FILES = array(
|
|
'data' => array(
|
|
'name' => array(
|
|
'Document' => array(
|
|
1 => array(
|
|
'birth_cert' => 'born on.txt',
|
|
'passport' => 'passport.txt',
|
|
'drivers_license' => 'ugly pic.jpg'
|
|
),
|
|
2 => array(
|
|
'birth_cert' => 'aunt betty.txt',
|
|
'passport' => 'betty-passport.txt',
|
|
'drivers_license' => 'betty-photo.jpg'
|
|
),
|
|
),
|
|
),
|
|
'type' => array(
|
|
'Document' => array(
|
|
1 => array(
|
|
'birth_cert' => 'application/octet-stream',
|
|
'passport' => 'application/octet-stream',
|
|
'drivers_license' => 'application/octet-stream',
|
|
),
|
|
2 => array(
|
|
'birth_cert' => 'application/octet-stream',
|
|
'passport' => 'application/octet-stream',
|
|
'drivers_license' => 'application/octet-stream',
|
|
)
|
|
)
|
|
),
|
|
'tmp_name' => array(
|
|
'Document' => array(
|
|
1 => array(
|
|
'birth_cert' => '/private/var/tmp/phpbsUWfH',
|
|
'passport' => '/private/var/tmp/php7f5zLt',
|
|
'drivers_license' => '/private/var/tmp/phpMXpZgT',
|
|
),
|
|
2 => array(
|
|
'birth_cert' => '/private/var/tmp/php5kHZt0',
|
|
'passport' => '/private/var/tmp/phpnYkOuM',
|
|
'drivers_license' => '/private/var/tmp/php9Rq0P3',
|
|
)
|
|
)
|
|
),
|
|
'error' => array(
|
|
'Document' => array(
|
|
1 => array(
|
|
'birth_cert' => 0,
|
|
'passport' => 0,
|
|
'drivers_license' => 0,
|
|
),
|
|
2 => array(
|
|
'birth_cert' => 0,
|
|
'passport' => 0,
|
|
'drivers_license' => 0,
|
|
)
|
|
)
|
|
),
|
|
'size' => array(
|
|
'Document' => array(
|
|
1 => array(
|
|
'birth_cert' => 123,
|
|
'passport' => 458,
|
|
'drivers_license' => 875,
|
|
),
|
|
2 => array(
|
|
'birth_cert' => 876,
|
|
'passport' => 976,
|
|
'drivers_license' => 9783,
|
|
)
|
|
)
|
|
)
|
|
)
|
|
);
|
|
$Dispatcher =& new Dispatcher();
|
|
$result = $Dispatcher->parseParams('/');
|
|
$expected = array(
|
|
'Document' => array(
|
|
1 => array(
|
|
'birth_cert' => array(
|
|
'name' => 'born on.txt',
|
|
'tmp_name' => '/private/var/tmp/phpbsUWfH',
|
|
'error' => 0,
|
|
'size' => 123,
|
|
'type' => 'application/octet-stream',
|
|
),
|
|
'passport' => array(
|
|
'name' => 'passport.txt',
|
|
'tmp_name' => '/private/var/tmp/php7f5zLt',
|
|
'error' => 0,
|
|
'size' => 458,
|
|
'type' => 'application/octet-stream',
|
|
),
|
|
'drivers_license' => array(
|
|
'name' => 'ugly pic.jpg',
|
|
'tmp_name' => '/private/var/tmp/phpMXpZgT',
|
|
'error' => 0,
|
|
'size' => 875,
|
|
'type' => 'application/octet-stream',
|
|
),
|
|
),
|
|
2 => array(
|
|
'birth_cert' => array(
|
|
'name' => 'aunt betty.txt',
|
|
'tmp_name' => '/private/var/tmp/php5kHZt0',
|
|
'error' => 0,
|
|
'size' => 876,
|
|
'type' => 'application/octet-stream',
|
|
),
|
|
'passport' => array(
|
|
'name' => 'betty-passport.txt',
|
|
'tmp_name' => '/private/var/tmp/phpnYkOuM',
|
|
'error' => 0,
|
|
'size' => 976,
|
|
'type' => 'application/octet-stream',
|
|
),
|
|
'drivers_license' => array(
|
|
'name' => 'betty-photo.jpg',
|
|
'tmp_name' => '/private/var/tmp/php9Rq0P3',
|
|
'error' => 0,
|
|
'size' => 9783,
|
|
'type' => 'application/octet-stream',
|
|
),
|
|
),
|
|
)
|
|
);
|
|
$this->assertEqual($result['data'], $expected);
|
|
|
|
|
|
$_FILES = array(
|
|
'data' => array(
|
|
'name' => array('birth_cert' => 'born on.txt'),
|
|
'type' => array('birth_cert' => 'application/octet-stream'),
|
|
'tmp_name' => array('birth_cert' => '/private/var/tmp/phpbsUWfH'),
|
|
'error' => array('birth_cert' => 0),
|
|
'size' => array('birth_cert' => 123)
|
|
)
|
|
);
|
|
|
|
$Dispatcher =& new Dispatcher();
|
|
$result = $Dispatcher->parseParams('/');
|
|
|
|
$expected = array(
|
|
'birth_cert' => array(
|
|
'name' => 'born on.txt',
|
|
'type' => 'application/octet-stream',
|
|
'tmp_name' => '/private/var/tmp/phpbsUWfH',
|
|
'error' => 0,
|
|
'size' => 123
|
|
)
|
|
);
|
|
|
|
$this->assertEqual($result['data'], $expected);
|
|
}
|
|
|
|
/**
|
|
* testGetUrl method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testGetUrl() {
|
|
$Dispatcher =& new Dispatcher();
|
|
$Dispatcher->base = '/app/webroot/index.php';
|
|
$uri = '/app/webroot/index.php/posts/add';
|
|
$result = $Dispatcher->getUrl($uri);
|
|
$expected = 'posts/add';
|
|
$this->assertEqual($expected, $result);
|
|
|
|
Configure::write('App.baseUrl', '/app/webroot/index.php');
|
|
|
|
$uri = '/posts/add';
|
|
$result = $Dispatcher->getUrl($uri);
|
|
$expected = 'posts/add';
|
|
$this->assertEqual($expected, $result);
|
|
|
|
$_GET['url'] = array();
|
|
Configure::write('App.base', '/control');
|
|
$Dispatcher =& new Dispatcher();
|
|
$Dispatcher->baseUrl();
|
|
$uri = '/control/students/browse';
|
|
$result = $Dispatcher->getUrl($uri);
|
|
$expected = 'students/browse';
|
|
$this->assertEqual($expected, $result);
|
|
|
|
$_GET['url'] = array();
|
|
$Dispatcher =& new Dispatcher();
|
|
$Dispatcher->base = '';
|
|
$uri = '/?/home';
|
|
$result = $Dispatcher->getUrl($uri);
|
|
$expected = '?/home';
|
|
$this->assertEqual($expected, $result);
|
|
|
|
}
|
|
|
|
/**
|
|
* testBaseUrlAndWebrootWithModRewrite method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testBaseUrlAndWebrootWithModRewrite() {
|
|
$Dispatcher =& new Dispatcher();
|
|
|
|
$Dispatcher->base = false;
|
|
$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches';
|
|
$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php';
|
|
$_SERVER['PHP_SELF'] = '/1.2.x.x/app/webroot/index.php';
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/1.2.x.x';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/1.2.x.x/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
$Dispatcher->base = false;
|
|
$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/app/webroot';
|
|
$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php';
|
|
$_SERVER['PHP_SELF'] = '/index.php';
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
$Dispatcher->base = false;
|
|
$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/test/';
|
|
$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/test/webroot/index.php';
|
|
$_SERVER['PHP_SELF'] = '/webroot/index.php';
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
$Dispatcher->base = false;
|
|
$_SERVER['DOCUMENT_ROOT'] = '/some/apps/where';
|
|
$_SERVER['SCRIPT_FILENAME'] = '/some/apps/where/app/webroot/index.php';
|
|
$_SERVER['PHP_SELF'] = '/some/apps/where/app/webroot/index.php';
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/some/apps/where';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/some/apps/where/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
|
|
Configure::write('App.dir', 'auth');
|
|
|
|
$Dispatcher->base = false;
|
|
$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches';
|
|
$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/demos/auth/webroot/index.php';
|
|
$_SERVER['PHP_SELF'] = '/demos/auth/webroot/index.php';
|
|
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/demos/auth';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/demos/auth/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
Configure::write('App.dir', 'code');
|
|
|
|
$Dispatcher->base = false;
|
|
$_SERVER['DOCUMENT_ROOT'] = '/Library/WebServer/Documents';
|
|
$_SERVER['SCRIPT_FILENAME'] = '/Library/WebServer/Documents/clients/PewterReport/code/webroot/index.php';
|
|
$_SERVER['PHP_SELF'] = '/clients/PewterReport/code/webroot/index.php';
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/clients/PewterReport/code';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/clients/PewterReport/code/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
}
|
|
|
|
/**
|
|
* testBaseUrlwithModRewriteAlias method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testBaseUrlwithModRewriteAlias() {
|
|
$_SERVER['DOCUMENT_ROOT'] = '/home/aplusnur/public_html';
|
|
$_SERVER['SCRIPT_FILENAME'] = '/home/aplusnur/cake2/app/webroot/index.php';
|
|
$_SERVER['PHP_SELF'] = '/control/index.php';
|
|
|
|
Configure::write('App.base', '/control');
|
|
|
|
$Dispatcher =& new Dispatcher();
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/control';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/control/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
Configure::write('App.base', false);
|
|
Configure::write('App.dir', 'affiliate');
|
|
Configure::write('App.webroot', 'newaffiliate');
|
|
|
|
$_SERVER['DOCUMENT_ROOT'] = '/var/www/abtravaff/html';
|
|
$_SERVER['SCRIPT_FILENAME'] = '/var/www/abtravaff/html/newaffiliate/index.php';
|
|
$_SERVER['PHP_SELF'] = '/newaffiliate/index.php';
|
|
$Dispatcher =& new Dispatcher();
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/newaffiliate';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/newaffiliate/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
}
|
|
|
|
/**
|
|
* testBaseUrlAndWebrootWithBaseUrl method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testBaseUrlAndWebrootWithBaseUrl() {
|
|
$Dispatcher =& new Dispatcher();
|
|
|
|
Configure::write('App.dir', 'app');
|
|
|
|
Configure::write('App.baseUrl', '/app/webroot/index.php');
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/app/webroot/index.php';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/app/webroot/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
Configure::write('App.baseUrl', '/app/webroot/test.php');
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/app/webroot/test.php';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/app/webroot/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
Configure::write('App.baseUrl', '/app/index.php');
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/app/index.php';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/app/webroot/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
Configure::write('App.baseUrl', '/index.php');
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/index.php';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/app/webroot/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
Configure::write('App.baseUrl', '/CakeBB/app/webroot/index.php');
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/CakeBB/app/webroot/index.php';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/CakeBB/app/webroot/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
Configure::write('App.baseUrl', '/CakeBB/app/index.php');
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/CakeBB/app/index.php';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/CakeBB/app/webroot/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
Configure::write('App.baseUrl', '/CakeBB/index.php');
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/CakeBB/index.php';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/CakeBB/app/webroot/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
Configure::write('App.baseUrl', '/dbhauser/index.php');
|
|
$_SERVER['DOCUMENT_ROOT'] = '/kunden/homepages/4/d181710652/htdocs/joomla';
|
|
$_SERVER['SCRIPT_FILENAME'] = '/kunden/homepages/4/d181710652/htdocs/joomla/dbhauser/index.php';
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/dbhauser/index.php';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/dbhauser/app/webroot/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
}
|
|
|
|
/**
|
|
* testBaseUrlAndWebrootWithBase method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testBaseUrlAndWebrootWithBase() {
|
|
$Dispatcher =& new Dispatcher();
|
|
$Dispatcher->base = '/app';
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/app';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/app/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
$Dispatcher->base = '';
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
|
|
Configure::write('App.dir', 'testbed');
|
|
$Dispatcher->base = '/cake/testbed/webroot';
|
|
$result = $Dispatcher->baseUrl();
|
|
$expected = '/cake/testbed/webroot';
|
|
$this->assertEqual($expected, $result);
|
|
$expectedWebroot = '/cake/testbed/webroot/';
|
|
$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
|
|
}
|
|
|
|
/**
|
|
* testMissingController method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testMissingController() {
|
|
$Dispatcher =& new TestDispatcher();
|
|
Configure::write('App.baseUrl','/index.php');
|
|
$url = 'some_controller/home/param:value/param2:value2';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$expected = array('missingController', array(array(
|
|
'className' => 'SomeControllerController',
|
|
'webroot' => '/app/webroot/',
|
|
'url' => 'some_controller/home/param:value/param2:value2',
|
|
'base' => '/index.php'
|
|
)));
|
|
$this->assertEqual($expected, $controller);
|
|
}
|
|
|
|
/**
|
|
* testPrivate method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testPrivate() {
|
|
$Dispatcher =& new TestDispatcher();
|
|
Configure::write('App.baseUrl','/index.php');
|
|
$url = 'some_pages/_protected/param:value/param2:value2';
|
|
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$expected = array('privateAction', array(array(
|
|
'className' => 'SomePagesController',
|
|
'action' => '_protected',
|
|
'webroot' => '/app/webroot/',
|
|
'url' => 'some_pages/_protected/param:value/param2:value2',
|
|
'base' => '/index.php'
|
|
)));
|
|
$this->assertEqual($controller, $expected);
|
|
}
|
|
|
|
/**
|
|
* testMissingAction method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testMissingAction() {
|
|
$Dispatcher =& new TestDispatcher();
|
|
Configure::write('App.baseUrl','/index.php');
|
|
$url = 'some_pages/home/param:value/param2:value2';
|
|
|
|
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
|
|
|
|
$expected = array('missingAction', array(array(
|
|
'className' => 'SomePagesController',
|
|
'action' => 'home',
|
|
'webroot' => '/app/webroot/',
|
|
'url' => '/index.php/some_pages/home/param:value/param2:value2',
|
|
'base' => '/index.php'
|
|
)));
|
|
$this->assertEqual($expected, $controller);
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
Configure::write('App.baseUrl','/index.php');
|
|
$url = 'some_pages/redirect/param:value/param2:value2';
|
|
|
|
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
|
|
|
|
$expected = array('missingAction', array(array(
|
|
'className' => 'SomePagesController',
|
|
'action' => 'redirect',
|
|
'webroot' => '/app/webroot/',
|
|
'url' => '/index.php/some_pages/redirect/param:value/param2:value2',
|
|
'base' => '/index.php'
|
|
)));
|
|
$this->assertEqual($expected, $controller);
|
|
}
|
|
|
|
/**
|
|
* testDispatch method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testDispatch() {
|
|
$Dispatcher =& new TestDispatcher();
|
|
Configure::write('App.baseUrl','/index.php');
|
|
$url = 'pages/home/param:value/param2:value2';
|
|
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$expected = 'Pages';
|
|
$this->assertEqual($expected, $controller->name);
|
|
|
|
$expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2');
|
|
$this->assertIdentical($expected, $controller->passedArgs);
|
|
|
|
Configure::write('App.baseUrl','/pages/index.php');
|
|
|
|
$url = 'pages/home';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$expected = 'Pages';
|
|
$this->assertEqual($expected, $controller->name);
|
|
|
|
$url = 'pages/home/';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertNull($controller->plugin);
|
|
$this->assertNull($Dispatcher->params['plugin']);
|
|
|
|
$expected = 'Pages';
|
|
$this->assertEqual($expected, $controller->name);
|
|
|
|
unset($Dispatcher);
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
Configure::write('App.baseUrl','/timesheets/index.php');
|
|
|
|
$url = 'timesheets';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$expected = 'Timesheets';
|
|
$this->assertEqual($expected, $controller->name);
|
|
|
|
$url = 'timesheets/';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$this->assertEqual('Timesheets', $controller->name);
|
|
$this->assertEqual('/timesheets/index.php', $Dispatcher->base);
|
|
|
|
|
|
$url = 'test_dispatch_pages/camelCased';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertEqual('TestDispatchPages', $controller->name);
|
|
}
|
|
|
|
/**
|
|
* testDispatchWithArray method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testDispatchWithArray() {
|
|
$Dispatcher =& new TestDispatcher();
|
|
Configure::write('App.baseUrl','/index.php');
|
|
$url = 'pages/home/param:value/param2:value2';
|
|
|
|
$url = array('controller' => 'pages', 'action' => 'display');
|
|
$controller = $Dispatcher->dispatch($url, array('pass' => array('home'), 'named' => array('param' => 'value', 'param2' => 'value2'), 'return' => 1));
|
|
$expected = 'Pages';
|
|
$this->assertEqual($expected, $controller->name);
|
|
|
|
$expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2');
|
|
$this->assertIdentical($expected, $controller->passedArgs);
|
|
}
|
|
|
|
/**
|
|
* testAdminDispatch method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testAdminDispatch() {
|
|
$_POST = array();
|
|
$Dispatcher =& new TestDispatcher();
|
|
Configure::write('Routing.prefixes', array('admin'));
|
|
Configure::write('App.baseUrl','/cake/repo/branches/1.2.x.x/index.php');
|
|
$url = 'admin/test_dispatch_pages/index/param:value/param2:value2';
|
|
|
|
Router::reload();
|
|
$Router =& Router::getInstance();
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$expected = 'TestDispatchPages';
|
|
$this->assertEqual($expected, $controller->name);
|
|
|
|
$expected = array('param' => 'value', 'param2' => 'value2');
|
|
$this->assertIdentical($expected, $controller->passedArgs);
|
|
$this->assertTrue($controller->params['admin']);
|
|
|
|
$expected = '/cake/repo/branches/1.2.x.x/index.php/admin/test_dispatch_pages/index/param:value/param2:value2';
|
|
$this->assertIdentical($expected, $controller->here);
|
|
|
|
$expected = '/cake/repo/branches/1.2.x.x/index.php';
|
|
$this->assertIdentical($expected, $controller->base);
|
|
}
|
|
|
|
/**
|
|
* testPluginDispatch method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testPluginDispatch() {
|
|
$_POST = array();
|
|
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
|
|
|
|
Router::reload();
|
|
$Dispatcher =& new TestDispatcher();
|
|
Router::connect('/my_plugin/:controller/*', array('plugin'=>'my_plugin', 'controller'=>'pages', 'action'=>'display'));
|
|
|
|
$Dispatcher->base = false;
|
|
$url = 'my_plugin/some_pages/home/param:value/param2:value2';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$result = $Dispatcher->parseParams($url);
|
|
$expected = array(
|
|
'pass' => array('home'),
|
|
'named' => array('param'=> 'value', 'param2'=> 'value2'), 'plugin'=> 'my_plugin',
|
|
'controller'=> 'some_pages', 'action'=> 'display', 'form'=> null,
|
|
'url'=> array('url'=> 'my_plugin/some_pages/home/param:value/param2:value2'),
|
|
);
|
|
ksort($expected);
|
|
ksort($result);
|
|
|
|
$this->assertEqual($expected, $result);
|
|
|
|
$expected = 'my_plugin';
|
|
$this->assertIdentical($expected, $controller->plugin);
|
|
|
|
$expected = 'SomePages';
|
|
$this->assertIdentical($expected, $controller->name);
|
|
|
|
$expected = 'some_pages';
|
|
$this->assertIdentical($expected, $controller->params['controller']);
|
|
|
|
$expected = array('0' => 'home', 'param'=>'value', 'param2'=>'value2');
|
|
$this->assertIdentical($expected, $controller->passedArgs);
|
|
|
|
$expected = '/cake/repo/branches/1.2.x.x/my_plugin/some_pages/home/param:value/param2:value2';
|
|
$this->assertIdentical($expected, $controller->here);
|
|
|
|
$expected = '/cake/repo/branches/1.2.x.x';
|
|
$this->assertIdentical($expected, $controller->base);
|
|
}
|
|
|
|
/**
|
|
* testAutomaticPluginDispatch method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testAutomaticPluginDispatch() {
|
|
$_POST = array();
|
|
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
|
|
|
|
Router::reload();
|
|
$Dispatcher =& new TestDispatcher();
|
|
Router::connect('/my_plugin/:controller/:action/*', array('plugin'=>'my_plugin', 'controller'=>'pages', 'action'=>'display'));
|
|
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'my_plugin/other_pages/index/param:value/param2:value2';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$expected = 'my_plugin';
|
|
$this->assertIdentical($expected, $controller->plugin);
|
|
|
|
$expected = 'OtherPages';
|
|
$this->assertIdentical($expected, $controller->name);
|
|
|
|
$expected = 'index';
|
|
$this->assertIdentical($expected, $controller->action);
|
|
|
|
$expected = array('param' => 'value', 'param2' => 'value2');
|
|
$this->assertIdentical($expected, $controller->passedArgs);
|
|
|
|
$expected = '/cake/repo/branches/1.2.x.x/my_plugin/other_pages/index/param:value/param2:value2';
|
|
$this->assertIdentical($expected, $controller->here);
|
|
|
|
$expected = '/cake/repo/branches/1.2.x.x';
|
|
$this->assertIdentical($expected, $controller->base);
|
|
}
|
|
|
|
/**
|
|
* testAutomaticPluginControllerDispatch method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testAutomaticPluginControllerDispatch() {
|
|
$_POST = array();
|
|
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
|
|
|
|
Router::reload();
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'my_plugin/add/param:value/param2:value2';
|
|
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$this->assertIdentical($controller->plugin, 'my_plugin');
|
|
$this->assertIdentical($controller->name, 'MyPlugin');
|
|
$this->assertIdentical($controller->action, 'add');
|
|
$this->assertEqual($controller->params['named'], array('param' => 'value', 'param2' => 'value2'));
|
|
|
|
|
|
Router::reload();
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
/* Simulates the Route for a real plugin, installed in APP/plugins */
|
|
Router::connect('/my_plugin/:controller/:action/*', array('plugin' => 'my_plugin'));
|
|
|
|
$plugin = 'MyPlugin';
|
|
$pluginUrl = Inflector::underscore($plugin);
|
|
|
|
$url = $pluginUrl;
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$expected = $pluginUrl;
|
|
$this->assertIdentical($controller->plugin, $expected);
|
|
|
|
$expected = $plugin;
|
|
$this->assertIdentical($controller->name, $expected);
|
|
|
|
$expected = 'index';
|
|
$this->assertIdentical($controller->action, $expected);
|
|
|
|
$expected = $pluginUrl;
|
|
$this->assertEqual($controller->params['controller'], $expected);
|
|
|
|
|
|
Configure::write('Routing.prefixes', array('admin'));
|
|
|
|
Router::reload();
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'admin/my_plugin/add/5/param:value/param2:value2';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$expected = 'my_plugin';
|
|
$this->assertIdentical($controller->plugin, $expected);
|
|
|
|
$expected = 'MyPlugin';
|
|
$this->assertIdentical($controller->name, $expected);
|
|
|
|
$expected = 'admin_add';
|
|
$this->assertIdentical($controller->action, $expected);
|
|
|
|
$expected = array(0 => 5, 'param'=>'value', 'param2'=>'value2');
|
|
$this->assertEqual($controller->passedArgs, $expected);
|
|
|
|
Router::reload();
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$controller = $Dispatcher->dispatch('admin/articles_test', array('return' => 1));
|
|
|
|
$expected = 'articles_test';
|
|
$this->assertIdentical($controller->plugin, $expected);
|
|
|
|
$expected = 'ArticlesTest';
|
|
$this->assertIdentical($controller->name, $expected);
|
|
|
|
$expected = 'admin_index';
|
|
$this->assertIdentical($controller->action, $expected);
|
|
|
|
$expected = array(
|
|
'pass'=> array(), 'named' => array(), 'controller' => 'articles_test', 'plugin' => 'articles_test', 'action' => 'admin_index',
|
|
'prefix' => 'admin', 'admin' => true, 'form' => array(), 'url' => array('url' => 'admin/articles_test'), 'return' => 1
|
|
);
|
|
$this->assertEqual($controller->params, $expected);
|
|
}
|
|
|
|
/**
|
|
* test Plugin dispatching without controller name and using
|
|
* plugin short form instead.
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testAutomaticPluginDispatchWithShortAccess() {
|
|
$_POST = array();
|
|
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
|
|
|
|
Router::reload();
|
|
Router::connect('/my_plugin/:controller/:action/*', array('plugin' => 'my_plugin'));
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'my_plugin/';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertEqual($controller->params['controller'], 'my_plugin');
|
|
$this->assertEqual($controller->params['plugin'], 'my_plugin');
|
|
$this->assertEqual($controller->params['action'], 'index');
|
|
$this->assertFalse(isset($controller->params['pass'][0]));
|
|
|
|
$url = 'my_plugin/my_plugin/add';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertFalse(isset($controller->params['pass'][0]));
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'my_plugin/my_plugin/add/0';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertTrue(isset($controller->params['pass'][0]));
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'my_plugin/add';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertFalse(isset($controller->params['pass'][0]));
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'my_plugin/add/0';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertEqual($controller->params['controller'], 'my_plugin');
|
|
$this->assertEqual($controller->params['plugin'], 'my_plugin');
|
|
$this->assertEqual($controller->params['action'], 'add');
|
|
$this->assertIdentical('0', $controller->params['pass'][0]);
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'my_plugin/add/1';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$this->assertEqual($controller->params['controller'], 'my_plugin');
|
|
$this->assertEqual($controller->params['plugin'], 'my_plugin');
|
|
$this->assertEqual($controller->params['action'], 'add');
|
|
$this->assertIdentical('1', $controller->params['pass'][0]);
|
|
}
|
|
|
|
/**
|
|
* test plugin shortcut urls with controllers that need to be loaded,
|
|
* the above test uses a controller that has already been included.
|
|
*
|
|
* @return void
|
|
*/
|
|
function testPluginShortCutUrlsWithControllerThatNeedsToBeLoaded() {
|
|
$loaded = class_exists('TestPluginController', false);
|
|
if ($this->skipIf($loaded, 'TestPluginController already loaded, this test will always pass, skipping %s')) {
|
|
return true;
|
|
}
|
|
Router::reload();
|
|
App::build(array(
|
|
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
|
), true);
|
|
App::objects('plugin', null, false);
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'test_plugin/';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertEqual($controller->params['controller'], 'test_plugin');
|
|
$this->assertEqual($controller->params['plugin'], 'test_plugin');
|
|
$this->assertEqual($controller->params['action'], 'index');
|
|
$this->assertFalse(isset($controller->params['pass'][0]));
|
|
|
|
$url = '/test_plugin/tests/index';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertEqual($controller->params['controller'], 'tests');
|
|
$this->assertEqual($controller->params['plugin'], 'test_plugin');
|
|
$this->assertEqual($controller->params['action'], 'index');
|
|
$this->assertFalse(isset($controller->params['pass'][0]));
|
|
|
|
$url = '/test_plugin/tests/index/some_param';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertEqual($controller->params['controller'], 'tests');
|
|
$this->assertEqual($controller->params['plugin'], 'test_plugin');
|
|
$this->assertEqual($controller->params['action'], 'index');
|
|
$this->assertEqual($controller->params['pass'][0], 'some_param');
|
|
|
|
App::build();
|
|
}
|
|
|
|
/**
|
|
* testAutomaticPluginControllerMissingActionDispatch method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testAutomaticPluginControllerMissingActionDispatch() {
|
|
$_POST = array();
|
|
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
|
|
|
|
Router::reload();
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'my_plugin/not_here/param:value/param2:value2';
|
|
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
|
|
|
|
$expected = array('missingAction', array(array(
|
|
'className' => 'MyPluginController',
|
|
'action' => 'not_here',
|
|
'webroot' => '/cake/repo/branches/1.2.x.x/',
|
|
'url' => '/cake/repo/branches/1.2.x.x/my_plugin/not_here/param:value/param2:value2',
|
|
'base' => '/cake/repo/branches/1.2.x.x'
|
|
)));
|
|
$this->assertIdentical($expected, $controller);
|
|
|
|
Router::reload();
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'my_plugin/param:value/param2:value2';
|
|
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
|
|
|
|
$expected = array('missingAction', array(array(
|
|
'className' => 'MyPluginController',
|
|
'action' => 'param:value',
|
|
'webroot' => '/cake/repo/branches/1.2.x.x/',
|
|
'url' => '/cake/repo/branches/1.2.x.x/my_plugin/param:value/param2:value2',
|
|
'base' => '/cake/repo/branches/1.2.x.x'
|
|
)));
|
|
$this->assertIdentical($expected, $controller);
|
|
}
|
|
|
|
/**
|
|
* testPrefixProtection method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testPrefixProtection() {
|
|
$_POST = array();
|
|
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
|
|
|
|
Router::reload();
|
|
Router::connect('/admin/:controller/:action/*', array('prefix'=>'admin'), array('controller', 'action'));
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
$Dispatcher->base = false;
|
|
|
|
$url = 'test_dispatch_pages/admin_index/param:value/param2:value2';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$expected = array('privateAction', array(array(
|
|
'className' => 'TestDispatchPagesController',
|
|
'action' => 'admin_index',
|
|
'webroot' => '/cake/repo/branches/1.2.x.x/',
|
|
'url' => 'test_dispatch_pages/admin_index/param:value/param2:value2',
|
|
'base' => '/cake/repo/branches/1.2.x.x'
|
|
)));
|
|
$this->assertIdentical($expected, $controller);
|
|
}
|
|
|
|
/**
|
|
* Test dispatching into the TestPlugin in the test_app
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testTestPluginDispatch() {
|
|
$Dispatcher =& new TestDispatcher();
|
|
App::build(array(
|
|
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
|
));
|
|
App::objects('plugin', null, false);
|
|
Router::reload();
|
|
Router::parse('/');
|
|
|
|
$url = '/test_plugin/tests/index';
|
|
$result = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$this->assertTrue(class_exists('TestsController'));
|
|
$this->assertTrue(class_exists('TestPluginAppController'));
|
|
$this->assertTrue(class_exists('OtherComponentComponent'));
|
|
$this->assertTrue(class_exists('PluginsComponentComponent'));
|
|
|
|
$this->assertEqual($result->params['controller'], 'tests');
|
|
$this->assertEqual($result->params['plugin'], 'test_plugin');
|
|
$this->assertEqual($result->params['action'], 'index');
|
|
|
|
App::build();
|
|
}
|
|
|
|
/**
|
|
* testChangingParamsFromBeforeFilter method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testChangingParamsFromBeforeFilter() {
|
|
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
|
|
$Dispatcher =& new TestDispatcher();
|
|
$url = 'some_posts/index/param:value/param2:value2';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$expected = array('missingAction', array(array(
|
|
'className' => 'SomePostsController',
|
|
'action' => 'view',
|
|
'webroot' => '/cake/repo/branches/1.2.x.x/',
|
|
'url' => '/cake/repo/branches/1.2.x.x/some_posts/index/param:value/param2:value2',
|
|
'base' => '/cake/repo/branches/1.2.x.x'
|
|
)));
|
|
$this->assertEqual($expected, $controller);
|
|
|
|
$url = 'some_posts/something_else/param:value/param2:value2';
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
|
|
$expected = 'SomePosts';
|
|
$this->assertEqual($expected, $controller->name);
|
|
|
|
$expected = 'change';
|
|
$this->assertEqual($expected, $controller->action);
|
|
|
|
$expected = array('changed');
|
|
$this->assertIdentical($expected, $controller->params['pass']);
|
|
}
|
|
|
|
/**
|
|
* testStaticAssets method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testAssets() {
|
|
Router::reload();
|
|
$Configure = Configure::getInstance();
|
|
$Configure->__objects = null;
|
|
|
|
App::build(array(
|
|
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
|
|
'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
|
|
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
|
));
|
|
|
|
$Dispatcher =& new TestDispatcher();
|
|
$debug = Configure::read('debug');
|
|
Configure::write('debug', 0);
|
|
|
|
ob_start();
|
|
$Dispatcher->dispatch('theme/test_theme/../webroot/css/test_asset.css');
|
|
$result = ob_get_clean();
|
|
$this->assertFalse($result);
|
|
|
|
ob_start();
|
|
$Dispatcher->dispatch('theme/test_theme/pdfs');
|
|
$result = ob_get_clean();
|
|
$this->assertFalse($result);
|
|
|
|
ob_start();
|
|
$Dispatcher->dispatch('theme/test_theme/flash/theme_test.swf');
|
|
$result = ob_get_clean();
|
|
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'flash' . DS . 'theme_test.swf');
|
|
$this->assertEqual($file, $result);
|
|
$this->assertEqual('this is just a test to load swf file from the theme.', $result);
|
|
|
|
ob_start();
|
|
$Dispatcher->dispatch('theme/test_theme/pdfs/theme_test.pdf');
|
|
$result = ob_get_clean();
|
|
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'pdfs' . DS . 'theme_test.pdf');
|
|
$this->assertEqual($file, $result);
|
|
$this->assertEqual('this is just a test to load pdf file from the theme.', $result);
|
|
|
|
ob_start();
|
|
$Dispatcher->dispatch('theme/test_theme/img/test.jpg');
|
|
$result = ob_get_clean();
|
|
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'img' . DS . 'test.jpg');
|
|
$this->assertEqual($file, $result);
|
|
|
|
$Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/css/test_asset.css');
|
|
ob_start();
|
|
$Dispatcher->asset('theme/test_theme/css/test_asset.css');
|
|
$result = ob_get_clean();
|
|
$this->assertEqual('this is the test asset css file', $result);
|
|
|
|
$Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/js/theme.js');
|
|
ob_start();
|
|
$Dispatcher->asset('theme/test_theme/js/theme.js');
|
|
$result = ob_get_clean();
|
|
$this->assertEqual('root theme js file', $result);
|
|
|
|
$Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/js/one/theme_one.js');
|
|
ob_start();
|
|
$Dispatcher->asset('theme/test_theme/js/one/theme_one.js');
|
|
$result = ob_get_clean();
|
|
$this->assertEqual('nested theme js file', $result);
|
|
|
|
ob_start();
|
|
$Dispatcher->dispatch('test_plugin/flash/plugin_test.swf');
|
|
$result = ob_get_clean();
|
|
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'flash' . DS . 'plugin_test.swf');
|
|
$this->assertEqual($file, $result);
|
|
$this->assertEqual('this is just a test to load swf file from the plugin.', $result);
|
|
|
|
ob_start();
|
|
$Dispatcher->dispatch('test_plugin/pdfs/plugin_test.pdf');
|
|
$result = ob_get_clean();
|
|
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'pdfs' . DS . 'plugin_test.pdf');
|
|
$this->assertEqual($file, $result);
|
|
$this->assertEqual('this is just a test to load pdf file from the plugin.', $result);
|
|
|
|
ob_start();
|
|
$Dispatcher->asset('test_plugin/js/test_plugin/test.js');
|
|
$result = ob_get_clean();
|
|
$this->assertEqual('alert("Test App");', $result);
|
|
|
|
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/js/test_plugin/test.js');
|
|
ob_start();
|
|
$Dispatcher->asset('test_plugin/js/test_plugin/test.js');
|
|
$result = ob_get_clean();
|
|
$this->assertEqual('alert("Test App");', $result);
|
|
|
|
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/test_plugin_asset.css');
|
|
ob_start();
|
|
$Dispatcher->asset('test_plugin/css/test_plugin_asset.css');
|
|
$result = ob_get_clean();
|
|
$this->assertEqual('this is the test plugin asset css file', $result);
|
|
|
|
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/img/cake.icon.gif');
|
|
ob_start();
|
|
$Dispatcher->asset('test_plugin/img/cake.icon.gif');
|
|
$result = ob_get_clean();
|
|
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' .DS . 'webroot' . DS . 'img' . DS . 'cake.icon.gif');
|
|
$this->assertEqual($file, $result);
|
|
|
|
$Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/plugin_js.js');
|
|
ob_start();
|
|
$Dispatcher->asset('plugin_js/js/plugin_js.js');
|
|
$result = ob_get_clean();
|
|
$expected = "alert('win sauce');";
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/one/plugin_one.js');
|
|
ob_start();
|
|
$Dispatcher->asset('plugin_js/js/one/plugin_one.js');
|
|
$result = ob_get_clean();
|
|
$expected = "alert('plugin one nested js file');";
|
|
$this->assertEqual($result, $expected);
|
|
Configure::write('debug', $debug);
|
|
//reset the header content-type without page can render as plain text.
|
|
header('Content-type: text/html');
|
|
|
|
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/theme_one.htc');
|
|
ob_start();
|
|
$Dispatcher->asset('test_plugin/css/unknown.extension');
|
|
$result = ob_get_clean();
|
|
$this->assertEqual('Testing a file with unknown extension to mime mapping.', $result);
|
|
header('Content-type: text/html');
|
|
|
|
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/theme_one.htc');
|
|
ob_start();
|
|
$Dispatcher->asset('test_plugin/css/theme_one.htc');
|
|
$result = ob_get_clean();
|
|
$this->assertEqual('htc file', $result);
|
|
header('Content-type: text/html');
|
|
}
|
|
|
|
/**
|
|
* testFullPageCachingDispatch method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testFullPageCachingDispatch() {
|
|
Configure::write('Cache.disable', false);
|
|
Configure::write('Cache.check', true);
|
|
Configure::write('debug', 2);
|
|
|
|
$_POST = array();
|
|
$_SERVER['PHP_SELF'] = '/';
|
|
|
|
Router::reload();
|
|
Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index'));
|
|
|
|
App::build(array(
|
|
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
|
|
), true);
|
|
|
|
$dispatcher =& new TestDispatcher();
|
|
$dispatcher->base = false;
|
|
|
|
$url = '/';
|
|
|
|
ob_start();
|
|
$dispatcher->dispatch($url);
|
|
$out = ob_get_clean();
|
|
|
|
ob_start();
|
|
$dispatcher->cached($url);
|
|
$cached = ob_get_clean();
|
|
|
|
$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
|
|
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
|
|
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$filename = $this->__cachePath($dispatcher->here);
|
|
unlink($filename);
|
|
|
|
$dispatcher->base = false;
|
|
$url = 'test_cached_pages/index';
|
|
|
|
ob_start();
|
|
$dispatcher->dispatch($url);
|
|
$out = ob_get_clean();
|
|
|
|
ob_start();
|
|
$dispatcher->cached($url);
|
|
$cached = ob_get_clean();
|
|
|
|
$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
|
|
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
|
|
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
$filename = $this->__cachePath($dispatcher->here);
|
|
unlink($filename);
|
|
|
|
$url = 'TestCachedPages/index';
|
|
|
|
ob_start();
|
|
$dispatcher->dispatch($url);
|
|
$out = ob_get_clean();
|
|
|
|
ob_start();
|
|
$dispatcher->cached($url);
|
|
$cached = ob_get_clean();
|
|
|
|
$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
|
|
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
|
|
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
$filename = $this->__cachePath($dispatcher->here);
|
|
unlink($filename);
|
|
|
|
$url = 'TestCachedPages/test_nocache_tags';
|
|
|
|
ob_start();
|
|
$dispatcher->dispatch($url);
|
|
$out = ob_get_clean();
|
|
|
|
ob_start();
|
|
$dispatcher->cached($url);
|
|
$cached = ob_get_clean();
|
|
|
|
$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
|
|
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
|
|
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
$filename = $this->__cachePath($dispatcher->here);
|
|
unlink($filename);
|
|
|
|
$url = 'test_cached_pages/view/param/param';
|
|
|
|
ob_start();
|
|
$dispatcher->dispatch($url);
|
|
$out = ob_get_clean();
|
|
|
|
ob_start();
|
|
$dispatcher->cached($url);
|
|
$cached = ob_get_clean();
|
|
|
|
$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
|
|
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
|
|
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
$filename = $this->__cachePath($dispatcher->here);
|
|
unlink($filename);
|
|
|
|
$url = 'test_cached_pages/view/foo:bar/value:goo';
|
|
|
|
ob_start();
|
|
$dispatcher->dispatch($url);
|
|
$out = ob_get_clean();
|
|
|
|
ob_start();
|
|
$dispatcher->cached($url);
|
|
$cached = ob_get_clean();
|
|
|
|
$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
|
|
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
|
|
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
$filename = $this->__cachePath($dispatcher->here);
|
|
$this->assertTrue(file_exists($filename));
|
|
unlink($filename);
|
|
}
|
|
|
|
/**
|
|
* test that cached() registers a view and un-registers it. Tests
|
|
* that helpers using ClassRegistry::getObject('view'); don't fail
|
|
*
|
|
* @return void
|
|
*/
|
|
function testCachedRegisteringViewObject() {
|
|
Configure::write('Cache.disable', false);
|
|
Configure::write('Cache.check', true);
|
|
Configure::write('debug', 2);
|
|
|
|
$_POST = array();
|
|
$_SERVER['PHP_SELF'] = '/';
|
|
|
|
Router::reload();
|
|
App::build(array(
|
|
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
|
));
|
|
|
|
$dispatcher =& new TestDispatcher();
|
|
$dispatcher->base = false;
|
|
|
|
$url = 'test_cached_pages/cache_form';
|
|
ob_start();
|
|
$dispatcher->dispatch($url);
|
|
$out = ob_get_clean();
|
|
|
|
ClassRegistry::flush();
|
|
|
|
ob_start();
|
|
$dispatcher->cached($url);
|
|
$cached = ob_get_clean();
|
|
|
|
$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
|
|
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
|
|
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
$filename = $this->__cachePath($dispatcher->here);
|
|
@unlink($filename);
|
|
ClassRegistry::flush();
|
|
}
|
|
|
|
/**
|
|
* testHttpMethodOverrides method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testHttpMethodOverrides() {
|
|
Router::reload();
|
|
Router::mapResources('Posts');
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
$dispatcher =& new Dispatcher();
|
|
$dispatcher->base = false;
|
|
|
|
$result = $dispatcher->parseParams('/posts');
|
|
$expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST', 'form' => array(), 'url' => array());
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'GET';
|
|
$_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT';
|
|
|
|
$result = $dispatcher->parseParams('/posts/5');
|
|
$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'form' => array(), 'url' => array());
|
|
$this->assertEqual($result, $expected);
|
|
|
|
unset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
|
|
$_SERVER['REQUEST_METHOD'] = 'GET';
|
|
|
|
$result = $dispatcher->parseParams('/posts/5');
|
|
$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'view', '[method]' => 'GET', 'form' => array(), 'url' => array());
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$_POST['_method'] = 'PUT';
|
|
|
|
$result = $dispatcher->parseParams('/posts/5');
|
|
$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'form' => array(), 'url' => array());
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$_POST['_method'] = 'POST';
|
|
$_POST['data'] = array('Post' => array('title' => 'New Post'));
|
|
$_POST['extra'] = 'data';
|
|
$_SERVER = array();
|
|
|
|
$result = $dispatcher->parseParams('/posts');
|
|
$expected = array(
|
|
'pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add',
|
|
'[method]' => 'POST', 'form' => array('extra' => 'data'), 'data' => array('Post' => array('title' => 'New Post')),
|
|
'url' => array()
|
|
);
|
|
$this->assertEqual($result, $expected);
|
|
|
|
unset($_POST['_method']);
|
|
}
|
|
|
|
/**
|
|
* Tests that invalid characters cannot be injected into the application base path.
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testBasePathInjection() {
|
|
$self = $_SERVER['PHP_SELF'];
|
|
$_SERVER['PHP_SELF'] = urldecode(
|
|
"/index.php/%22%3E%3Ch1%20onclick=%22alert('xss');%22%3Eheya%3C/h1%3E"
|
|
);
|
|
|
|
$dispatcher =& new Dispatcher();
|
|
$result = $dispatcher->baseUrl();
|
|
$expected = '/index.php/h1 onclick=alert(xss);heya';
|
|
$this->assertEqual($result, $expected);
|
|
}
|
|
|
|
/**
|
|
* testEnvironmentDetection method
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testEnvironmentDetection() {
|
|
$dispatcher =& new Dispatcher();
|
|
|
|
$environments = array(
|
|
'IIS' => array(
|
|
'No rewrite base path' => array(
|
|
'App' => array('base' => false, 'baseUrl' => '/index.php?', 'server' => 'IIS'),
|
|
'SERVER' => array('HTTPS' => 'off', 'SCRIPT_NAME' => '/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', 'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_HOST' => '127.0.0.1', 'REQUEST_METHOD' => 'GET', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_SOFTWARE' => 'Microsoft-IIS/5.1', 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'ORIG_PATH_INFO' => '/index.php', 'PATH_INFO' => '', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', 'HTTP_ACCEPT' => '*/*', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_CONNECTION' => 'Keep-Alive', 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'argv' => array(), 'argc' => 0),
|
|
'reload' => true,
|
|
'path' => ''
|
|
),
|
|
'No rewrite with path' => array(
|
|
'SERVER' => array('QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/index.php?/posts/add', 'URL' => '/index.php?/posts/add', 'argv' => array('/posts/add'), 'argc' => 1),
|
|
'reload' => false,
|
|
'path' => '/posts/add'
|
|
),
|
|
'No rewrite sub dir 1' => array(
|
|
'GET' => array(),
|
|
'SERVER' => array('QUERY_STRING' => '', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'ORIG_PATH_INFO' => '/index.php', 'PATH_INFO' => '', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', 'argv' => array(), 'argc' => 0),
|
|
'reload' => false,
|
|
'path' => ''
|
|
),
|
|
'No rewrite sub dir 1 with path' => array(
|
|
'GET' => array('/posts/add' => ''),
|
|
'SERVER' => array('QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/index.php?/posts/add', 'URL' => '/index.php?/posts/add', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'argv' => array('/posts/add'), 'argc' => 1),
|
|
'reload' => false,
|
|
'path' => '/posts/add'
|
|
),
|
|
'No rewrite sub dir 2' => array(
|
|
'App' => array('base' => false, 'baseUrl' => '/site/index.php?', 'dir' => 'app', 'webroot' => 'webroot', 'server' => 'IIS'),
|
|
'GET' => array(),
|
|
'POST' => array(),
|
|
'SERVER' => array('SCRIPT_NAME' => '/site/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', 'REQUEST_URI' => '/site/index.php', 'URL' => '/site/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/site/index.php', 'argv' => array(), 'argc' => 0),
|
|
'reload' => false,
|
|
'path' => ''
|
|
),
|
|
'No rewrite sub dir 2 with path' => array(
|
|
'GET' => array('/posts/add' => ''),
|
|
'SERVER' => array('SCRIPT_NAME' => '/site/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/site/index.php?/posts/add', 'URL' => '/site/index.php?/posts/add', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/site/index.php', 'argv' => array('/posts/add'), 'argc' => 1),
|
|
'reload' => false,
|
|
'path' => '/posts/add'
|
|
)
|
|
),
|
|
'Apache' => array(
|
|
'No rewrite base path' => array(
|
|
'App' => array('base' => false, 'baseUrl' => '/index.php', 'dir' => 'app', 'webroot' => 'webroot'),
|
|
'SERVER' => array('SERVER_NAME' => 'localhost', 'SERVER_ADDR' => '::1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '::1', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => '', 'REQUEST_URI' => '/', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php', 'argv' => array(), 'argc' => 0),
|
|
'reload' => true,
|
|
'path' => ''
|
|
),
|
|
'No rewrite with path' => array(
|
|
'SERVER' => array('UNIQUE_ID' => 'VardGqn@17IAAAu7LY8AAAAK', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/523.10.5 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6', 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/officespace/app/webroot/index.php', 'QUERY_STRING' => '', 'REQUEST_URI' => '/index.php/posts/add', 'SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/posts/add', 'PHP_SELF' => '/index.php/posts/add', 'argv' => array(), 'argc' => 0),
|
|
'reload' => false,
|
|
'path' => '/posts/add'
|
|
),
|
|
'GET Request at base domain' => array(
|
|
'App' => array('base' => false, 'baseUrl' => null, 'dir' => 'app', 'webroot' => 'webroot'),
|
|
'SERVER' => array('UNIQUE_ID' => '2A-v8sCoAQ8AAAc-2xUAAAAB', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_COOKIE' => 'CAKEPHP=jcbv51apn84kd9ucv5aj2ln3t3', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'cake.1.2', 'SERVER_NAME' => 'cake.1.2', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot', 'SERVER_ADMIN' => 'you@example.com', 'SCRIPT_FILENAME' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot/index.php', 'REMOTE_PORT' => '53550', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => 'a=b', 'REQUEST_URI' => '/?a=b', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php'),
|
|
'GET' => array('a' => 'b'),
|
|
'POST' => array(),
|
|
'reload' => true,
|
|
'path' => '',
|
|
'urlParams' => array('a' => 'b'),
|
|
'environment' => array('CGI_MODE' => false)
|
|
),
|
|
'New CGI no mod_rewrite' => array(
|
|
'App' => array('base' => false, 'baseUrl' => '/limesurvey20/index.php', 'dir' => 'app', 'webroot' => 'webroot'),
|
|
'SERVER' => array('DOCUMENT_ROOT' => '/home/.sites/110/site313/web', 'PATH_INFO' => '/installations', 'PATH_TRANSLATED' => '/home/.sites/110/site313/web/limesurvey20/index.php', 'PHPRC' => '/home/.sites/110/site313', 'QUERY_STRING' => '', 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/limesurvey20/index.php/installations', 'SCRIPT_FILENAME' => '/home/.sites/110/site313/web/limesurvey20/index.php', 'SCRIPT_NAME' => '/limesurvey20/index.php', 'SCRIPT_URI' => 'http://www.gisdat-umfragen.at/limesurvey20/index.php/installations', 'PHP_SELF' => '/limesurvey20/index.php/installations', 'CGI_MODE' => true),
|
|
'GET' => array(),
|
|
'POST' => array(),
|
|
'reload' => true,
|
|
'path' => '/installations',
|
|
'urlParams' => array(),
|
|
'environment' => array('CGI_MODE' => true)
|
|
)
|
|
)
|
|
);
|
|
$backup = $this->__backupEnvironment();
|
|
|
|
foreach ($environments as $name => $env) {
|
|
foreach ($env as $descrip => $settings) {
|
|
if ($settings['reload']) {
|
|
$this->__reloadEnvironment();
|
|
}
|
|
$this->__loadEnvironment($settings);
|
|
$this->assertEqual($dispatcher->uri(), $settings['path'], "%s on environment: {$name}, on setting: {$descrip}");
|
|
|
|
if (isset($settings['urlParams'])) {
|
|
$this->assertEqual($_GET, $settings['urlParams'], "%s on environment: {$name}, on setting: {$descrip}");
|
|
}
|
|
if (isset($settings['environment'])) {
|
|
foreach ($settings['environment'] as $key => $val) {
|
|
$this->assertEqual(env($key), $val, "%s on key {$key} on environment: {$name}, on setting: {$descrip}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$this->__loadEnvironment(array_merge(array('reload' => true), $backup));
|
|
}
|
|
|
|
/**
|
|
* Tests that the Dispatcher does not return an empty action
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function testTrailingSlash() {
|
|
$_POST = array();
|
|
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
|
|
|
|
Router::reload();
|
|
$Dispatcher =& new TestDispatcher();
|
|
Router::connect('/myalias/:action/*', array('controller' => 'my_controller', 'action' => null));
|
|
|
|
$Dispatcher->base = false;
|
|
$url = 'myalias/'; //Fails
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$result = $Dispatcher->parseParams($url);
|
|
$this->assertEqual('index', $result['action']);
|
|
|
|
$url = 'myalias'; //Passes
|
|
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
|
$result = $Dispatcher->parseParams($url);
|
|
$this->assertEqual('index', $result['action']);
|
|
}
|
|
|
|
/**
|
|
* backupEnvironment method
|
|
*
|
|
* @return void
|
|
* @access private
|
|
*/
|
|
function __backupEnvironment() {
|
|
return array(
|
|
'App' => Configure::read('App'),
|
|
'GET' => $_GET,
|
|
'POST' => $_POST,
|
|
'SERVER'=> $_SERVER
|
|
);
|
|
}
|
|
|
|
/**
|
|
* reloadEnvironment method
|
|
*
|
|
* @return void
|
|
* @access private
|
|
*/
|
|
function __reloadEnvironment() {
|
|
foreach ($_GET as $key => $val) {
|
|
unset($_GET[$key]);
|
|
}
|
|
foreach ($_POST as $key => $val) {
|
|
unset($_POST[$key]);
|
|
}
|
|
foreach ($_SERVER as $key => $val) {
|
|
unset($_SERVER[$key]);
|
|
}
|
|
Configure::write('App', array());
|
|
}
|
|
|
|
/**
|
|
* loadEnvironment method
|
|
*
|
|
* @param mixed $env
|
|
* @return void
|
|
* @access private
|
|
*/
|
|
function __loadEnvironment($env) {
|
|
if ($env['reload']) {
|
|
$this->__reloadEnvironment();
|
|
}
|
|
|
|
if (isset($env['App'])) {
|
|
Configure::write('App', $env['App']);
|
|
}
|
|
|
|
if (isset($env['GET'])) {
|
|
foreach ($env['GET'] as $key => $val) {
|
|
$_GET[$key] = $val;
|
|
}
|
|
}
|
|
|
|
if (isset($env['POST'])) {
|
|
foreach ($env['POST'] as $key => $val) {
|
|
$_POST[$key] = $val;
|
|
}
|
|
}
|
|
|
|
if (isset($env['SERVER'])) {
|
|
foreach ($env['SERVER'] as $key => $val) {
|
|
$_SERVER[$key] = $val;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* cachePath method
|
|
*
|
|
* @param mixed $her
|
|
* @return string
|
|
* @access private
|
|
*/
|
|
function __cachePath($here) {
|
|
$path = $here;
|
|
if ($here == '/') {
|
|
$path = 'home';
|
|
}
|
|
$path = strtolower(Inflector::slug($path));
|
|
|
|
$filename = CACHE . 'views' . DS . $path . '.php';
|
|
|
|
if (!file_exists($filename)) {
|
|
$filename = CACHE . 'views' . DS . $path . '_index.php';
|
|
}
|
|
return $filename;
|
|
}
|
|
}
|
|
?>
|