Changeset 42343 for trunk/tests/phpunit/tests/post/wpUniquePostSlug.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/wpUniquePostSlug.php
r39506 r42343 26 26 for ( $i = 0; $i < 2; $i++ ) { 27 27 $post = array( 28 'post_author' => $author_id,29 'post_status' => 'publish',28 'post_author' => $author_id, 29 'post_status' => 'publish', 30 30 'post_content' => 'Post content', 31 'post_title' => $post_title,31 'post_title' => $post_title, 32 32 ); 33 33 … … 36 36 37 37 $post = get_post( $id ); 38 $this->assertEquals( $outputs[ $k], urldecode( $post->post_name ) );38 $this->assertEquals( $outputs[ $k ], urldecode( $post->post_name ) ); 39 39 } 40 40 } … … 47 47 register_post_type( 'post-type-2', array( 'hierarchical' => true ) ); 48 48 49 $args = array(50 'post_type' => 'post-type-1',51 'post_name' => 'some-slug',49 $args = array( 50 'post_type' => 'post-type-1', 51 'post_name' => 'some-slug', 52 52 'post_status' => 'publish', 53 53 ); 54 $one = self::factory()->post->create( $args );54 $one = self::factory()->post->create( $args ); 55 55 $args['post_type'] = 'post-type-2'; 56 $two = self::factory()->post->create( $args );56 $two = self::factory()->post->create( $args ); 57 57 58 58 $this->assertEquals( 'some-slug', get_post( $one )->post_name ); … … 72 72 register_post_type( 'post-type-1', array( 'hierarchical' => true ) ); 73 73 74 $args = array(75 'post_type' => 'post-type-1',76 'post_name' => 'some-slug',74 $args = array( 75 'post_type' => 'post-type-1', 76 'post_name' => 'some-slug', 77 77 'post_status' => 'publish', 78 78 ); 79 $one = self::factory()->post->create( $args );79 $one = self::factory()->post->create( $args ); 80 80 $args['post_name'] = 'some-slug-2'; 81 $two = self::factory()->post->create( $args );81 $two = self::factory()->post->create( $args ); 82 82 83 83 $this->assertEquals( 'some-slug', get_post( $one )->post_name ); … … 96 96 97 97 $args = array( 98 'post_type' => 'post-type-1',99 'post_name' => 'some-slug',98 'post_type' => 'post-type-1', 99 'post_name' => 'some-slug', 100 100 'post_status' => 'publish', 101 101 ); 102 $one = self::factory()->post->create( $args ); 102 $one = self::factory()->post->create( $args ); 103 104 $args = array( 105 'post_mime_type' => 'image/jpeg', 106 'post_type' => 'attachment', 107 'post_name' => 'image', 108 ); 109 $attachment = self::factory()->attachment->create_object( 'image.jpg', $one, $args ); 103 110 104 111 $args = array( 105 'post_mime_type' => 'image/jpeg', 106 'post_type' => 'attachment', 107 'post_name' => 'image' 108 ); 109 $attachment = self::factory()->attachment->create_object( 'image.jpg', $one, $args ); 110 111 $args = array( 112 'post_type' => 'post-type-1', 113 'post_name' => 'image', 112 'post_type' => 'post-type-1', 113 'post_name' => 'image', 114 114 'post_status' => 'publish', 115 'post_parent' => $one 116 ); 117 $two = self::factory()->post->create( $args );115 'post_parent' => $one, 116 ); 117 $two = self::factory()->post->create( $args ); 118 118 119 119 $this->assertEquals( 'some-slug', get_post( $one )->post_name ); … … 131 131 */ 132 132 public function test_whitelisted_post_statuses_should_not_be_forced_to_be_unique( $status ) { 133 $p1 = self::factory()->post->create( array( 134 'post_type' => 'post', 135 'post_name' => 'foo', 136 ) ); 137 138 $p2 = self::factory()->post->create( array( 139 'post_type' => 'post', 140 ) ); 133 $p1 = self::factory()->post->create( 134 array( 135 'post_type' => 'post', 136 'post_name' => 'foo', 137 ) 138 ); 139 140 $p2 = self::factory()->post->create( 141 array( 142 'post_type' => 'post', 143 ) 144 ); 141 145 142 146 $actual = wp_unique_post_slug( 'foo', $p2, $status, 'post', 0 ); … … 154 158 155 159 public function test_revisions_should_not_be_forced_to_be_unique() { 156 $p1 = self::factory()->post->create( array( 157 'post_type' => 'post', 158 'post_name' => 'foo', 159 ) ); 160 161 $p2 = self::factory()->post->create( array( 162 'post_type' => 'post', 163 ) ); 160 $p1 = self::factory()->post->create( 161 array( 162 'post_type' => 'post', 163 'post_name' => 'foo', 164 ) 165 ); 166 167 $p2 = self::factory()->post->create( 168 array( 169 'post_type' => 'post', 170 ) 171 ); 164 172 165 173 $actual = wp_unique_post_slug( 'foo', $p2, 'inherit', 'revision', 0 ); … … 174 182 $this->set_permalink_structure( '/%postname%/' ); 175 183 176 $p = self::factory()->post->create( array( 177 'post_type' => 'post', 178 'post_name' => 'foo', 179 ) ); 184 $p = self::factory()->post->create( 185 array( 186 'post_type' => 'post', 187 'post_name' => 'foo', 188 ) 189 ); 180 190 181 191 $found = wp_unique_post_slug( '2015', $p, 'publish', 'post', 0 ); … … 189 199 $this->set_permalink_structure( '/%postname%/' ); 190 200 191 $p = self::factory()->post->create( array( 192 'post_type' => 'post', 193 'post_name' => 'foo', 194 'post_status' => 'publish', 195 ) ); 201 $p = self::factory()->post->create( 202 array( 203 'post_type' => 'post', 204 'post_name' => 'foo', 205 'post_status' => 'publish', 206 ) 207 ); 196 208 197 209 $found = wp_unique_post_slug( '2015', $p, 'publish', 'post', 0 ); … … 205 217 $this->set_permalink_structure( '/%year%/%postname%/' ); 206 218 207 $p = self::factory()->post->create( array( 208 'post_type' => 'post', 209 'post_name' => 'foo', 210 ) ); 219 $p = self::factory()->post->create( 220 array( 221 'post_type' => 'post', 222 'post_name' => 'foo', 223 ) 224 ); 211 225 212 226 $found = wp_unique_post_slug( '2015', $p, 'publish', 'post', 0 ); … … 220 234 $this->set_permalink_structure( '/%year%/%postname%/' ); 221 235 222 $p = self::factory()->post->create( array( 223 'post_type' => 'post', 224 'post_name' => 'foo', 225 ) ); 236 $p = self::factory()->post->create( 237 array( 238 'post_type' => 'post', 239 'post_name' => 'foo', 240 ) 241 ); 226 242 227 243 $found = wp_unique_post_slug( '11', $p, 'publish', 'post', 0 ); … … 235 251 $this->set_permalink_structure( '/%year%/foo/%postname%/' ); 236 252 237 $p = self::factory()->post->create( array( 238 'post_type' => 'post', 239 'post_name' => 'foo', 240 ) ); 253 $p = self::factory()->post->create( 254 array( 255 'post_type' => 'post', 256 'post_name' => 'foo', 257 ) 258 ); 241 259 242 260 $found = wp_unique_post_slug( '11', $p, 'publish', 'post', 0 ); … … 250 268 $this->set_permalink_structure( '/%year%/%postname%/' ); 251 269 252 $p = self::factory()->post->create( array( 253 'post_type' => 'post', 254 'post_name' => 'foo', 255 ) ); 270 $p = self::factory()->post->create( 271 array( 272 'post_type' => 'post', 273 'post_name' => 'foo', 274 ) 275 ); 256 276 257 277 $found = wp_unique_post_slug( '13', $p, 'publish', 'post', 0 ); … … 265 285 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 266 286 267 $p = self::factory()->post->create( array( 268 'post_type' => 'post', 269 'post_name' => 'foo', 270 ) ); 287 $p = self::factory()->post->create( 288 array( 289 'post_type' => 'post', 290 'post_name' => 'foo', 291 ) 292 ); 271 293 272 294 $found = wp_unique_post_slug( '30', $p, 'publish', 'post', 0 ); … … 280 302 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 281 303 282 $p = self::factory()->post->create( array( 283 'post_type' => 'post', 284 'post_name' => 'foo', 285 ) ); 304 $p = self::factory()->post->create( 305 array( 306 'post_type' => 'post', 307 'post_name' => 'foo', 308 ) 309 ); 286 310 287 311 $found = wp_unique_post_slug( '30', $p, 'publish', 'post', 0 ); … … 295 319 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 296 320 297 $p = self::factory()->post->create( array( 298 'post_type' => 'post', 299 'post_name' => 'foo', 300 ) ); 321 $p = self::factory()->post->create( 322 array( 323 'post_type' => 'post', 324 'post_name' => 'foo', 325 ) 326 ); 301 327 302 328 $found = wp_unique_post_slug( '32', $p, 'publish', 'post', 0 ); … … 310 336 $this->set_permalink_structure( '/%postname%/' ); 311 337 312 $p = self::factory()->post->create( array( 313 'post_type' => 'post', 314 'post_name' => 'embed', 315 ) ); 338 $p = self::factory()->post->create( 339 array( 340 'post_type' => 'post', 341 'post_name' => 'embed', 342 ) 343 ); 316 344 317 345 $found = wp_unique_post_slug( 'embed', $p, 'publish', 'post', 0 ); … … 325 353 $this->set_permalink_structure( '/%postname%/' ); 326 354 327 $p = self::factory()->post->create( array( 328 'post_type' => 'page', 329 'post_name' => 'embed', 330 ) ); 355 $p = self::factory()->post->create( 356 array( 357 'post_type' => 'page', 358 'post_name' => 'embed', 359 ) 360 ); 331 361 332 362 $found = wp_unique_post_slug( 'embed', $p, 'publish', 'paage', 0 ); … … 340 370 $this->set_permalink_structure( '/%postname%/' ); 341 371 342 $p = self::factory()->post->create( array( 343 'post_type' => 'attachment', 344 'post_name' => 'embed', 345 ) ); 372 $p = self::factory()->post->create( 373 array( 374 'post_type' => 'attachment', 375 'post_name' => 'embed', 376 ) 377 ); 346 378 347 379 $found = wp_unique_post_slug( 'embed', $p, 'publish', 'attachment', 0 );
Note: See TracChangeset
for help on using the changeset viewer.