mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-16 03:48:24 +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
1363 lines
No EOL
57 KiB
PHP
1363 lines
No EOL
57 KiB
PHP
<?php
|
|
/**
|
|
* XmlTest 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.libs
|
|
* @since CakePHP(tm) v 1.2.0.5432
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
*/
|
|
App::import('Core', 'Xml');
|
|
|
|
/**
|
|
* XmlTest class
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.tests.cases.libs
|
|
*/
|
|
class XmlTest extends CakeTestCase {
|
|
|
|
/**
|
|
* setUp method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function setUp() {
|
|
$manager =& new XmlManager();
|
|
$manager->namespaces = array();
|
|
}
|
|
|
|
/**
|
|
* testRootTagParsing method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testRootTagParsing() {
|
|
$input = '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . "\n" .
|
|
'<plugin id="1" version_id="1" name="my_plugin" title="My Plugin" author="Me" author_email="me@cakephp.org" description="My awesome package" created="2008-01-28 18:21:13" updated="2008-01-28 18:21:13">'
|
|
.'<current id="1" plugin_id="1" name="1.0" file="" created="2008-01-28 18:21:13" updated="2008-01-28 18:21:13" />'
|
|
.'<version id="1" plugin_id="1" name="1.0" file="" created="2008-01-28 18:21:13" updated="2008-01-28 18:21:13" />'
|
|
.'</plugin>';
|
|
$xml = new Xml($input);
|
|
$this->assertEqual($xml->children[0]->name, 'plugin');
|
|
$this->assertEqual($xml->children[0]->children[0]->name, 'current');
|
|
$this->assertEqual($xml->toString(true), $input);
|
|
}
|
|
|
|
/**
|
|
* testSerialization method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testSerialization() {
|
|
$input = array(
|
|
array(
|
|
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial')
|
|
),
|
|
array(
|
|
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
|
|
'Industry' => array('id' => 2, 'name' => 'Education')
|
|
)
|
|
);
|
|
|
|
$xml = new Xml($input);
|
|
$result = preg_replace("/\n/",'', $xml->toString(false));
|
|
$expected = '<project id="1" title="" client_id="1" show="1" is_spotlight="" style_id="0" job_type_id="1" industry_id="1" modified="" created=""><style id="" name="" /><job_type id="1" name="Touch Screen Kiosk" /><industry id="1" name="Financial" /></project><project id="2" title="" client_id="2" show="1" is_spotlight="" style_id="0" job_type_id="2" industry_id="2" modified="2007-11-26 14:48:36" created=""><style id="" name="" /><job_type id="2" name="Awareness Campaign" /><industry id="2" name="Education" /></project>';
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$input = array(
|
|
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial')
|
|
);
|
|
$expected = '<project id="1" title="" client_id="1" show="1" is_spotlight="" style_id="0" job_type_id="1" industry_id="1" modified="" created=""><style id="" name="" /><job_type id="1" name="Touch Screen Kiosk" /><industry id="1" name="Financial" /></project>';
|
|
$xml = new Xml($input);
|
|
$result = preg_replace("/\n/",'', $xml->toString(false));
|
|
$this->assertEqual($result, $expected);
|
|
}
|
|
|
|
/**
|
|
* testSerializeOnMultiDimensionalArray method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testSerializeOnMultiDimensionalArray() {
|
|
$data = array(
|
|
'Statuses' => array(
|
|
array('Status' => array('id' => 1)),
|
|
array('Status' => array('id' => 2))
|
|
)
|
|
);
|
|
$result =& new Xml($data, array('format' => 'tags'));
|
|
$expected = '<statuses><status><id>1</id></status><status><id>2</id></status></statuses>';
|
|
$this->assertIdentical($result->toString(), $expected);
|
|
}
|
|
|
|
/**
|
|
* test serialization of boolean and null values. false = 0, true = 1, null = ''
|
|
*
|
|
* @return void
|
|
*/
|
|
function testSerializationOfBooleanAndBooleanishValues() {
|
|
$xml =& new Xml(array('data' => array('example' => false)));
|
|
$result = $xml->toString(false);
|
|
$expected = '<data example="0" />';
|
|
$this->assertEqual($result, $expected, 'Boolean values incorrectly handled. %s');
|
|
|
|
$xml =& new Xml(array('data' => array('example' => true)));
|
|
$result = $xml->toString(false);
|
|
$expected = '<data example="1" />';
|
|
$this->assertEqual($result, $expected, 'Boolean values incorrectly handled. %s');
|
|
|
|
$xml =& new Xml(array('data' => array('example' => null)));
|
|
$result = $xml->toString(false);
|
|
$expected = '<data example="" />';
|
|
$this->assertEqual($result, $expected, 'Boolean values incorrectly handled. %s');
|
|
|
|
$xml =& new Xml(array('data' => array('example' => 0)));
|
|
$result = $xml->toString(false);
|
|
$expected = '<data example="0" />';
|
|
$this->assertEqual($result, $expected, 'Boolean-ish values incorrectly handled. %s');
|
|
|
|
$xml =& new Xml(array('data' => array('example' => 1)));
|
|
$result = $xml->toString(false);
|
|
$expected = '<data example="1" />';
|
|
$this->assertEqual($result, $expected, 'Boolean-ish values incorrectly handled. %s');
|
|
}
|
|
|
|
/**
|
|
* testSimpleArray method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testSimpleArray() {
|
|
$xml = new Xml(array('hello' => 'world'), array('format' => 'tags'));
|
|
|
|
$result = $xml->toString(false);
|
|
$expected = '<hello><![CDATA[world]]></hello>';
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* testSimpleObject method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testSimpleObject() {
|
|
$input = new StdClass();
|
|
$input->hello = 'world';
|
|
$xml = new Xml($input, array('format' => 'tags'));
|
|
|
|
$result = $xml->toString(false);
|
|
$expected = '<hello><![CDATA[world]]></hello>';
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* testSimpleArrayWithZeroValues method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testSimpleArrayWithZeroValues() {
|
|
$xml = new Xml(array('zero_string' => '0', 'zero_integer' => 0), array('format' => 'tags'));
|
|
|
|
$result = $xml->toString(false);
|
|
$expected = '<zero_string>0</zero_string><zero_integer>0</zero_integer>';
|
|
$this->assertEqual($expected, $result);
|
|
|
|
$data = array(
|
|
'Client' => array(
|
|
'id' => 3,
|
|
'object_id' => 9,
|
|
'key' => 'alt',
|
|
'name' => 'Client Two',
|
|
'created_by' => 4,
|
|
'status' => '0',
|
|
'num_projects' => 0
|
|
)
|
|
);
|
|
$xml = new Xml($data, array('format' => 'tags'));
|
|
$result = $xml->toString(array('format' => 'tags', 'header' => false));
|
|
$this->assertPattern('/<status>0<\/status>/', $result);
|
|
$this->assertPattern('/<num_projects>0<\/num_projects>/', $result);
|
|
}
|
|
/**
|
|
* testHeader method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testHeader() {
|
|
$input = new stdClass();
|
|
$input->hello = 'world';
|
|
$xml = new Xml($input, array('format' => 'tags'));
|
|
|
|
$result = $xml->toString(array('header' => true));
|
|
$expected = '<'.'?xml version="1.0" encoding="UTF-8" ?'.'>'."\n".'<hello><![CDATA[world]]></hello>';
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* testOwnerAssignment method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testOwnerAssignment() {
|
|
$xml = new Xml();
|
|
$node =& $xml->createElement('hello', 'world');
|
|
$owner =& $node->document();
|
|
$this->assertTrue($xml === $owner);
|
|
|
|
$children =& $node->children;
|
|
$childOwner =& $children[0]->document();
|
|
$this->assertTrue($xml === $childOwner);
|
|
}
|
|
|
|
/**
|
|
* testArraySingleSerialization method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testArraySingleSerialization() {
|
|
$input = array(
|
|
'Post' => array(
|
|
'id' => '1', 'author_id' => '1', 'title' => 'First Post',
|
|
'body' => 'First Post Body', 'published' => 'Y',
|
|
'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
|
),
|
|
'Author' => array(
|
|
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
|
|
'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working'
|
|
)
|
|
);
|
|
|
|
$expected = '<post><id>1</id><author_id>1</author_id><title><![CDATA[First Post]]>';
|
|
$expected .= '</title><body><![CDATA[First Post Body]]></body><published><![CDATA[Y]]>';
|
|
$expected .= '</published><created><![CDATA[2007-03-18 10:39:23]]></created><updated>';
|
|
$expected .= '<![CDATA[2007-03-18 10:41:31]]></updated><author><id>1</id><user>';
|
|
$expected .= '<![CDATA[mariano]]></user><password><![CDATA[5f4dcc3b5aa765d61d8327deb882';
|
|
$expected .= 'cf99]]></password><created><![CDATA[2007-03-17 01:16:23]]></created>';
|
|
$expected .= '<updated><![CDATA[2007-03-17 01:18:31]]></updated><test><![CDATA[working]]>';
|
|
$expected .= '</test></author></post>';
|
|
|
|
$xml = new Xml($input, array('format' => 'tags'));
|
|
$result = $xml->toString(false);
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* testArraySerialization method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testSerializationArray() {
|
|
$input = array(
|
|
array(
|
|
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial')
|
|
),
|
|
array(
|
|
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
|
|
'Industry' => array('id' => 2, 'name' => 'Education'),
|
|
)
|
|
);
|
|
$expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project>';
|
|
|
|
$xml = new Xml($input, array('format' => 'tags'));
|
|
$result = $xml->toString(array('header' => false, 'cdata' => false));
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* testNestedArraySerialization method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testSerializationNestedArray() {
|
|
$input = array(
|
|
array(
|
|
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial'),
|
|
'BusinessSolution' => array(array('id' => 6, 'name' => 'Convert Sales')),
|
|
'MediaType' => array(
|
|
array('id' => 15, 'name' => 'Print'),
|
|
array('id' => 7, 'name' => 'Web Demo'),
|
|
array('id' => 6, 'name' => 'CD-ROM')
|
|
)
|
|
),
|
|
array(
|
|
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
|
|
'Industry' => array('id' => 2, 'name' => 'Education'),
|
|
'BusinessSolution' => array(
|
|
array('id' => 4, 'name' => 'Build Relationship'),
|
|
array('id' => 6, 'name' => 'Convert Sales')
|
|
),
|
|
'MediaType' => array(
|
|
array('id' => 17, 'name' => 'Web'),
|
|
array('id' => 6, 'name' => 'CD-ROM')
|
|
)
|
|
)
|
|
);
|
|
$expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry><business_solution><id>6</id><name>Convert Sales</name></business_solution><media_type><id>15</id><name>Print</name></media_type><media_type><id>7</id><name>Web Demo</name></media_type><media_type><id>6</id><name>CD-ROM</name></media_type></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry><business_solution><id>4</id><name>Build Relationship</name></business_solution><business_solution><id>6</id><name>Convert Sales</name></business_solution><media_type><id>17</id><name>Web</name></media_type><media_type><id>6</id><name>CD-ROM</name></media_type></project>';
|
|
|
|
$xml = new Xml($input, array('format' => 'tags'));
|
|
$result = $xml->toString(array('header' => false, 'cdata' => false));
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* Prove that serialization with a given root node works
|
|
* as expected.
|
|
*
|
|
* @access public
|
|
* @return void
|
|
* @link https://trac.cakephp.org/ticket/6294
|
|
*/
|
|
function testArraySerializationWithRoot() {
|
|
$input = array(
|
|
array('Shirt' => array('id' => 1, 'color' => 'green')),
|
|
array('Shirt' => array('id' => 2, 'color' => 'blue')),
|
|
);
|
|
$expected = '<collection><shirt id="1" color="green" />';
|
|
$expected .= '<shirt id="2" color="blue" /></collection>';
|
|
|
|
$Xml = new Xml($input, array('root' => 'collection'));
|
|
$result = $Xml->toString(array('header' => false));
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* testCloneNode
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testCloneNode() {
|
|
$node =& new XmlNode('element', 'myValue');
|
|
$twin =& $node->cloneNode();
|
|
$this->assertEqual($node, $twin);
|
|
}
|
|
|
|
/**
|
|
* testNextSibling
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testNextSibling() {
|
|
$input = array(
|
|
array(
|
|
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => '1', 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => '1.89', 'industry_id' => '1.56', 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial')
|
|
),
|
|
array(
|
|
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => '1', 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => '2.2', 'industry_id' => 2.2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
|
|
'Industry' => array('id' => 2, 'name' => 'Education'),
|
|
)
|
|
);
|
|
$xml =& new Xml($input, array('format' => 'tags'));
|
|
$node =& $xml->children[0]->children[0];
|
|
|
|
$nextSibling =& $node->nextSibling();
|
|
$this->assertEqual($nextSibling, $xml->children[0]->children[1]);
|
|
|
|
$nextSibling2 =& $nextSibling->nextSibling();
|
|
$this->assertEqual($nextSibling2, $xml->children[0]->children[2]);
|
|
|
|
$noFriends =& $xml->children[0]->children[12];
|
|
$this->assertNull($noFriends->nextSibling());
|
|
}
|
|
|
|
/**
|
|
* testPreviousSibling
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testPreviousSibling() {
|
|
$input = array(
|
|
array(
|
|
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => '1', 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => '1.89', 'industry_id' => '1.56', 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial')
|
|
),
|
|
array(
|
|
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => '1', 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => '2.2', 'industry_id' => 2.2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
|
|
'Industry' => array('id' => 2, 'name' => 'Education'),
|
|
)
|
|
);
|
|
$xml =& new Xml($input, array('format' => 'tags'));
|
|
$node =& $xml->children[0]->children[1];
|
|
|
|
$prevSibling =& $node->previousSibling();
|
|
$this->assertEqual($prevSibling, $xml->children[0]->children[0]);
|
|
|
|
$this->assertNull($prevSibling->previousSibling());
|
|
}
|
|
|
|
/**
|
|
* testAddAndRemoveAttributes
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testAddAndRemoveAttributes() {
|
|
$node =& new XmlElement('myElement', 'superValue');
|
|
$this->assertTrue(empty($node->attributes));
|
|
|
|
$attrs = array(
|
|
'id' => 'test',
|
|
'show' => 1,
|
|
'is_spotlight' => 1,
|
|
);
|
|
$node->addAttribute($attrs);
|
|
$this->assertEqual($node->attributes, $attrs);
|
|
|
|
$node =& new XmlElement('myElement', 'superValue');
|
|
$node->addAttribute('test', 'value');
|
|
$this->assertTrue(isset($node->attributes['test']));
|
|
|
|
$node =& new XmlElement('myElement', 'superValue');
|
|
$obj =& new StdClass();
|
|
$obj->class = 'info';
|
|
$obj->id = 'primaryInfoBox';
|
|
$node->addAttribute($obj);
|
|
$expected = array(
|
|
'class' => 'info',
|
|
'id' => 'primaryInfoBox',
|
|
);
|
|
$this->assertEqual($node->attributes, $expected);
|
|
|
|
$result = $node->removeAttribute('class');
|
|
$this->assertTrue($result);
|
|
$this->assertFalse(isset($node->attributes['class']));
|
|
|
|
$result = $node->removeAttribute('missing');
|
|
$this->assertFalse($result);
|
|
}
|
|
|
|
/**
|
|
* Tests that XML documents with non-standard spacing (i.e. leading whitespace, whole document
|
|
* on one line) still parse properly.
|
|
*
|
|
* @return void
|
|
*/
|
|
function testParsingWithNonStandardWhitespace() {
|
|
$raw = '<?xml version="1.0" encoding="ISO-8859-1" ?><prices><price>1.0</price></prices>';
|
|
$array = array('Prices' => array('price' => 1.0));
|
|
|
|
$xml = new Xml($raw);
|
|
$this->assertEqual($xml->toArray(), $array);
|
|
$this->assertEqual($xml->__header, 'xml version="1.0" encoding="ISO-8859-1"');
|
|
|
|
$xml = new Xml(' ' . $raw);
|
|
$this->assertEqual($xml->toArray(), $array);
|
|
$this->assertEqual($xml->__header, 'xml version="1.0" encoding="ISO-8859-1"');
|
|
|
|
$xml = new Xml("\n" . $raw);
|
|
$this->assertEqual($xml->toArray(), $array);
|
|
$this->assertEqual($xml->__header, 'xml version="1.0" encoding="ISO-8859-1"');
|
|
}
|
|
|
|
/* Not implemented yet */
|
|
/* function testChildFilter() {
|
|
$input = array(
|
|
array(
|
|
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial'),
|
|
'BusinessSolution' => array(array('id' => 6, 'name' => 'Convert Sales')),
|
|
'MediaType' => array(
|
|
array('id' => 15, 'name' => 'Print'),
|
|
array('id' => 7, 'name' => 'Web Demo'),
|
|
array('id' => 6, 'name' => 'CD-ROM')
|
|
)
|
|
),
|
|
array(
|
|
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
|
|
'Industry' => array('id' => 2, 'name' => 'Education'),
|
|
'BusinessSolution' => array(
|
|
array('id' => 4, 'name' => 'Build Relationship'),
|
|
array('id' => 6, 'name' => 'Convert Sales')
|
|
),
|
|
'MediaType' => array(
|
|
array('id' => 17, 'name' => 'Web'),
|
|
array('id' => 6, 'name' => 'CD-ROM')
|
|
)
|
|
)
|
|
);
|
|
|
|
$xml = new Xml($input, array('format' => 'tags', 'tags' => array(
|
|
'MediaType' => array('value' => 'id', 'children' => false),
|
|
'JobType' => array('children' => array()),
|
|
'Industry' => array('children' => array('name')),
|
|
'show' => false
|
|
)));
|
|
|
|
$result = $xml->toString(array('header' => false, 'cdata' => false));
|
|
$expected = '<project><id>1</id><title /><client_id>1</client_id><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><name>Financial</name></industry><business_solution><id>6</id><name>Convert Sales</name></business_solution><media_type>15</media_type><media_type>7</media_type><media_type>6</media_type></project><project><id>2</id><title /><client_id>2</client_id><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><name>Education</name></industry><business_solution><id>4</id><name>Build Relationship</name></business_solution><business_solution><id>6</id><name>Convert Sales</name></business_solution><media_type>17</media_type><media_type>6</media_type></project>';
|
|
$this->assertEqual($expected, $result);
|
|
} */
|
|
|
|
/* Broken due to a Set class issue */
|
|
/* function testMixedArray() {
|
|
$input = array('OptionGroup' => array(
|
|
array('name' => 'OptA', 'id' => 12, 'OptA 1', 'OptA 2', 'OptA 3', 'OptA 4', 'OptA 5', 'OptA 6'),
|
|
array('name' => 'OptB', 'id' => 12, 'OptB 1', 'OptB 2', 'OptB 3', 'OptB 4', 'OptB 5', 'OptB 6')
|
|
));
|
|
$expected = '<option_group><name>OptA</name><id>12</id><option_group>OptA 1</option_group><option_group>OptA 2</option_group><option_group>OptA 3</option_group><option_group>OptA 4</option_group><option_group>OptA 5</option_group><option_group>OptA 6</option_group></option_group><option_group><name>OptB</name><id>12</id><option_group>OptB 1</option_group><option_group>OptB 2</option_group><option_group>OptB 3</option_group><option_group>OptB 4</option_group><option_group>OptB 5</option_group><option_group>OptB 6</option_group></option_group>';
|
|
$xml = new Xml($input, array('format' => 'tags'));
|
|
$result = $xml->toString(array('header' => false, 'cdata' => false));
|
|
$this->assertEqual($expected, $result);
|
|
} */
|
|
|
|
/* function testMixedNestedArray() {
|
|
$input = array(
|
|
'OptionA' => array(
|
|
'name' => 'OptA',
|
|
'id' => 12,
|
|
'opt' => array('OptA 1', 'OptA 2', 'OptA 3', 'OptA 4', 'OptA 5', 'OptA 6')
|
|
),
|
|
'OptionB' => array(
|
|
'name' => 'OptB',
|
|
'id' => 12,
|
|
'opt' => array('OptB 1', 'OptB 2', 'OptB 3', 'OptB 4', 'OptB 5', 'OptB 6')
|
|
)
|
|
);
|
|
$expected = '<option_a><name>OptA</name><id>12</id><opt>OptA 1</opt><opt>OptA 2</opt><opt>OptA 3</opt><opt>OptA 4</opt><opt>OptA 5</opt><opt>OptA 6</opt></option_a><option_b><name>OptB</name><id>12</id><opt>OptB 1</opt><opt>OptB 2</opt><opt>OptB 3</opt><opt>OptB 4</opt><opt>OptB 5</opt><opt>OptB 6</opt></option_b>';
|
|
$xml = new Xml($input, array('format' => 'tags'));
|
|
$result = $xml->toString(array('header' => false, 'cdata' => false));
|
|
$this->assertEqual($expected, $result);
|
|
} */
|
|
|
|
/* function testMixedArrayAttributes() {
|
|
$input = array('OptionGroup' => array(
|
|
array(
|
|
'name' => 'OptA',
|
|
'id' => 12,
|
|
array('opt' => 'OptA 1'),
|
|
array('opt' => 'OptA 2'),
|
|
array('opt' => 'OptA 3'),
|
|
array('opt' => 'OptA 4'),
|
|
array('opt' => 'OptA 5'),
|
|
array('opt' => 'OptA 6')
|
|
),
|
|
array(
|
|
'name' => 'OptB',
|
|
'id' => 12,
|
|
array('opt' => 'OptB 1'),
|
|
array('opt' => 'OptB 2'),
|
|
array('opt' => 'OptB 3'),
|
|
array('opt' => 'OptB 4'),
|
|
array('opt' => 'OptB 5'),
|
|
array('opt' => 'OptB 6')
|
|
)
|
|
));
|
|
$expected = '<option_group name="OptA" id="12"><opt>OptA 1</opt><opt>OptA 2</opt><opt>OptA 3</opt><opt>OptA 4</opt><opt>OptA 5</opt><opt>OptA 6</opt></option_group><option_group name="OptB" id="12"><opt>OptB 1</opt><opt>OptB 2</opt><opt>OptB 3</opt><opt>OptB 4</opt><opt>OptB 5</opt><opt>OptB 6</opt></option_group>';
|
|
|
|
$options = array('tags' => array('option_group' => array('attributes' => array('id', 'name'))));
|
|
$xml = new Xml($input, $options);
|
|
$result = $xml->toString(false);
|
|
|
|
$this->assertEqual($expected, $result);
|
|
} */
|
|
|
|
/* Not implemented yet */
|
|
/* function testTagMap() {
|
|
$input = array(
|
|
array(
|
|
'Project' => array('id' => 1, 'title' => null, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial')
|
|
),
|
|
array(
|
|
'Project' => array('id' => 2, 'title' => null, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
|
|
'Industry' => array('id' => 2, 'name' => 'Education'),
|
|
)
|
|
);
|
|
$expected = '<project id="1"><title /><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style id=""><name /></style><jobtype id="1">Touch Screen Kiosk</jobtype><industry id="1"><name>Financial</name></industry></project><project id="2"><title /><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style id=""><name /></style><jobtype id="2">Awareness Campaign</jobtype><industry id="2"><name>Education</name></industry></project>';
|
|
|
|
$xml = new Xml($input, array('tags' => array(
|
|
'Project' => array('attributes' => array('id')),
|
|
'style' => array('attributes' => array('id')),
|
|
'JobType' => array('name' => 'jobtype', 'attributes' => array('id'), 'value' => 'name'),
|
|
'Industry' => array('attributes' => array('id'))
|
|
)));
|
|
$result = $xml->toString(array('header' => false, 'cdata' => false));
|
|
$this->assertEqual($expected, $result);
|
|
} */
|
|
|
|
/**
|
|
* testAllCData method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testAllCData() {
|
|
$input = array(
|
|
array(
|
|
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => '1', 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => '1.89', 'industry_id' => '1.56', 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial')
|
|
),
|
|
array(
|
|
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => '1', 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => '2.2', 'industry_id' => 2.2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
|
|
'Industry' => array('id' => 2, 'name' => 'Education'),
|
|
)
|
|
);
|
|
$expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1.89</job_type_id><industry_id>1.56</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name><![CDATA[Touch Screen Kiosk]]></name></job_type><industry><id>1</id><name><![CDATA[Financial]]></name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2.2</job_type_id><industry_id>2.2</industry_id><modified><![CDATA[2007-11-26 14:48:36]]></modified><created /><style><id /><name /></style><job_type><id>2</id><name><![CDATA[Awareness Campaign]]></name></job_type><industry><id>2</id><name><![CDATA[Education]]></name></industry></project>';
|
|
$xml = new Xml($input, array('format' => 'tags'));
|
|
$result = $xml->toString(array('header' => false, 'cdata' => true));
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
/* PHP-native Unicode support pending */
|
|
/* function testConvertEntities() {
|
|
$input = array('project' => 'écît');
|
|
$xml = new Xml($input);
|
|
|
|
$result = $xml->toString(array('header' => false, 'cdata' => false, 'convertEntities' => true));
|
|
$expected = '<project>écît</project>';
|
|
$this->assertEqual($result, $expected);
|
|
} */
|
|
|
|
/**
|
|
* testWhitespace method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testWhitespace() {
|
|
$input = array(
|
|
array(
|
|
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial')
|
|
),
|
|
array(
|
|
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
|
|
'Industry' => array('id' => 2, 'name' => 'Education'),
|
|
)
|
|
);
|
|
$expected = "\n\t<project>\n\t\t<id>\n\t\t\t1\n\t\t</id>\n\t\t<title />\n\t\t<client_id>\n\t\t\t1\n\t\t</client_id>\n\t\t<show>\n\t\t\t1\n\t\t</show>\n\t\t<is_spotlight />\n\t\t<style_id>\n\t\t\t0\n\t\t</style_id>\n\t\t<job_type_id>\n\t\t\t1\n\t\t</job_type_id>\n\t\t<industry_id>\n\t\t\t1\n\t\t</industry_id>\n\t\t<modified />\n\t\t<created />\n\t\t<style>\n\t\t\t<id />\n\t\t\t<name />\n\t\t</style>\n\t\t<job_type>\n\t\t\t<id>\n\t\t\t\t1\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tTouch Screen Kiosk\n\t\t\t</name>\n\t\t</job_type>\n\t\t<industry>\n\t\t\t<id>\n\t\t\t\t1\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tFinancial\n\t\t\t</name>\n\t\t</industry>\n\t</project>\n\t<project>\n\t\t<id>\n\t\t\t2\n\t\t</id>\n\t\t<title />\n\t\t<client_id>\n\t\t\t2\n\t\t</client_id>\n\t\t<show>\n\t\t\t1\n\t\t</show>\n\t\t<is_spotlight />\n\t\t<style_id>\n\t\t\t0\n\t\t</style_id>\n\t\t<job_type_id>\n\t\t\t2\n\t\t</job_type_id>\n\t\t<industry_id>\n\t\t\t2\n\t\t</industry_id>\n\t\t<modified>\n\t\t\t2007-11-26 14:48:36\n\t\t</modified>\n\t\t<created />\n\t\t<style>\n\t\t\t<id />\n\t\t\t<name />\n\t\t</style>\n\t\t<job_type>\n\t\t\t<id>\n\t\t\t\t2\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tAwareness Campaign\n\t\t\t</name>\n\t\t</job_type>\n\t\t<industry>\n\t\t\t<id>\n\t\t\t\t2\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tEducation\n\t\t\t</name>\n\t\t</industry>\n\t</project>\n";
|
|
|
|
$xml = new Xml($input, array('format' => 'tags'));
|
|
$result = $xml->toString(array('header' => false, 'cdata' => false, 'whitespace' => true));
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* testSetSerialization method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testSetSerialization() {
|
|
$input = array(
|
|
array(
|
|
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
|
|
'Industry' => array('id' => 1, 'name' => 'Financial')
|
|
),
|
|
array(
|
|
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
|
|
'Style' => array('id' => null, 'name' => null),
|
|
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
|
|
'Industry' => array('id' => 2, 'name' => 'Education'),
|
|
)
|
|
);
|
|
$expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project>';
|
|
|
|
$xml = new Xml(Set::map($input), array('format' => 'tags'));
|
|
$result = $xml->toString(array('header' => false, 'cdata' => false));
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* ensure that normalize does not add _name_ elements that come from Set::map sometimes.
|
|
*
|
|
* @return void
|
|
*/
|
|
function testNormalizeNotAdding_name_Element() {
|
|
$input = array(
|
|
'output' => array(
|
|
'Vouchers' => array(
|
|
array('Voucher' => array('id' => 1)),
|
|
array('Voucher' => array('id' => 2)),
|
|
),
|
|
)
|
|
);
|
|
$xml = new Xml($input, array('attributes' => false, 'format' => 'tags'));
|
|
$this->assertFalse(isset($xml->children[0]->children[0]->children[1]), 'Too many children %s');
|
|
$this->assertEqual($xml->children[0]->children[0]->children[0]->name, 'voucher');
|
|
}
|
|
/**
|
|
* testSimpleParsing method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testSimpleParsing() {
|
|
$source = '<response><hello><![CDATA[happy world]]></hello><goodbye><![CDATA[cruel world]]></goodbye></response>';
|
|
$xml = new Xml($source);
|
|
$result = $xml->toString();
|
|
$this->assertEqual($source, $result);
|
|
}
|
|
|
|
/**
|
|
* test that elements with empty tag values do not collapse and corrupt data structures
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testElementCollapsing() {
|
|
$xmlDataThatFails = '<resultpackage>
|
|
<result qid="46b1c46ed6208"><![CDATA[46b1c46ed3af9]]></result>
|
|
<result qid="46b1c46ed332a"><![CDATA[]]></result>
|
|
<result qid="46b1c46ed90e6"><![CDATA[46b1c46ed69d8]]></result>
|
|
<result qid="46b1c46ed71a7"><![CDATA[46b1c46ed5a38]]></result>
|
|
<result qid="46b1c46ed8146"><![CDATA[46b1c46ed98b6]]></result>
|
|
<result qid="46b1c46ed7978"><![CDATA[]]></result>
|
|
<result qid="46b1c46ed4a98"><![CDATA[]]></result>
|
|
<result qid="46b1c46ed42c8"><![CDATA[]]></result>
|
|
<result qid="46b1c46ed5268"><![CDATA[46b1c46ed8917]]></result>
|
|
</resultpackage>';
|
|
|
|
$Xml = new Xml();
|
|
$Xml->load('<?xml version="1.0" encoding="UTF-8" ?>' . $xmlDataThatFails);
|
|
$result = $Xml->toArray(false);
|
|
|
|
$this->assertTrue(is_array($result));
|
|
$expected = array(
|
|
'resultpackage' => array(
|
|
'result' => array(
|
|
0 => array(
|
|
'value' => '46b1c46ed3af9',
|
|
'qid' => '46b1c46ed6208'),
|
|
1 => array(
|
|
'qid' => '46b1c46ed332a'),
|
|
2 => array(
|
|
'value' => '46b1c46ed69d8',
|
|
'qid' => '46b1c46ed90e6'),
|
|
3 => array(
|
|
'value' => '46b1c46ed5a38',
|
|
'qid' => '46b1c46ed71a7'),
|
|
4 => array(
|
|
'value' => '46b1c46ed98b6',
|
|
'qid' => '46b1c46ed8146'),
|
|
5 => array(
|
|
'qid' => '46b1c46ed7978'),
|
|
6 => array(
|
|
'qid' => '46b1c46ed4a98'),
|
|
7 => array(
|
|
'qid' => '46b1c46ed42c8'),
|
|
8 => array(
|
|
'value' => '46b1c46ed8917',
|
|
'qid' => '46b1c46ed5268'),
|
|
)
|
|
));
|
|
$this->assertEqual(
|
|
count($result['resultpackage']['result']), count($expected['resultpackage']['result']),
|
|
'Incorrect array length %s');
|
|
|
|
$this->assertFalse(
|
|
isset($result['resultpackage']['result'][0][0]['qid']), 'Nested array exists, data is corrupt. %s');
|
|
|
|
$this->assertEqual($result, $expected);
|
|
}
|
|
|
|
/**
|
|
* test that empty values do not casefold collapse
|
|
*
|
|
* @see http://code.cakephp.org/tickets/view/8
|
|
* @return void
|
|
*/
|
|
function testCaseFoldingWithEmptyValues() {
|
|
$filledValue = '<method name="set_user_settings">
|
|
<title>update user information</title>
|
|
<user>1</user>
|
|
<User>
|
|
<id>1</id>
|
|
<name>varchar(45)</name>
|
|
</User>
|
|
</method>';
|
|
$xml =& new XML($filledValue);
|
|
$expected = array(
|
|
'Method' => array(
|
|
'name' => 'set_user_settings',
|
|
'title' => 'update user information',
|
|
'user' => '1',
|
|
'User' => array(
|
|
'id' => 1,
|
|
'name' => 'varchar(45)',
|
|
),
|
|
)
|
|
);
|
|
$result = $xml->toArray();
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$emptyValue ='<method name="set_user_settings">
|
|
<title>update user information</title>
|
|
<user></user>
|
|
<User>
|
|
<id>1</id>
|
|
<name>varchar(45)</name>
|
|
</User>
|
|
</method>';
|
|
|
|
$xml =& new XML($emptyValue);
|
|
$expected = array(
|
|
'Method' => array(
|
|
'name' => 'set_user_settings',
|
|
'title' => 'update user information',
|
|
'user' => array(),
|
|
'User' => array(
|
|
'id' => 1,
|
|
'name' => 'varchar(45)',
|
|
),
|
|
)
|
|
);
|
|
$result = $xml->toArray();
|
|
$this->assertEqual($result, $expected);
|
|
}
|
|
/**
|
|
* testMixedParsing method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testMixedParsing() {
|
|
$source = '<response><body><hello><![CDATA[happy world]]></hello><![CDATA[in between]]><goodbye><![CDATA[cruel world]]></goodbye></body></response>';
|
|
$xml = new Xml($source);
|
|
$result = $xml->toString();
|
|
$this->assertEqual($source, $result);
|
|
}
|
|
|
|
/**
|
|
* testComplexParsing method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testComplexParsing() {
|
|
$source = '<projects><project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project></projects>';
|
|
$xml = new Xml($source);
|
|
$result = $xml->toString(array('cdata' => false));
|
|
$this->assertEqual($source, $result);
|
|
}
|
|
|
|
/**
|
|
* testNamespaceParsing method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testNamespaceParsing() {
|
|
$source = '<a:container xmlns:a="http://example.com/a" xmlns:b="http://example.com/b" xmlns:c="http://example.com/c" xmlns:d="http://example.com/d" xmlns:e="http://example.com/e"><b:rule test=""><c:result>value</c:result></b:rule><d:rule test=""><e:result>value</e:result></d:rule></a:container>';
|
|
$xml = new Xml($source);
|
|
|
|
$result = $xml->toString(array('cdata' => false));
|
|
$this->assertEqual($source, $result);
|
|
|
|
$children = $xml->children('container');
|
|
$this->assertEqual($children[0]->namespace, 'a');
|
|
|
|
$children = $children[0]->children('rule');
|
|
$this->assertEqual($children[0]->namespace, 'b');
|
|
}
|
|
|
|
/**
|
|
* testNamespaces method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testNamespaces() {
|
|
$source = '<a:container xmlns:a="http://example.com/a" xmlns:b="http://example.com/b" xmlns:c="http://example.com/c" xmlns:d="http://example.com/d" xmlns:e="http://example.com/e"><b:rule test=""><c:result>value</c:result></b:rule><d:rule test=""><e:result>value</e:result></d:rule></a:container>';
|
|
$xml = new Xml($source);
|
|
|
|
$expects = '<a:container xmlns:a="http://example.com/a" xmlns:b="http://example.com/b" xmlns:c="http://example.com/c" xmlns:d="http://example.com/d" xmlns:e="http://example.com/e" xmlns:f="http://example.com/f"><b:rule test=""><c:result>value</c:result></b:rule><d:rule test=""><e:result>value</e:result></d:rule></a:container>';
|
|
|
|
$_xml = XmlManager::getInstance();
|
|
$xml->addNamespace('f', 'http://example.com/f');
|
|
$result = $xml->toString(array('cdata' => false));
|
|
$this->assertEqual($expects, $result);
|
|
}
|
|
|
|
/**
|
|
* testEscapeCharSerialization method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testEscapeCharSerialization() {
|
|
$xml = new Xml(array('text' => 'JavaScript & DHTML'), array('attributes' => false, 'format' => 'attributes'));
|
|
|
|
$result = $xml->toString(false);
|
|
$expected = '<std_class text="JavaScript & DHTML" />';
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* testCompleteEscapeCharSerialization method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testCompleteEscapeCharSerialization() {
|
|
$xml = new Xml(array('text' => '<>&"\''), array('attributes' => false, 'format' => 'attributes'));
|
|
|
|
$result = $xml->toString(false);
|
|
$expected = '<std_class text="<>&"'" />';
|
|
$this->assertEqual($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* testToArray method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testToArray() {
|
|
App::import('Set');
|
|
$string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<rss version="2.0">
|
|
<channel>
|
|
<title>Cake PHP Google Group</title>
|
|
<link>http://groups.google.com/group/cake-php</link>
|
|
<description>Search this group before posting anything. There are over 20,000 posts and it&#39;s very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.</description>
|
|
<language>en</language>
|
|
<item>
|
|
<title>constructng result array when using findall</title>
|
|
<link>http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f</link>
|
|
<description>i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay-&gt;(hasMany)ServiceTi me-&gt;(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] =&gt; Array(</description>
|
|
<guid isPermaLink="true">http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f</guid>
|
|
<author>bmil...@gmail.com(bpscrugs)</author>
|
|
<pubDate>Fri, 28 Dec 2007 00:44:14 UT</pubDate>
|
|
</item>
|
|
<item>
|
|
<title>Re: share views between actions?</title>
|
|
<link>http://groups.google.com/group/cake-php/msg/8b350d898707dad8</link>
|
|
<description>Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple &quot;RTFM&quot; would suffice. I'll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other</description>
|
|
<guid isPermaLink="true">http://groups.google.com/group/cake-php/msg/8b350d898707dad8</guid>
|
|
<author>subtropolis.z...@gmail.com(subtropolis zijn)</author>
|
|
<pubDate>Fri, 28 Dec 2007 00:45:01 UT</pubDate>
|
|
</item>
|
|
</channel>
|
|
</rss>';
|
|
$xml = new Xml($string);
|
|
$result = $xml->toArray();
|
|
$expected = array('Rss' => array(
|
|
'version' => '2.0',
|
|
'Channel' => array(
|
|
'title' => 'Cake PHP Google Group',
|
|
'link' => 'http://groups.google.com/group/cake-php',
|
|
'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.',
|
|
'language' => 'en',
|
|
'Item' => array(
|
|
array(
|
|
'title' => 'constructng result array when using findall',
|
|
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
|
|
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br><p>Array( <br> [0] => Array(",
|
|
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
|
'author' => 'bmil...@gmail.com(bpscrugs)',
|
|
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
|
),
|
|
array(
|
|
'title' => 'Re: share views between actions?',
|
|
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
|
|
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
|
|
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
|
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
|
|
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
|
|
)
|
|
)
|
|
)
|
|
));
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$string ='<data><post title="Title of this post" description="cool"/></data>';
|
|
$xml = new Xml($string);
|
|
$result = $xml->toArray();
|
|
$expected = array('Data' => array('Post' => array('title' => 'Title of this post', 'description' => 'cool')));
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$xml = new Xml('<example><item><title>An example of a correctly reversed XMLNode</title><desc/></item></example>');
|
|
$result = Set::reverse($xml);
|
|
$expected = array(
|
|
'Example' => array(
|
|
'Item' => array(
|
|
'title' => 'An example of a correctly reversed XMLNode',
|
|
'desc' => array(),
|
|
)
|
|
)
|
|
);
|
|
$this->assertIdentical($result, $expected);
|
|
|
|
$xml = new Xml('<example><item attr="123"><titles><title>title1</title><title>title2</title></titles></item></example>');
|
|
$result = $xml->toArray();
|
|
$expected = array(
|
|
'Example' => array(
|
|
'Item' => array(
|
|
'attr' => '123',
|
|
'Titles' => array(
|
|
'Title' => array('title1', 'title2')
|
|
)
|
|
)
|
|
)
|
|
);
|
|
$this->assertIdentical($result, $expected);
|
|
|
|
$xml = new Xml('<example attr="ex_attr"><item attr="123"><titles>list</titles>textforitems</item></example>');
|
|
$result = $xml->toArray();
|
|
$expected = array(
|
|
'Example' => array(
|
|
'attr' => 'ex_attr',
|
|
'Item' => array(
|
|
'attr' => '123',
|
|
'titles' => 'list',
|
|
'value' => 'textforitems'
|
|
)
|
|
)
|
|
);
|
|
$this->assertIdentical($result, $expected);
|
|
|
|
$xml = new Xml('<example attr="ex_attr"><item attr="123"><titles>list</titles>textforitems</item></example>');
|
|
$example = $xml->child('example');
|
|
$item = $example->child('item');
|
|
$result = $item->toArray();
|
|
|
|
$expected = array(
|
|
'attr' => '123',
|
|
'titles' => 'list',
|
|
'value' => 'textforitems'
|
|
);
|
|
$this->assertIdentical($result, $expected);
|
|
|
|
$string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<rss version="2.0">
|
|
<channel>
|
|
<title>Cake PHP Google Group</title>
|
|
<link>http://groups.google.com/group/cake-php</link>
|
|
<description>Search this group before posting anything. There are over 20,000 posts and it&#39;s very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.</description>
|
|
<language>en</language>
|
|
<item>
|
|
<title>constructng result array when using findall</title>
|
|
<link>http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f</link>
|
|
<description>i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay-&gt;(hasMany)ServiceTi me-&gt;(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] =&gt; Array(</description>
|
|
<dc:creator>cakephp</dc:creator>
|
|
<category><![CDATA[cakephp]]></category>
|
|
<category><![CDATA[model]]></category>
|
|
<guid isPermaLink="true">http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f</guid>
|
|
<author>bmil...@gmail.com(bpscrugs)</author>
|
|
<pubDate>Fri, 28 Dec 2007 00:44:14 UT</pubDate>
|
|
</item>
|
|
<item>
|
|
<title>Re: share views between actions?</title>
|
|
<link>http://groups.google.com/group/cake-php/msg/8b350d898707dad8</link>
|
|
<description>Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple &quot;RTFM&quot; would suffice. I'll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other</description>
|
|
<dc:creator>cakephp</dc:creator>
|
|
<category><![CDATA[cakephp]]></category>
|
|
<category><![CDATA[model]]></category>
|
|
<guid isPermaLink="true">http://groups.google.com/group/cake-php/msg/8b350d898707dad8</guid>
|
|
<author>subtropolis.z...@gmail.com(subtropolis zijn)</author>
|
|
<pubDate>Fri, 28 Dec 2007 00:45:01 UT</pubDate>
|
|
</item>
|
|
</channel>
|
|
</rss>';
|
|
|
|
$xml = new Xml($string);
|
|
$result = $xml->toArray();
|
|
|
|
$expected = array('Rss' => array(
|
|
'version' => '2.0',
|
|
'Channel' => array(
|
|
'title' => 'Cake PHP Google Group',
|
|
'link' => 'http://groups.google.com/group/cake-php',
|
|
'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.',
|
|
'language' => 'en',
|
|
'Item' => array(
|
|
array(
|
|
'title' => 'constructng result array when using findall',
|
|
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
|
|
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br><p>Array( <br> [0] => Array(",
|
|
'creator' => 'cakephp',
|
|
'Category' => array('cakephp', 'model'),
|
|
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
|
'author' => 'bmil...@gmail.com(bpscrugs)',
|
|
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
|
),
|
|
array(
|
|
'title' => 'Re: share views between actions?',
|
|
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
|
|
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
|
|
'creator' => 'cakephp',
|
|
'Category' => array('cakephp', 'model'),
|
|
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
|
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
|
|
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
|
|
)
|
|
)
|
|
)
|
|
));
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$text = "<?xml version='1.0' encoding='utf-8'?>
|
|
<course>
|
|
<comps>
|
|
<comp>1</comp>
|
|
<comp>2</comp>
|
|
<comp>3</comp>
|
|
<comp>4</comp>
|
|
</comps>
|
|
</course>";
|
|
$xml = new Xml($text);
|
|
$result = $xml->toArray();
|
|
|
|
$expected = array('Course' => array(
|
|
'Comps' => array(
|
|
'Comp' => array(
|
|
1, 2, 3, 4
|
|
)
|
|
)
|
|
));
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$text = '<?xml version="1.0" encoding="UTF-8"?>
|
|
<XRDS xmlns="xri://$xrds">
|
|
<XRD xml:id="oauth" xmlns="xri://$XRD*($v*2.0)" version="2.0">
|
|
<Type>xri://$xrds*simple</Type>
|
|
<Expires>2008-04-13T07:34:58Z</Expires>
|
|
<Service>
|
|
<Type>http://oauth.net/core/1.0/endpoint/authorize</Type>
|
|
<Type>http://oauth.net/core/1.0/parameters/auth-header</Type>
|
|
<Type>http://oauth.net/core/1.0/parameters/uri-query</Type>
|
|
<URI priority="10">https://ma.gnolia.com/oauth/authorize</URI>
|
|
<URI priority="20">http://ma.gnolia.com/oauth/authorize</URI>
|
|
</Service>
|
|
</XRD>
|
|
<XRD xmlns="xri://$XRD*($v*2.0)" version="2.0">
|
|
<Type>xri://$xrds*simple</Type>
|
|
<Service priority="10">
|
|
<Type>http://oauth.net/discovery/1.0</Type>
|
|
<URI>#oauth</URI>
|
|
</Service>
|
|
</XRD>
|
|
</XRDS>';
|
|
|
|
$xml = new Xml($text);
|
|
$result = $xml->toArray();
|
|
|
|
$expected = array('XRDS' => array(
|
|
'xmlns' => 'xri://$xrds',
|
|
'XRD' => array(
|
|
array(
|
|
'xml:id' => 'oauth',
|
|
'xmlns' => 'xri://$XRD*($v*2.0)',
|
|
'version' => '2.0',
|
|
'Type' => 'xri://$xrds*simple',
|
|
'Expires' => '2008-04-13T07:34:58Z',
|
|
'Service' => array(
|
|
'Type' => array(
|
|
'http://oauth.net/core/1.0/endpoint/authorize',
|
|
'http://oauth.net/core/1.0/parameters/auth-header',
|
|
'http://oauth.net/core/1.0/parameters/uri-query'
|
|
),
|
|
'URI' => array(
|
|
array(
|
|
'value' => 'https://ma.gnolia.com/oauth/authorize',
|
|
'priority' => '10',
|
|
),
|
|
array(
|
|
'value' => 'http://ma.gnolia.com/oauth/authorize',
|
|
'priority' => '20'
|
|
)
|
|
)
|
|
)
|
|
),
|
|
array(
|
|
'xmlns' => 'xri://$XRD*($v*2.0)',
|
|
'version' => '2.0',
|
|
'Type' => 'xri://$xrds*simple',
|
|
'Service' => array(
|
|
'priority' => '10',
|
|
'Type' => 'http://oauth.net/discovery/1.0',
|
|
'URI' => '#oauth'
|
|
)
|
|
)
|
|
)
|
|
));
|
|
$this->assertEqual($result, $expected);
|
|
|
|
$text = '<?xml version="1.0" encoding="UTF-8"?>
|
|
<root>
|
|
<child id="1" other="1" />
|
|
<child id="2" other="1" />
|
|
<child id="3" other="1" />
|
|
<child id="4" other="1" />
|
|
<child id="5" other="1" />
|
|
</root>';
|
|
$xml = new Xml($text);
|
|
$result = $xml->toArray();
|
|
$expected = array(
|
|
'Root' => array(
|
|
'Child' => array(
|
|
array('id' => 1, 'other' => 1),
|
|
array('id' => 2, 'other' => 1),
|
|
array('id' => 3, 'other' => 1),
|
|
array('id' => 4, 'other' => 1),
|
|
array('id' => 5, 'other' => 1)
|
|
)
|
|
)
|
|
);
|
|
$this->assertEqual($result, $expected);
|
|
}
|
|
|
|
/**
|
|
* testAppend method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testAppend() {
|
|
$parentNode = new XmlNode('ourParentNode');
|
|
$parentNode->append( new XmlNode('ourChildNode'));
|
|
$first =& $parentNode->first();
|
|
$this->assertEqual($first->name, 'ourChildNode');
|
|
|
|
$string = 'ourChildNode';
|
|
$parentNode = new XmlNode('ourParentNode');
|
|
$parentNode->append($string);
|
|
$last =& $parentNode->last();
|
|
$this->assertEqual($last->name, 'ourChildNode');
|
|
|
|
$this->expectError();
|
|
$parentNode->append($parentNode);
|
|
}
|
|
|
|
/**
|
|
* testNamespacing method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testNamespacing() {
|
|
$node = new Xml('<xml></xml>');
|
|
$node->addNamespace('cake', 'http://cakephp.org');
|
|
$this->assertEqual($node->toString(), '<xml xmlns:cake="http://cakephp.org" />');
|
|
|
|
$this->assertTrue($node->removeNamespace('cake'));
|
|
$this->assertEqual($node->toString(), '<xml />');
|
|
|
|
|
|
$node = new Xml('<xml xmlns:cake="http://cakephp.org" />');
|
|
$this->assertTrue($node->removeNamespace('cake'));
|
|
$this->assertEqual($node->toString(), '<xml />');
|
|
|
|
$node->addNamespace('cake', 'http://cakephp.org');
|
|
$this->assertEqual($node->toString(), '<xml xmlns:cake="http://cakephp.org" />');
|
|
}
|
|
|
|
/**
|
|
* testCamelize method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testCamelize() {
|
|
$xmlString = '<methodCall><methodName>examples.getStateName</methodName>' .
|
|
'<params><param><value><i4>41</i4></value></param></params></methodCall>';
|
|
|
|
$Xml = new Xml($xmlString);
|
|
$expected = array(
|
|
'methodCall' => array(
|
|
'methodName' => 'examples.getStateName',
|
|
'params' => array(
|
|
'param' => array('value' => array('i4' => 41)))));
|
|
$this->assertEqual($expected, $Xml->toArray(false));
|
|
|
|
$Xml = new Xml($xmlString);
|
|
$expected = array(
|
|
'MethodCall' => array(
|
|
'methodName' => 'examples.getStateName',
|
|
'Params' => array(
|
|
'Param' => array('Value' => array('i4' => 41)))));
|
|
$this->assertEqual($expected, $Xml->toArray());
|
|
}
|
|
|
|
/**
|
|
* testNumericDataHandling method
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
function testNumericDataHandling() {
|
|
$data = '<xml><data>012345</data></xml>';
|
|
|
|
$node = new Xml();
|
|
$node->load($data);
|
|
$node->parse();
|
|
|
|
$result = $node->first();
|
|
$result = $result->children("data");
|
|
|
|
$result = $result[0]->first();
|
|
$this->assertEqual($result->value, '012345');
|
|
}
|
|
}
|
|
?>
|