Skip to content

Commit 5b5d358

Browse files
author
desrosj
committed
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 #42668. git-svn-id: https://develop.svn.wordpress.org/trunk@59769 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 76a89c2 commit 5b5d358

File tree

6 files changed

+1
-798
lines changed

6 files changed

+1
-798
lines changed

tests/phpunit/includes/bootstrap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@
214214
define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
215215
define( 'DIR_TESTDATA', __DIR__ . '/../data' );
216216
define( 'DIR_TESTROOT', realpath( dirname( __DIR__ ) ) );
217-
define( 'IMPORTER_PLUGIN_FOR_TESTS', DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php' );
218217

219218
define( 'WP_LANG_DIR', realpath( DIR_TESTDATA . '/languages' ) );
220219

tests/phpunit/tests/import/base.php

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 1 addition & 267 deletions
Original file line numberDiff line numberDiff line change
@@ -1,249 +1,9 @@
11
<?php
22

3-
require_once __DIR__ . '/base.php';
4-
53
/**
64
* @group import
75
*/
8-
class Tests_Import_Import extends WP_Import_UnitTestCase {
9-
public function set_up() {
10-
global $wpdb;
11-
12-
parent::set_up();
13-
14-
if ( ! defined( 'WP_IMPORTING' ) ) {
15-
define( 'WP_IMPORTING', true );
16-
}
17-
18-
if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) {
19-
define( 'WP_LOAD_IMPORTERS', true );
20-
}
21-
22-
add_filter( 'import_allow_create_users', '__return_true' );
23-
24-
$this->require_importer();
25-
26-
// Crude but effective: make sure there's no residual data in the main tables.
27-
foreach ( array( 'posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta' ) as $table ) {
28-
$wpdb->query( "DELETE FROM {$wpdb->$table}" );
29-
}
30-
}
31-
32-
/**
33-
* @covers WP_Import::import
34-
*/
35-
public function test_small_import() {
36-
global $wpdb;
37-
38-
$authors = array(
39-
'admin' => false,
40-
'editor' => false,
41-
'author' => false,
42-
);
43-
$this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors );
44-
45-
// Ensure that authors were imported correctly.
46-
$user_count = count_users();
47-
$this->assertSame( 3, $user_count['total_users'] );
48-
$admin = get_user_by( 'login', 'admin' );
49-
$this->assertSame( 'admin', $admin->user_login );
50-
$this->assertSame( '[email protected]', $admin->user_email );
51-
$editor = get_user_by( 'login', 'editor' );
52-
$this->assertSame( 'editor', $editor->user_login );
53-
$this->assertSame( '[email protected]', $editor->user_email );
54-
$this->assertSame( 'FirstName', $editor->user_firstname );
55-
$this->assertSame( 'LastName', $editor->user_lastname );
56-
$author = get_user_by( 'login', 'author' );
57-
$this->assertSame( 'author', $author->user_login );
58-
$this->assertSame( '[email protected]', $author->user_email );
59-
60-
// Check that terms were imported correctly.
61-
$this->assertSame( '30', wp_count_terms( array( 'taxonomy' => 'category' ) ) );
62-
$this->assertSame( '3', wp_count_terms( array( 'taxonomy' => 'post_tag' ) ) );
63-
$foo = get_term_by( 'slug', 'foo', 'category' );
64-
$this->assertSame( 0, $foo->parent );
65-
$bar = get_term_by( 'slug', 'bar', 'category' );
66-
$foo_bar = get_term_by( 'slug', 'foo-bar', 'category' );
67-
$this->assertSame( $bar->term_id, $foo_bar->parent );
68-
69-
// Check that posts/pages were imported correctly.
70-
$post_count = wp_count_posts( 'post' );
71-
$this->assertSame( '5', $post_count->publish );
72-
$this->assertSame( '1', $post_count->private );
73-
$page_count = wp_count_posts( 'page' );
74-
$this->assertSame( '4', $page_count->publish );
75-
$this->assertSame( '1', $page_count->draft );
76-
$comment_count = wp_count_comments();
77-
$this->assertSame( 1, $comment_count->total_comments );
78-
79-
$posts = get_posts(
80-
array(
81-
'numberposts' => 20,
82-
'post_type' => 'any',
83-
'post_status' => 'any',
84-
'orderby' => 'ID',
85-
)
86-
);
87-
$this->assertCount( 11, $posts );
88-
89-
$post = $posts[0];
90-
$this->assertSame( 'Many Categories', $post->post_title );
91-
$this->assertSame( 'many-categories', $post->post_name );
92-
$this->assertEquals( $admin->ID, $post->post_author );
93-
$this->assertSame( 'post', $post->post_type );
94-
$this->assertSame( 'publish', $post->post_status );
95-
$this->assertSame( 0, $post->post_parent );
96-
$cats = wp_get_post_categories( $post->ID );
97-
$this->assertCount( 27, $cats );
98-
99-
$post = $posts[1];
100-
$this->assertSame( 'Non-standard post format', $post->post_title );
101-
$this->assertSame( 'non-standard-post-format', $post->post_name );
102-
$this->assertEquals( $admin->ID, $post->post_author );
103-
$this->assertSame( 'post', $post->post_type );
104-
$this->assertSame( 'publish', $post->post_status );
105-
$this->assertSame( 0, $post->post_parent );
106-
$cats = wp_get_post_categories( $post->ID );
107-
$this->assertCount( 1, $cats );
108-
$this->assertTrue( has_post_format( 'aside', $post->ID ) );
109-
110-
$post = $posts[2];
111-
$this->assertSame( 'Top-level Foo', $post->post_title );
112-
$this->assertSame( 'top-level-foo', $post->post_name );
113-
$this->assertEquals( $admin->ID, $post->post_author );
114-
$this->assertSame( 'post', $post->post_type );
115-
$this->assertSame( 'publish', $post->post_status );
116-
$this->assertSame( 0, $post->post_parent );
117-
$cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) );
118-
$this->assertCount( 1, $cats );
119-
$this->assertSame( 'foo', $cats[0]->slug );
120-
121-
$post = $posts[3];
122-
$this->assertSame( 'Foo-child', $post->post_title );
123-
$this->assertSame( 'foo-child', $post->post_name );
124-
$this->assertEquals( $editor->ID, $post->post_author );
125-
$this->assertSame( 'post', $post->post_type );
126-
$this->assertSame( 'publish', $post->post_status );
127-
$this->assertSame( 0, $post->post_parent );
128-
$cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) );
129-
$this->assertCount( 1, $cats );
130-
$this->assertSame( 'foo-bar', $cats[0]->slug );
131-
132-
$post = $posts[4];
133-
$this->assertSame( 'Private Post', $post->post_title );
134-
$this->assertSame( 'private-post', $post->post_name );
135-
$this->assertEquals( $admin->ID, $post->post_author );
136-
$this->assertSame( 'post', $post->post_type );
137-
$this->assertSame( 'private', $post->post_status );
138-
$this->assertSame( 0, $post->post_parent );
139-
$cats = wp_get_post_categories( $post->ID );
140-
$this->assertCount( 1, $cats );
141-
$tags = wp_get_post_tags( $post->ID );
142-
$this->assertCount( 3, $tags );
143-
$this->assertSame( 'tag1', $tags[0]->slug );
144-
$this->assertSame( 'tag2', $tags[1]->slug );
145-
$this->assertSame( 'tag3', $tags[2]->slug );
146-
147-
$post = $posts[5];
148-
$this->assertSame( '1-col page', $post->post_title );
149-
$this->assertSame( '1-col-page', $post->post_name );
150-
$this->assertEquals( $admin->ID, $post->post_author );
151-
$this->assertSame( 'page', $post->post_type );
152-
$this->assertSame( 'publish', $post->post_status );
153-
$this->assertSame( 0, $post->post_parent );
154-
$this->assertSame( 'onecolumn-page.php', get_post_meta( $post->ID, '_wp_page_template', true ) );
155-
156-
$post = $posts[6];
157-
$this->assertSame( 'Draft Page', $post->post_title );
158-
$this->assertSame( '', $post->post_name );
159-
$this->assertEquals( $admin->ID, $post->post_author );
160-
$this->assertSame( 'page', $post->post_type );
161-
$this->assertSame( 'draft', $post->post_status );
162-
$this->assertSame( 0, $post->post_parent );
163-
$this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) );
164-
165-
$post = $posts[7];
166-
$this->assertSame( 'Parent Page', $post->post_title );
167-
$this->assertSame( 'parent-page', $post->post_name );
168-
$this->assertEquals( $admin->ID, $post->post_author );
169-
$this->assertSame( 'page', $post->post_type );
170-
$this->assertSame( 'publish', $post->post_status );
171-
$this->assertSame( 0, $post->post_parent );
172-
$this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) );
173-
174-
$post = $posts[8];
175-
$this->assertSame( 'Child Page', $post->post_title );
176-
$this->assertSame( 'child-page', $post->post_name );
177-
$this->assertEquals( $admin->ID, $post->post_author );
178-
$this->assertSame( 'page', $post->post_type );
179-
$this->assertSame( 'publish', $post->post_status );
180-
$this->assertSame( $posts[7]->ID, $post->post_parent );
181-
$this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) );
182-
183-
$post = $posts[9];
184-
$this->assertSame( 'Sample Page', $post->post_title );
185-
$this->assertSame( 'sample-page', $post->post_name );
186-
$this->assertEquals( $admin->ID, $post->post_author );
187-
$this->assertSame( 'page', $post->post_type );
188-
$this->assertSame( 'publish', $post->post_status );
189-
$this->assertSame( 0, $post->post_parent );
190-
$this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) );
191-
192-
$post = $posts[10];
193-
$this->assertSame( 'Hello world!', $post->post_title );
194-
$this->assertSame( 'hello-world', $post->post_name );
195-
$this->assertEquals( $author->ID, $post->post_author );
196-
$this->assertSame( 'post', $post->post_type );
197-
$this->assertSame( 'publish', $post->post_status );
198-
$this->assertSame( 0, $post->post_parent );
199-
$cats = wp_get_post_categories( $post->ID );
200-
$this->assertCount( 1, $cats );
201-
}
202-
203-
/**
204-
* @covers WP_Import::import
205-
*/
206-
public function test_double_import() {
207-
$authors = array(
208-
'admin' => false,
209-
'editor' => false,
210-
'author' => false,
211-
);
212-
$this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors );
213-
$this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors );
214-
215-
$user_count = count_users();
216-
$this->assertSame( 3, $user_count['total_users'] );
217-
$admin = get_user_by( 'login', 'admin' );
218-
$this->assertSame( 'admin', $admin->user_login );
219-
$this->assertSame( '[email protected]', $admin->user_email );
220-
$editor = get_user_by( 'login', 'editor' );
221-
$this->assertSame( 'editor', $editor->user_login );
222-
$this->assertSame( '[email protected]', $editor->user_email );
223-
$this->assertSame( 'FirstName', $editor->user_firstname );
224-
$this->assertSame( 'LastName', $editor->user_lastname );
225-
$author = get_user_by( 'login', 'author' );
226-
$this->assertSame( 'author', $author->user_login );
227-
$this->assertSame( '[email protected]', $author->user_email );
228-
229-
$this->assertSame( '30', wp_count_terms( array( 'taxonomy' => 'category' ) ) );
230-
$this->assertSame( '3', wp_count_terms( array( 'taxonomy' => 'post_tag' ) ) );
231-
$foo = get_term_by( 'slug', 'foo', 'category' );
232-
$this->assertSame( 0, $foo->parent );
233-
$bar = get_term_by( 'slug', 'bar', 'category' );
234-
$foo_bar = get_term_by( 'slug', 'foo-bar', 'category' );
235-
$this->assertSame( $bar->term_id, $foo_bar->parent );
236-
237-
$post_count = wp_count_posts( 'post' );
238-
$this->assertSame( '5', $post_count->publish );
239-
$this->assertSame( '1', $post_count->private );
240-
$page_count = wp_count_posts( 'page' );
241-
$this->assertSame( '4', $page_count->publish );
242-
$this->assertSame( '1', $page_count->draft );
243-
$comment_count = wp_count_comments();
244-
$this->assertSame( 1, $comment_count->total_comments );
245-
}
246-
6+
class Tests_Import_Import extends WP_UnitTestCase {
2477
/**
2488
* @covers ::get_importers
2499
*/
@@ -269,30 +29,4 @@ public function test_ordering_of_importers() {
26929
);
27030
$wp_importers = $_wp_importers; // Restore global state.
27131
}
272-
273-
/**
274-
* @ticket 21007
275-
*
276-
* @covers WP_Import::import
277-
*/
278-
public function test_slashes_should_not_be_stripped() {
279-
global $wpdb;
280-
281-
$authors = array( 'admin' => false );
282-
$this->_import_wp( DIR_TESTDATA . '/export/slashes.xml', $authors );
283-
284-
$alpha = get_term_by( 'slug', 'alpha', 'category' );
285-
$this->assertSame( 'a \"great\" category', $alpha->name );
286-
287-
$tag1 = get_term_by( 'slug', 'tag1', 'post_tag' );
288-
$this->assertSame( "foo\'bar", $tag1->name );
289-
290-
$posts = get_posts(
291-
array(
292-
'post_type' => 'any',
293-
'post_status' => 'any',
294-
)
295-
);
296-
$this->assertSame( 'Slashes aren\\\'t \"cool\"', $posts[0]->post_content );
297-
}
29832
}

0 commit comments

Comments
 (0)