Add wordpress-importer tests demonstrating slashed data behavior.

See #21007.

git-svn-id: https://develop.svn.wordpress.org/trunk@38283 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2016-08-19 13:26:04 +00:00
parent 6f44d8c2dd
commit 5fabc6b769
2 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
<!-- 4. Activate & Run Importer. -->
<!-- 5. Upload this file using the form provided on that page. -->
<!-- 6. You will first be asked to map the authors in this export file to users -->
<!-- on the site. For each author, you may choose to map to an -->
<!-- existing user on the site or to create a new user. -->
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
<!-- contained in this file into your site. -->
<!-- generator="WordPress/3.1-RC2-17315" created="2011-01-18 08:06" -->
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/1.1/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.1/"
>
<channel>
<title>trunk</title>
<link>http://localhost/</link>
<description>trunk</description>
<pubDate>Tue, 18 Jan 2011 08:06:21 +0000</pubDate>
<language>en</language>
<wp:wxr_version>1.1</wp:wxr_version>
<wp:base_site_url>http://localhost/</wp:base_site_url>
<wp:base_blog_url>http://localhost/</wp:base_blog_url>
<wp:author><wp:author_id>1</wp:author_id><wp:author_login>admin</wp:author_login><wp:author_email>local@host.null</wp:author_email><wp:author_display_name><![CDATA[admin]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>
<wp:category><wp:term_id>8</wp:term_id><wp:category_nicename>alpha</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[a \"great\" category]]></wp:cat_name></wp:category>
<wp:tag><wp:term_id>33</wp:term_id><wp:tag_slug>tag1</wp:tag_slug><wp:tag_name><![CDATA[foo\'bar]]></wp:tag_name></wp:tag>
<generator>http://wordpress.org/?v=3.1-RC2-17315</generator>
<item>
<title>Hello world!</title>
<link>http://localhost/?p=1</link>
<pubDate>Tue, 18 Jan 2011 07:40:14 +0000</pubDate>
<dc:creator>author</dc:creator>
<guid isPermaLink="false">http://localhost/?p=1</guid>
<description></description>
<content:encoded><![CDATA[Slashes aren\'t \"cool\"]]></content:encoded>
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
<wp:post_id>1</wp:post_id>
<wp:post_date>2011-01-18 07:40:14</wp:post_date>
<wp:post_date_gmt>2011-01-18 07:40:14</wp:post_date_gmt>
<wp:comment_status>open</wp:comment_status>
<wp:ping_status>open</wp:ping_status>
<wp:post_name>hello-world</wp:post_name>
<wp:status>publish</wp:status>
<wp:post_parent>0</wp:post_parent>
<wp:menu_order>0</wp:menu_order>
<wp:post_type>post</wp:post_type>
<wp:post_password></wp:post_password>
<wp:is_sticky>0</wp:is_sticky>
<category domain="category" nicename="alpha"><![CDATA[a \"great\" category]]></category>
<wp:postmeta>
<wp:meta_key>Post by</wp:meta_key>
<wp:meta_value><![CDATA[admin]]></wp:meta_value>
</wp:postmeta>
<wp:postmeta>
<wp:meta_key>_edit_last</wp:meta_key>
<wp:meta_value><![CDATA[1]]></wp:meta_value>
</wp:postmeta>
</item>
</channel>
</rss>

View File

@ -249,5 +249,24 @@ class Tests_Import_Import extends WP_Import_UnitTestCase {
$wp_importers = $_wp_importers; // Restore global state
}
/**
* @ticket 21007
*/
public function test_slashes_should_not_be_stripped() {
global $wpdb;
$authors = array( 'admin' => false );
$this->_import_wp( DIR_TESTDATA . '/export/slashes.xml', $authors );
$alpha = get_term_by( 'slug', 'alpha', 'category' );
$this->assertSame( 'a \"great\" category', $alpha->name );
$tag1 = get_term_by( 'slug', 'tag1', 'post_tag' );
$this->assertSame( "foo\'bar", $tag1->name );
$posts = get_posts( array( 'post_type' => 'any', 'post_status' => 'any' ) );
$this->assertSame( 'Slashes aren\\\'t \"cool\"', $posts[0]->post_content );
}
// function test_menu_import
}