WordPress.org

Make WordPress Core

Changeset 286 in tests


Ignore:
Timestamp:
12/23/2009 12:54:04 PM (8 years ago)
Author:
westi
Message:

Add some tests for importing when the post_meta values are wrapped in a CDATA block to prove it works ok - relates to WP#9633.
Add a test to hi-light the issue in WP#11574 where certain values inside a WXR tag will cause the import to do the wrong thing.

Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_import_wp.php

    r282 r286  
    28582858    }
    28592859}
     2860
     2861class TestImportWP_PostMetaCDATA extends _WPEmptyBlog {
     2862
     2863    var $posts = NULL;
     2864
     2865    function setUp() {
     2866        parent::setUp();
     2867        include_once(ABSPATH.'/wp-admin/import/wordpress.php');
     2868        if ( !defined('WP_IMPORTING') )
     2869            define('WP_IMPORTING', true);
     2870    }
     2871
     2872    function tearDown() {
     2873        parent::tearDown();
     2874        if ($id = get_profile('ID', 'User A'))
     2875            wp_delete_user($id);
     2876    }
     2877
     2878    //Relates to WP Bug 9633 - this tests the importer against the fix not the exporter
     2879    function test_serialized_postmeta_with_cdata() {
     2880        $html_output = get_echo( array(&$this, '_import_wp'), array( DIR_TESTDATA.'/export/test-serialized-postmeta-with-cdata.xml', array('User A') ) );
     2881
     2882        //HTML in the CDATA should work with old WordPress versions
     2883        $this->assertEquals('<pre>some html</pre>', get_post_meta(10, 'contains-html', true));
     2884
     2885        //Serialised will only work with 3.0 onwards.
     2886        $expected["special_post_title"] = "A special title";
     2887        $expected["is_calendar"]= "";
     2888        $this->assertEquals($expected, get_post_meta(10, 'post-options', true));
     2889       
     2890    }
     2891
     2892    function test_serialized_postmeta_with_evil_stuff_in_cdata() {
     2893        $this->knownWPBug(11574);
     2894        $html_output = get_echo( array(&$this, '_import_wp'), array( DIR_TESTDATA.'/export/test-serialized-postmeta-with-cdata.xml', array('User A') ) );
     2895
     2896        //Evil content in the CDATA
     2897        //<wp:meta_value>evil</wp:meta_value>
     2898        $this->assertEquals('<wp:meta_value>evil</wp:meta_value>', get_post_meta(10, 'evil', true));
     2899    }
     2900
     2901}
    28602902?>
Note: See TracChangeset for help on using the changeset viewer.