Changeset 42343 for trunk/tests/phpunit/tests/import/import.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/import/import.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/import/import.php
r41169 r42343 10 10 parent::setUp(); 11 11 12 if ( ! defined( 'WP_IMPORTING' ) ) 12 if ( ! defined( 'WP_IMPORTING' ) ) { 13 13 define( 'WP_IMPORTING', true ); 14 15 if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) 14 } 15 16 if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) { 16 17 define( 'WP_LOAD_IMPORTERS', true ); 18 } 17 19 18 20 add_filter( 'import_allow_create_users', '__return_true' ); … … 26 28 global $wpdb; 27 29 // crude but effective: make sure there's no residual data in the main tables 28 foreach ( array('posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta') as $table) 29 $wpdb->query("DELETE FROM {$wpdb->$table}"); 30 foreach ( array( 'posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta' ) as $table ) { 31 $wpdb->query( "DELETE FROM {$wpdb->$table}" ); 32 } 30 33 } 31 34 … … 39 42 global $wpdb; 40 43 41 $authors = array( 'admin' => false, 'editor' => false, 'author' => false ); 44 $authors = array( 45 'admin' => false, 46 'editor' => false, 47 'author' => false, 48 ); 42 49 $this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors ); 43 50 … … 62 69 $foo = get_term_by( 'slug', 'foo', 'category' ); 63 70 $this->assertEquals( 0, $foo->parent ); 64 $bar = get_term_by( 'slug', 'bar', 'category' );71 $bar = get_term_by( 'slug', 'bar', 'category' ); 65 72 $foo_bar = get_term_by( 'slug', 'foo-bar', 'category' ); 66 73 $this->assertEquals( $bar->term_id, $foo_bar->parent ); … … 76 83 $this->assertEquals( 1, $comment_count->total_comments ); 77 84 78 $posts = get_posts( array( 'numberposts' => 20, 'post_type' => 'any', 'post_status' => 'any', 'orderby' => 'ID' ) ); 79 $this->assertEquals( 11, count($posts) ); 85 $posts = get_posts( 86 array( 87 'numberposts' => 20, 88 'post_type' => 'any', 89 'post_status' => 'any', 90 'orderby' => 'ID', 91 ) 92 ); 93 $this->assertEquals( 11, count( $posts ) ); 80 94 81 95 $post = $posts[0]; … … 87 101 $this->assertEquals( 0, $post->post_parent ); 88 102 $cats = wp_get_post_categories( $post->ID ); 89 $this->assertEquals( 27, count( $cats) );103 $this->assertEquals( 27, count( $cats ) ); 90 104 91 105 $post = $posts[1]; … … 97 111 $this->assertEquals( 0, $post->post_parent ); 98 112 $cats = wp_get_post_categories( $post->ID ); 99 $this->assertEquals( 1, count( $cats) );113 $this->assertEquals( 1, count( $cats ) ); 100 114 $this->assertTrue( has_post_format( 'aside', $post->ID ) ); 101 115 … … 108 122 $this->assertEquals( 0, $post->post_parent ); 109 123 $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) ); 110 $this->assertEquals( 1, count( $cats) );124 $this->assertEquals( 1, count( $cats ) ); 111 125 $this->assertEquals( 'foo', $cats[0]->slug ); 112 126 … … 119 133 $this->assertEquals( 0, $post->post_parent ); 120 134 $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) ); 121 $this->assertEquals( 1, count( $cats) );135 $this->assertEquals( 1, count( $cats ) ); 122 136 $this->assertEquals( 'foo-bar', $cats[0]->slug ); 123 137 … … 130 144 $this->assertEquals( 0, $post->post_parent ); 131 145 $cats = wp_get_post_categories( $post->ID ); 132 $this->assertEquals( 1, count( $cats) );146 $this->assertEquals( 1, count( $cats ) ); 133 147 $tags = wp_get_post_tags( $post->ID ); 134 $this->assertEquals( 3, count( $tags) );148 $this->assertEquals( 3, count( $tags ) ); 135 149 $this->assertEquals( 'tag1', $tags[0]->slug ); 136 150 $this->assertEquals( 'tag2', $tags[1]->slug ); … … 190 204 $this->assertEquals( 0, $post->post_parent ); 191 205 $cats = wp_get_post_categories( $post->ID ); 192 $this->assertEquals( 1, count( $cats) );206 $this->assertEquals( 1, count( $cats ) ); 193 207 } 194 208 195 209 function test_double_import() { 196 $authors = array( 'admin' => false, 'editor' => false, 'author' => false ); 210 $authors = array( 211 'admin' => false, 212 'editor' => false, 213 'author' => false, 214 ); 197 215 $this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors ); 198 216 $this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors ); … … 216 234 $foo = get_term_by( 'slug', 'foo', 'category' ); 217 235 $this->assertEquals( 0, $foo->parent ); 218 $bar = get_term_by( 'slug', 'bar', 'category' );236 $bar = get_term_by( 'slug', 'bar', 'category' ); 219 237 $foo_bar = get_term_by( 'slug', 'foo-bar', 'category' ); 220 238 $this->assertEquals( $bar->term_id, $foo_bar->parent ); … … 233 251 global $wp_importers; 234 252 $_wp_importers = $wp_importers; // Preserve global state 235 $wp_importers = array(253 $wp_importers = array( 236 254 'xyz1' => array( 'xyz1' ), 237 255 'XYZ2' => array( 'XYZ2' ), … … 240 258 'def1' => array( 'def1' ), 241 259 ); 242 $this->assertEquals( array( 243 'ABC1' => array( 'ABC1' ), 244 'abc2' => array( 'abc2' ), 245 'def1' => array( 'def1' ), 246 'xyz1' => array( 'xyz1' ), 247 'XYZ2' => array( 'XYZ2' ), 248 ), get_importers() ); 260 $this->assertEquals( 261 array( 262 'ABC1' => array( 'ABC1' ), 263 'abc2' => array( 'abc2' ), 264 'def1' => array( 'def1' ), 265 'xyz1' => array( 'xyz1' ), 266 'XYZ2' => array( 'XYZ2' ), 267 ), get_importers() 268 ); 249 269 $wp_importers = $_wp_importers; // Restore global state 250 270 } … … 265 285 $this->assertSame( "foo\'bar", $tag1->name ); 266 286 267 $posts = get_posts( array( 'post_type' => 'any', 'post_status' => 'any' ) ); 287 $posts = get_posts( 288 array( 289 'post_type' => 'any', 290 'post_status' => 'any', 291 ) 292 ); 268 293 $this->assertSame( 'Slashes aren\\\'t \"cool\"', $posts[0]->post_content ); 269 294 }
Note: See TracChangeset
for help on using the changeset viewer.