From 5fabc6b76942841a95ffc4ea157509a692b26e15 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 19 Aug 2016 13:26:04 +0000 Subject: [PATCH] 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 --- tests/phpunit/data/export/slashes.xml | 77 +++++++++++++++++++++++++++ tests/phpunit/tests/import/import.php | 19 +++++++ 2 files changed, 96 insertions(+) create mode 100644 tests/phpunit/data/export/slashes.xml diff --git a/tests/phpunit/data/export/slashes.xml b/tests/phpunit/data/export/slashes.xml new file mode 100644 index 0000000000..3e073d8121 --- /dev/null +++ b/tests/phpunit/data/export/slashes.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + trunk + http://localhost/ + trunk + Tue, 18 Jan 2011 08:06:21 +0000 + en + 1.1 + http://localhost/ + http://localhost/ + + 1adminlocal@host.null + + 8alpha + 33tag1 + + http://wordpress.org/?v=3.1-RC2-17315 + + + Hello world! + http://localhost/?p=1 + Tue, 18 Jan 2011 07:40:14 +0000 + author + http://localhost/?p=1 + + + + 1 + 2011-01-18 07:40:14 + 2011-01-18 07:40:14 + open + open + hello-world + publish + 0 + 0 + post + + 0 + + + Post by + + + + _edit_last + + + + + diff --git a/tests/phpunit/tests/import/import.php b/tests/phpunit/tests/import/import.php index e253a9b788..fa0bcbbda8 100644 --- a/tests/phpunit/tests/import/import.php +++ b/tests/phpunit/tests/import/import.php @@ -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 }