Skip to content

Commit 6057e09

Browse files
committed
Test the order of terms with the same name across batches
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS
1 parent 600421d commit 6057e09

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎features/export.feature‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,8 @@ Feature: Export content.
13721372
And I run `wp post generate --count=150`
13731373
And I run `wp post create --post_title='Last post' --post_status=publish --tags_input='Zoo,apple,beta' --porcelain`
13741374
And save STDOUT as {LAST_POST_ID}
1375+
And I run `wp term create category Zoo --slug=zoo-category`
1376+
And I run `wp post term add {LAST_POST_ID} category zoo-category`
13751377
And I run `wp post meta add {LAST_POST_ID} my_meta_key my_meta_value`
13761378
And I run `wp post meta add {LAST_POST_ID} _edit_lock 123:1`
13771379
And I run `wp comment create --comment_post_ID={LAST_POST_ID} --comment_content='Approved comment' --comment_approved=1 --porcelain`
@@ -1399,10 +1401,12 @@ Feature: Export content.
13991401
foreach ( $xml->channel->item as $item ) {
14001402
$wp = $item->children( 'http://wordpress.org/export/1.2/' );
14011403
$tags = array();
1404+
$terms = array();
14021405
foreach ( $item->category as $category ) {
14031406
if ( 'post_tag' === (string) $category['domain'] ) {
14041407
$tags[] = (string) $category['nicename'];
14051408
}
1409+
$terms[] = (string) $category['nicename'];
14061410
}
14071411
$meta = array();
14081412
foreach ( $wp->postmeta as $postmeta ) {
@@ -1422,13 +1426,13 @@ Feature: Export content.
14221426
if ( (string) $wp->post_id === '{LAST_POST_ID}' ) {
14231427
++$found;
14241428
// The terms should be in the same order as the database returns them for the post.
1425-
$expected = wp_list_pluck( wp_get_object_terms( (int) $wp->post_id, 'post_tag' ), 'slug' );
1426-
echo 'tags in database order: ' . ( $tags === $expected ? 'yes' : 'no' ) . "\n";
1429+
$expected = wp_list_pluck( wp_get_object_terms( (int) $wp->post_id, get_object_taxonomies( 'post' ) ), 'slug' );
1430+
echo 'terms in database order: ' . ( $terms === $expected ? 'yes' : 'no' ) . "\n";
14271431
sort( $tags );
14281432
echo 'tags: ' . implode( ',', $tags ) . "\n";
14291433
echo 'meta: ' . implode( ',', $meta ) . "\n";
14301434
echo 'comments: ' . implode( ',', $comments ) . "\n";
1431-
} elseif ( $tags || $meta || $comments ) {
1435+
} elseif ( $tags || $meta || $comments || array( 'uncategorized' ) !== $terms ) {
14321436
echo 'unexpected data on post ' . $wp->post_id . "\n";
14331437
}
14341438
}
@@ -1441,7 +1445,7 @@ Feature: Export content.
14411445
When I run `wp eval-file check-export.php {EXPORT_FILE}`
14421446
Then STDOUT should be:
14431447
"""
1444-
tags in database order: yes
1448+
terms in database order: yes
14451449
tags: apple,beta,zoo
14461450
meta: my_meta_key=my_meta_value
14471451
comments: Approved comment [my_comment_meta_key=my_comment_meta_value]

0 commit comments

Comments
 (0)