<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[59769] trunk: Import: Remove Importer plugin related unit tests.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/59769">59769</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/59769","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>desrosj</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2025-02-06 17:51:01 +0000 (Thu, 06 Feb 2025)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Import: Remove Importer plugin related unit tests.
The WordPress Importer plugin has been maintained separately in a repository on GitHub since 2016. However, the unit tests were left in wordpress-develop due to the lack of a CI setup on GitHub.
With GitHub Actions set up for the plugin repository, these tests are now running in two locations. Because they are more relevant to the plugin itself, the tests have been synced, will run weekly through a `schedule` event, and are now being removed from wordpress-develop.
The only remaining test method in the `import` group covers `get_importers()`, which is a function maintained in WordPress Core itself.
Props frank-klein, netweb, dd32, peterwilsoncc, azaozz, desrosj, swissspidy.
Fixes <a href="https://core.trac.wordpress.org/ticket/42668">#42668</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunitincludesbootstrapphp">trunk/tests/phpunit/includes/bootstrap.php</a></li>
<li><a href="#trunktestsphpunittestsimportimportphp">trunk/tests/phpunit/tests/import/import.php</a></li>
<li><a href="#trunktoolslocalenvscriptsinstalljs">trunk/tools/local-env/scripts/install.js</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsimportbasephp">trunk/tests/phpunit/tests/import/base.php</a></li>
<li><a href="#trunktestsphpunittestsimportparserphp">trunk/tests/phpunit/tests/import/parser.php</a></li>
<li><a href="#trunktestsphpunittestsimportpostmetaphp">trunk/tests/phpunit/tests/import/postmeta.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunitincludesbootstrapphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/includes/bootstrap.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/includes/bootstrap.php 2025-02-06 17:25:01 UTC (rev 59768)
+++ trunk/tests/phpunit/includes/bootstrap.php 2025-02-06 17:51:01 UTC (rev 59769)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -214,7 +214,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
</span><span class="cx" style="display: block; padding: 0 10px"> define( 'DIR_TESTDATA', __DIR__ . '/../data' );
</span><span class="cx" style="display: block; padding: 0 10px"> define( 'DIR_TESTROOT', realpath( dirname( __DIR__ ) ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-define( 'IMPORTER_PLUGIN_FOR_TESTS', DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php' );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> define( 'WP_LANG_DIR', realpath( DIR_TESTDATA . '/languages' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunittestsimportbasephp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/import/base.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/import/base.php 2025-02-06 17:25:01 UTC (rev 59768)
+++ trunk/tests/phpunit/tests/import/base.php 2025-02-06 17:51:01 UTC (rev 59769)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,76 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-abstract class WP_Import_UnitTestCase extends WP_UnitTestCase {
-
- /**
- * Require the WordPress Importer plugin.
- *
- * Fails the test if the plugin is not installed.
- */
- protected function require_importer() {
- if ( ! file_exists( IMPORTER_PLUGIN_FOR_TESTS ) ) {
- $this->fail( 'This test requires the WordPress Importer plugin to be installed in the test suite. See: https://make.wordpress.org/core/handbook/contribute/git/#unit-tests' );
- }
- require_once IMPORTER_PLUGIN_FOR_TESTS;
- }
-
- /**
- * Import a WXR file.
- *
- * The $users parameter provides information on how users specified in the import
- * file should be imported. Each key is a user login name and indicates if the user
- * should be mapped to an existing user, created as a new user with a particular login
- * or imported with the information held in the WXR file. An example of this:
- *
- * <code>
- * $users = array(
- * 'alice' => 1, // alice will be mapped to user ID 1.
- * 'bob' => 'john', // bob will be transformed into john.
- * 'eve' => false // eve will be imported as is.
- * );</code>
- *
- * @param string $filename Full path of the file to import
- * @param array $users User import settings
- * @param bool $fetch_files Whether or not do download remote attachments
- */
- protected function _import_wp( $filename, $users = array(), $fetch_files = true ) {
- $this->require_importer();
-
- $importer = new WP_Import();
- $file = realpath( $filename );
-
- $this->assertNotEmpty( $file, 'Path to import file is empty.' );
- $this->assertTrue( is_file( $file ), 'Import file is not a file.' );
-
- $authors = array();
- $mapping = array();
- $new = array();
- $i = 0;
-
- // Each user is either mapped to a given ID, mapped to a new user
- // with given login or imported using details in WXR file.
- foreach ( $users as $user => $map ) {
- $authors[ $i ] = $user;
- if ( is_int( $map ) ) {
- $mapping[ $i ] = $map;
- } elseif ( is_string( $map ) ) {
- $new[ $i ] = $map;
- }
-
- ++$i;
- }
-
- $_POST = array(
- 'imported_authors' => $authors,
- 'user_map' => $mapping,
- 'user_new' => $new,
- );
-
- ob_start();
- $importer->fetch_attachments = $fetch_files;
- $importer->import( $file );
- ob_end_clean();
-
- $_POST = array();
- }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsimportimportphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/import/import.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/import/import.php 2025-02-06 17:25:01 UTC (rev 59768)
+++ trunk/tests/phpunit/tests/import/import.php 2025-02-06 17:51:01 UTC (rev 59769)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,250 +1,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-require_once __DIR__ . '/base.php';
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @group import
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-class Tests_Import_Import extends WP_Import_UnitTestCase {
- public function set_up() {
- global $wpdb;
-
- parent::set_up();
-
- if ( ! defined( 'WP_IMPORTING' ) ) {
- define( 'WP_IMPORTING', true );
- }
-
- if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) {
- define( 'WP_LOAD_IMPORTERS', true );
- }
-
- add_filter( 'import_allow_create_users', '__return_true' );
-
- $this->require_importer();
-
- // Crude but effective: make sure there's no residual data in the main tables.
- foreach ( array( 'posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta' ) as $table ) {
- $wpdb->query( "DELETE FROM {$wpdb->$table}" );
- }
- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class Tests_Import_Import extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @covers WP_Import::import
- */
- public function test_small_import() {
- global $wpdb;
-
- $authors = array(
- 'admin' => false,
- 'editor' => false,
- 'author' => false,
- );
- $this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors );
-
- // Ensure that authors were imported correctly.
- $user_count = count_users();
- $this->assertSame( 3, $user_count['total_users'] );
- $admin = get_user_by( 'login', 'admin' );
- $this->assertSame( 'admin', $admin->user_login );
- $this->assertSame( 'local@host.null', $admin->user_email );
- $editor = get_user_by( 'login', 'editor' );
- $this->assertSame( 'editor', $editor->user_login );
- $this->assertSame( 'editor@example.org', $editor->user_email );
- $this->assertSame( 'FirstName', $editor->user_firstname );
- $this->assertSame( 'LastName', $editor->user_lastname );
- $author = get_user_by( 'login', 'author' );
- $this->assertSame( 'author', $author->user_login );
- $this->assertSame( 'author@example.org', $author->user_email );
-
- // Check that terms were imported correctly.
- $this->assertSame( '30', wp_count_terms( array( 'taxonomy' => 'category' ) ) );
- $this->assertSame( '3', wp_count_terms( array( 'taxonomy' => 'post_tag' ) ) );
- $foo = get_term_by( 'slug', 'foo', 'category' );
- $this->assertSame( 0, $foo->parent );
- $bar = get_term_by( 'slug', 'bar', 'category' );
- $foo_bar = get_term_by( 'slug', 'foo-bar', 'category' );
- $this->assertSame( $bar->term_id, $foo_bar->parent );
-
- // Check that posts/pages were imported correctly.
- $post_count = wp_count_posts( 'post' );
- $this->assertSame( '5', $post_count->publish );
- $this->assertSame( '1', $post_count->private );
- $page_count = wp_count_posts( 'page' );
- $this->assertSame( '4', $page_count->publish );
- $this->assertSame( '1', $page_count->draft );
- $comment_count = wp_count_comments();
- $this->assertSame( 1, $comment_count->total_comments );
-
- $posts = get_posts(
- array(
- 'numberposts' => 20,
- 'post_type' => 'any',
- 'post_status' => 'any',
- 'orderby' => 'ID',
- )
- );
- $this->assertCount( 11, $posts );
-
- $post = $posts[0];
- $this->assertSame( 'Many Categories', $post->post_title );
- $this->assertSame( 'many-categories', $post->post_name );
- $this->assertEquals( $admin->ID, $post->post_author );
- $this->assertSame( 'post', $post->post_type );
- $this->assertSame( 'publish', $post->post_status );
- $this->assertSame( 0, $post->post_parent );
- $cats = wp_get_post_categories( $post->ID );
- $this->assertCount( 27, $cats );
-
- $post = $posts[1];
- $this->assertSame( 'Non-standard post format', $post->post_title );
- $this->assertSame( 'non-standard-post-format', $post->post_name );
- $this->assertEquals( $admin->ID, $post->post_author );
- $this->assertSame( 'post', $post->post_type );
- $this->assertSame( 'publish', $post->post_status );
- $this->assertSame( 0, $post->post_parent );
- $cats = wp_get_post_categories( $post->ID );
- $this->assertCount( 1, $cats );
- $this->assertTrue( has_post_format( 'aside', $post->ID ) );
-
- $post = $posts[2];
- $this->assertSame( 'Top-level Foo', $post->post_title );
- $this->assertSame( 'top-level-foo', $post->post_name );
- $this->assertEquals( $admin->ID, $post->post_author );
- $this->assertSame( 'post', $post->post_type );
- $this->assertSame( 'publish', $post->post_status );
- $this->assertSame( 0, $post->post_parent );
- $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) );
- $this->assertCount( 1, $cats );
- $this->assertSame( 'foo', $cats[0]->slug );
-
- $post = $posts[3];
- $this->assertSame( 'Foo-child', $post->post_title );
- $this->assertSame( 'foo-child', $post->post_name );
- $this->assertEquals( $editor->ID, $post->post_author );
- $this->assertSame( 'post', $post->post_type );
- $this->assertSame( 'publish', $post->post_status );
- $this->assertSame( 0, $post->post_parent );
- $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) );
- $this->assertCount( 1, $cats );
- $this->assertSame( 'foo-bar', $cats[0]->slug );
-
- $post = $posts[4];
- $this->assertSame( 'Private Post', $post->post_title );
- $this->assertSame( 'private-post', $post->post_name );
- $this->assertEquals( $admin->ID, $post->post_author );
- $this->assertSame( 'post', $post->post_type );
- $this->assertSame( 'private', $post->post_status );
- $this->assertSame( 0, $post->post_parent );
- $cats = wp_get_post_categories( $post->ID );
- $this->assertCount( 1, $cats );
- $tags = wp_get_post_tags( $post->ID );
- $this->assertCount( 3, $tags );
- $this->assertSame( 'tag1', $tags[0]->slug );
- $this->assertSame( 'tag2', $tags[1]->slug );
- $this->assertSame( 'tag3', $tags[2]->slug );
-
- $post = $posts[5];
- $this->assertSame( '1-col page', $post->post_title );
- $this->assertSame( '1-col-page', $post->post_name );
- $this->assertEquals( $admin->ID, $post->post_author );
- $this->assertSame( 'page', $post->post_type );
- $this->assertSame( 'publish', $post->post_status );
- $this->assertSame( 0, $post->post_parent );
- $this->assertSame( 'onecolumn-page.php', get_post_meta( $post->ID, '_wp_page_template', true ) );
-
- $post = $posts[6];
- $this->assertSame( 'Draft Page', $post->post_title );
- $this->assertSame( '', $post->post_name );
- $this->assertEquals( $admin->ID, $post->post_author );
- $this->assertSame( 'page', $post->post_type );
- $this->assertSame( 'draft', $post->post_status );
- $this->assertSame( 0, $post->post_parent );
- $this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) );
-
- $post = $posts[7];
- $this->assertSame( 'Parent Page', $post->post_title );
- $this->assertSame( 'parent-page', $post->post_name );
- $this->assertEquals( $admin->ID, $post->post_author );
- $this->assertSame( 'page', $post->post_type );
- $this->assertSame( 'publish', $post->post_status );
- $this->assertSame( 0, $post->post_parent );
- $this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) );
-
- $post = $posts[8];
- $this->assertSame( 'Child Page', $post->post_title );
- $this->assertSame( 'child-page', $post->post_name );
- $this->assertEquals( $admin->ID, $post->post_author );
- $this->assertSame( 'page', $post->post_type );
- $this->assertSame( 'publish', $post->post_status );
- $this->assertSame( $posts[7]->ID, $post->post_parent );
- $this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) );
-
- $post = $posts[9];
- $this->assertSame( 'Sample Page', $post->post_title );
- $this->assertSame( 'sample-page', $post->post_name );
- $this->assertEquals( $admin->ID, $post->post_author );
- $this->assertSame( 'page', $post->post_type );
- $this->assertSame( 'publish', $post->post_status );
- $this->assertSame( 0, $post->post_parent );
- $this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) );
-
- $post = $posts[10];
- $this->assertSame( 'Hello world!', $post->post_title );
- $this->assertSame( 'hello-world', $post->post_name );
- $this->assertEquals( $author->ID, $post->post_author );
- $this->assertSame( 'post', $post->post_type );
- $this->assertSame( 'publish', $post->post_status );
- $this->assertSame( 0, $post->post_parent );
- $cats = wp_get_post_categories( $post->ID );
- $this->assertCount( 1, $cats );
- }
-
- /**
- * @covers WP_Import::import
- */
- public function test_double_import() {
- $authors = array(
- 'admin' => false,
- 'editor' => false,
- 'author' => false,
- );
- $this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors );
- $this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors );
-
- $user_count = count_users();
- $this->assertSame( 3, $user_count['total_users'] );
- $admin = get_user_by( 'login', 'admin' );
- $this->assertSame( 'admin', $admin->user_login );
- $this->assertSame( 'local@host.null', $admin->user_email );
- $editor = get_user_by( 'login', 'editor' );
- $this->assertSame( 'editor', $editor->user_login );
- $this->assertSame( 'editor@example.org', $editor->user_email );
- $this->assertSame( 'FirstName', $editor->user_firstname );
- $this->assertSame( 'LastName', $editor->user_lastname );
- $author = get_user_by( 'login', 'author' );
- $this->assertSame( 'author', $author->user_login );
- $this->assertSame( 'author@example.org', $author->user_email );
-
- $this->assertSame( '30', wp_count_terms( array( 'taxonomy' => 'category' ) ) );
- $this->assertSame( '3', wp_count_terms( array( 'taxonomy' => 'post_tag' ) ) );
- $foo = get_term_by( 'slug', 'foo', 'category' );
- $this->assertSame( 0, $foo->parent );
- $bar = get_term_by( 'slug', 'bar', 'category' );
- $foo_bar = get_term_by( 'slug', 'foo-bar', 'category' );
- $this->assertSame( $bar->term_id, $foo_bar->parent );
-
- $post_count = wp_count_posts( 'post' );
- $this->assertSame( '5', $post_count->publish );
- $this->assertSame( '1', $post_count->private );
- $page_count = wp_count_posts( 'page' );
- $this->assertSame( '4', $page_count->publish );
- $this->assertSame( '1', $page_count->draft );
- $comment_count = wp_count_comments();
- $this->assertSame( 1, $comment_count->total_comments );
- }
-
- /**
</del><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_importers
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_ordering_of_importers() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -269,30 +29,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_importers = $_wp_importers; // Restore global state.
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- /**
- * @ticket 21007
- *
- * @covers WP_Import::import
- */
- 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 );
- }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsimportparserphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/import/parser.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/import/parser.php 2025-02-06 17:25:01 UTC (rev 59768)
+++ trunk/tests/phpunit/tests/import/parser.php 2025-02-06 17:51:01 UTC (rev 59769)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,341 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-require_once __DIR__ . '/base.php';
-
-/**
- * @group import
- */
-class Tests_Import_Parser extends WP_Import_UnitTestCase {
- public function set_up() {
- parent::set_up();
-
- if ( ! defined( 'WP_IMPORTING' ) ) {
- define( 'WP_IMPORTING', true );
- }
-
- if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) {
- define( 'WP_LOAD_IMPORTERS', true );
- }
-
- $this->require_importer();
- }
-
- /**
- * @covers WXR_Parser_SimpleXML::parse
- * @covers WXR_Parser_XML::parse
- */
- public function test_malformed_wxr() {
- if ( PHP_VERSION_ID >= 80400 ) {
- $this->markTestSkipped( 'The Importer plugin is not ready for PHP 8.4 yet. This skip should be removed once it is.' );
- }
-
- $file = DIR_TESTDATA . '/export/malformed.xml';
-
- // Regex based parser cannot detect malformed XML.
- foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML' ) as $p ) {
- $parser = new $p();
- $result = $parser->parse( $file );
- $this->assertWPError( $result );
- $this->assertSame( 'There was an error when reading this WXR file', $result->get_error_message() );
- }
- }
-
- /**
- * @covers WXR_Parser_SimpleXML::parse
- * @covers WXR_Parser_XML::parse
- * @covers WXR_Parser_Regex::parse
- */
- public function test_invalid_wxr() {
- if ( PHP_VERSION_ID >= 80400 ) {
- $this->markTestSkipped( 'The Importer plugin is not ready for PHP 8.4 yet. This skip should be removed once it is.' );
- }
-
- $f1 = DIR_TESTDATA . '/export/missing-version-tag.xml';
- $f2 = DIR_TESTDATA . '/export/invalid-version-tag.xml';
-
- foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) {
- foreach ( array( $f1, $f2 ) as $file ) {
- $parser = new $p();
- $result = $parser->parse( $file );
- $this->assertWPError( $result );
- $this->assertSame( 'This does not appear to be a WXR file, missing/invalid WXR version number', $result->get_error_message() );
- }
- }
- }
-
- /**
- * @covers WXR_Parser_SimpleXML::parse
- * @covers WXR_Parser_XML::parse
- * @covers WXR_Parser_Regex::parse
- */
- public function test_wxr_version_1_1() {
- if ( PHP_VERSION_ID >= 80400 ) {
- $this->markTestSkipped( 'The Importer plugin is not ready for PHP 8.4 yet. This skip should be removed once it is.' );
- }
-
- $file = DIR_TESTDATA . '/export/valid-wxr-1.1.xml';
-
- foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) {
- $message = $p . ' failed';
- $parser = new $p();
- $result = $parser->parse( $file );
-
- $this->assertIsArray( $result, $message );
- $this->assertSame( 'http://localhost/', $result['base_url'], $message );
- $this->assertEqualSetsWithIndex(
- array(
- 'author_id' => 2,
- 'author_login' => 'john',
- 'author_email' => 'johndoe@example.org',
- 'author_display_name' => 'John Doe',
- 'author_first_name' => 'John',
- 'author_last_name' => 'Doe',
- ),
- $result['authors']['john'],
- $message
- );
- $this->assertEqualSetsWithIndex(
- array(
- 'term_id' => 3,
- 'category_nicename' => 'alpha',
- 'category_parent' => '',
- 'cat_name' => 'alpha',
- 'category_description' => 'The alpha category',
- ),
- $result['categories'][0],
- $message
- );
- $this->assertEqualSetsWithIndex(
- array(
- 'term_id' => 22,
- 'tag_slug' => 'clippable',
- 'tag_name' => 'Clippable',
- 'tag_description' => 'The Clippable post_tag',
- ),
- $result['tags'][0],
- $message
- );
- $this->assertEqualSetsWithIndex(
- array(
- 'term_id' => 40,
- 'term_taxonomy' => 'post_tax',
- 'slug' => 'bieup',
- 'term_parent' => '',
- 'term_name' => 'bieup',
- 'term_description' => 'The bieup post_tax',
- ),
- $result['terms'][0],
- $message
- );
-
- $this->assertCount( 2, $result['posts'], $message );
- $this->assertCount( 19, $result['posts'][0], $message );
- $this->assertCount( 18, $result['posts'][1], $message );
- $this->assertEqualSetsWithIndex(
- array(
- array(
- 'name' => 'alpha',
- 'slug' => 'alpha',
- 'domain' => 'category',
- ),
- array(
- 'name' => 'Clippable',
- 'slug' => 'clippable',
- 'domain' => 'post_tag',
- ),
- array(
- 'name' => 'bieup',
- 'slug' => 'bieup',
- 'domain' => 'post_tax',
- ),
- ),
- $result['posts'][0]['terms'],
- $message
- );
- $this->assertSame(
- array(
- array(
- 'key' => '_wp_page_template',
- 'value' => 'default',
- ),
- ),
- $result['posts'][1]['postmeta'],
- $message
- );
- }
- }
-
- /**
- * @covers WXR_Parser_SimpleXML::parse
- * @covers WXR_Parser_XML::parse
- * @covers WXR_Parser_Regex::parse
- */
- public function test_wxr_version_1_0() {
- if ( PHP_VERSION_ID >= 80400 ) {
- $this->markTestSkipped( 'The Importer plugin is not ready for PHP 8.4 yet. This skip should be removed once it is.' );
- }
-
- $file = DIR_TESTDATA . '/export/valid-wxr-1.0.xml';
-
- foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) {
- $message = $p . ' failed';
- $parser = new $p();
- $result = $parser->parse( $file );
-
- $this->assertIsArray( $result, $message );
- $this->assertSame( 'http://localhost/', $result['base_url'], $message );
- $this->assertSame( $result['categories'][0]['category_nicename'], 'alpha', $message );
- $this->assertSame( $result['categories'][0]['cat_name'], 'alpha', $message );
- $this->assertSame( $result['categories'][0]['category_parent'], '', $message );
- $this->assertSame( $result['categories'][0]['category_description'], 'The alpha category', $message );
- $this->assertSame( $result['tags'][0]['tag_slug'], 'chicken', $message );
- $this->assertSame( $result['tags'][0]['tag_name'], 'chicken', $message );
-
- $this->assertCount( 6, $result['posts'], $message );
- $this->assertCount( 19, $result['posts'][0], $message );
- $this->assertCount( 18, $result['posts'][1], $message );
-
- $this->assertEquals(
- array(
- array(
- 'name' => 'Uncategorized',
- 'slug' => 'uncategorized',
- 'domain' => 'category',
- ),
- ),
- $result['posts'][0]['terms'],
- $message
- );
- $this->assertEquals(
- array(
- array(
- 'name' => 'alpha',
- 'slug' => 'alpha',
- 'domain' => 'category',
- ),
- array(
- 'name' => 'news',
- 'slug' => 'news',
- 'domain' => 'tag',
- ),
- array(
- 'name' => 'roar',
- 'slug' => 'roar',
- 'domain' => 'tag',
- ),
- ),
- $result['posts'][2]['terms'],
- $message
- );
- $this->assertEquals(
- array(
- array(
- 'name' => 'chicken',
- 'slug' => 'chicken',
- 'domain' => 'tag',
- ),
- array(
- 'name' => 'child',
- 'slug' => 'child',
- 'domain' => 'category',
- ),
- array(
- 'name' => 'face',
- 'slug' => 'face',
- 'domain' => 'tag',
- ),
- ),
- $result['posts'][3]['terms'],
- $message
- );
-
- $this->assertSame(
- array(
- array(
- 'key' => '_wp_page_template',
- 'value' => 'default',
- ),
- ),
- $result['posts'][1]['postmeta'],
- $message
- );
- }
- }
-
- /**
- * Test the WXR parser's ability to correctly retrieve content from CDATA
- * sections that contain escaped closing tags ("]]>" -> "]]]]><![CDATA[>").
- *
- * @link https://core.trac.wordpress.org/ticket/15203
- *
- * @covers WXR_Parser_SimpleXML::parse
- * @covers WXR_Parser_XML::parse
- * @covers WXR_Parser_Regex::parse
- */
- public function test_escaped_cdata_closing_sequence() {
- if ( PHP_VERSION_ID >= 80400 ) {
- $this->markTestSkipped( 'The Importer plugin is not ready for PHP 8.4 yet. This skip should be removed once it is.' );
- }
-
- $file = DIR_TESTDATA . '/export/crazy-cdata-escaped.xml';
-
- foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) {
- $message = 'Parser ' . $p;
- $parser = new $p();
- $result = $parser->parse( $file );
-
- $post = $result['posts'][0];
- $this->assertSame( 'Content with nested <![CDATA[ tags ]]> :)', $post['post_content'], $message );
- foreach ( $post['postmeta'] as $meta ) {
- switch ( $meta['key'] ) {
- case 'Plain string':
- $value = 'Foo';
- break;
- case 'Closing CDATA':
- $value = ']]>';
- break;
- case 'Alot of CDATA':
- $value = 'This has <![CDATA[ opening and ]]> closing <![CDATA[ tags like this: ]]>';
- break;
- default:
- $this->fail( sprintf( 'Unknown postmeta (%1$s) was parsed out by %2$s.', $meta['key'], $p ) );
- }
- $this->assertSame( $value, $meta['value'], $message );
- }
- }
- }
-
- /**
- * Ensure that the regex parser can still parse invalid CDATA blocks (i.e. those
- * with "]]>" unescaped within a CDATA section).
- *
- * @covers WXR_Parser_Regex::parse
- */
- public function test_unescaped_cdata_closing_sequence() {
- $file = DIR_TESTDATA . '/export/crazy-cdata.xml';
-
- $parser = new WXR_Parser_Regex();
- $result = $parser->parse( $file );
-
- $post = $result['posts'][0];
- $this->assertSame( 'Content with nested <![CDATA[ tags ]]> :)', $post['post_content'] );
- foreach ( $post['postmeta'] as $meta ) {
- switch ( $meta['key'] ) {
- case 'Plain string':
- $value = 'Foo';
- break;
- case 'Closing CDATA':
- $value = ']]>';
- break;
- case 'Alot of CDATA':
- $value = 'This has <![CDATA[ opening and ]]> closing <![CDATA[ tags like this: ]]>';
- break;
- default:
- $this->fail( sprintf( 'Unknown postmeta (%1$s) was parsed out by %2$s.', $meta['key'], $p ) );
- }
- $this->assertSame( $value, $meta['value'] );
- }
- }
-
- // Tags in CDATA #11574.
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsimportpostmetaphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/import/postmeta.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/import/postmeta.php 2025-02-06 17:25:01 UTC (rev 59768)
+++ trunk/tests/phpunit/tests/import/postmeta.php 2025-02-06 17:51:01 UTC (rev 59769)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,100 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-require_once __DIR__ . '/base.php';
-
-/**
- * @group import
- *
- * @covers WP_Import::import
- */
-class Tests_Import_Postmeta extends WP_Import_UnitTestCase {
- public function set_up() {
- parent::set_up();
-
- if ( ! defined( 'WP_IMPORTING' ) ) {
- define( 'WP_IMPORTING', true );
- }
-
- if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) {
- define( 'WP_LOAD_IMPORTERS', true );
- }
-
- $this->require_importer();
- }
-
- public function test_serialized_postmeta_no_cdata() {
- $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-no-cdata.xml', array( 'johncoswell' => 'john' ) );
- $expected['special_post_title'] = 'A special title';
- $expected['is_calendar'] = '';
- $this->assertSame( $expected, get_post_meta( 122, 'post-options', true ) );
- }
-
- public function test_utw_postmeta() {
- $this->_import_wp( DIR_TESTDATA . '/export/test-utw-post-meta-import.xml', array( 'johncoswell' => 'john' ) );
-
- $classy = new StdClass();
- $classy->tag = 'album';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'apple';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'art';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'artwork';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'dead-tracks';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'ipod';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'itunes';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'javascript';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'lyrics';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'script';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'tracks';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'windows-scripting-host';
- $expected[] = $classy;
- $classy = new StdClass();
- $classy->tag = 'wscript';
- $expected[] = $classy;
-
- $this->assertEqualSets( $expected, get_post_meta( 150, 'test', true ) );
- }
-
- /**
- * @ticket 9633
- */
- public function test_serialized_postmeta_with_cdata() {
- $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) );
-
- // HTML in the CDATA should work with old WordPress version.
- $this->assertSame( '<pre>some html</pre>', get_post_meta( 10, 'contains-html', true ) );
- // Serialised will only work with 3.0 onwards.
- $expected['special_post_title'] = 'A special title';
- $expected['is_calendar'] = '';
- $this->assertSame( $expected, get_post_meta( 10, 'post-options', true ) );
- }
-
- /**
- * @ticket 11574
- */
- public function test_serialized_postmeta_with_evil_stuff_in_cdata() {
- $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) );
- // Evil content in the CDATA.
- $this->assertSame( '<wp:meta_value>evil</wp:meta_value>', get_post_meta( 10, 'evil', true ) );
- }
-}
</del></span></pre></div>
<a id="trunktoolslocalenvscriptsinstalljs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tools/local-env/scripts/install.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tools/local-env/scripts/install.js 2025-02-06 17:25:01 UTC (rev 59768)
+++ trunk/tools/local-env/scripts/install.js 2025-02-06 17:51:01 UTC (rev 59769)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -26,8 +26,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Move wp-config.php to the base directory, so it doesn't get mixed up in the src or build directories.
</span><span class="cx" style="display: block; padding: 0 10px"> renameSync( `${process.env.LOCAL_DIR}/wp-config.php`, 'wp-config.php' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-install_wp_importer();
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Read in wp-tests-config-sample.php, edit it to work with our config, then write it to wp-tests-config.php.
</span><span class="cx" style="display: block; padding: 0 10px"> const testConfig = readFileSync( 'wp-tests-config-sample.php', 'utf8' )
</span><span class="cx" style="display: block; padding: 0 10px"> .replace( 'youremptytestdbnamehere', 'wordpress_develop_tests' )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -57,14 +55,3 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> execSync( `docker compose ${composeFiles} run --quiet-pull --rm cli ${cmd} --path=/var/www/${process.env.LOCAL_DIR}`, { stdio: 'inherit' } );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-/**
- * Downloads the WordPress Importer plugin for use in tests.
- */
-function install_wp_importer() {
- const testPluginDirectory = 'tests/phpunit/data/plugins/wordpress-importer';
- const composeFiles = local_env_utils.get_compose_files();
-
- execSync( `docker compose ${composeFiles} exec -T php rm -rf ${testPluginDirectory}`, { stdio: 'inherit' } );
- execSync( `docker compose ${composeFiles} exec -T php git clone https://github.com/WordPress/wordpress-importer.git ${testPluginDirectory} --depth=1`, { stdio: 'inherit' } );
-}
</del></span></pre>
</div>
</div>
</body>
</html>