Skip to content

Commit 0922845

Browse files
schlesseraMte90
andauthored
Apply suggestions from code review
apply second review Co-Authored-By: Mte90 <[email protected]>
1 parent 6e49e48 commit 0922845

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

features/term-migrate.feature

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Feature: Manage term custom fields
22

33
@require-wp-4.4
4-
Scenario: Migrate a term that exist
4+
Scenario: Migrate an existing term by slug
55
Given a WP install
66

77
When I run `wp term create category apple`
@@ -18,13 +18,13 @@ Feature: Manage term custom fields
1818
Then STDOUT should be:
1919
"""
2020
Term 'apple' assigned to post 4.
21-
Term 'apple' migrated!
21+
Term 'apple' migrated.
2222
Old instance of term 'apple' removed from its original taxonomy.
23-
Success: Migrated the term 'apple' from taxonomy 'category' to taxonomy 'post_tag' for 1 post
23+
Success: Migrated the term 'apple' from taxonomy 'category' to taxonomy 'post_tag' for 1 post.
2424
"""
2525

2626
@require-wp-4.4
27-
Scenario: Migrate a term that exist with id
27+
Scenario: Migrate an existing term by ID
2828
Given a WP install
2929

3030
When I run `wp term create category apple --porcelain`
@@ -42,9 +42,9 @@ Feature: Manage term custom fields
4242
Then STDOUT should be:
4343
"""
4444
Term '{TERM_ID}' assigned to post 4.
45-
Term '{TERM_ID}' migrated!
45+
Term '{TERM_ID}' migrated.
4646
Old instance of term '{TERM_ID}' removed from its original taxonomy.
47-
Success: Migrated the term '{TERM_ID}' from taxonomy 'category' to taxonomy 'post_tag' for 1 post
47+
Success: Migrated the term '{TERM_ID}' from taxonomy 'category' to taxonomy 'post_tag' for 1 post.
4848
"""
4949

5050
@require-wp-4.4
@@ -73,17 +73,17 @@ Feature: Manage term custom fields
7373
"""
7474
Term 'orange' assigned to post 4.
7575
Term 'orange' assigned to post 5.
76-
Term 'orange' migrated!
76+
Term 'orange' migrated.
7777
Old instance of term 'orange' removed from its original taxonomy.
78-
Success: Migrated the term 'orange' from taxonomy 'category' to taxonomy 'post_tag' for 2 posts
78+
Success: Migrated the term 'orange' from taxonomy 'category' to taxonomy 'post_tag' for 2 posts.
7979
"""
8080

8181
@require-wp-4.4
82-
Scenario: Migrate a term that not exist
82+
Scenario: Try to migrate a term that does not exist
8383
Given a WP install
8484

8585
When I try `wp term migrate peach --by=slug --from=category --to=post_tag`
8686
Then STDERR should be:
8787
"""
88-
Error: Taxonomy term `peach` for taxonomy `category` doesn't exist.
88+
Error: Taxonomy term 'peach' for taxonomy 'category' doesn't exist.
8989
"""

src/Term_Command.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ public function migrate( $args, $assoc_args ) {
676676
$term = get_term_by( Utils\get_flag_value( $assoc_args, 'by' ), $term_reference, $original_taxonomy );
677677

678678
if ( ! $term ) {
679-
WP_CLI::error( "Taxonomy term `{$term_reference}` for taxonomy `{$original_taxonomy}` doesn't exist." );
679+
WP_CLI::error( "Taxonomy term '{$term_reference}' for taxonomy '{$original_taxonomy}' doesn't exist." );
680680
}
681681

682682
$original_taxonomy = get_taxonomy( $original_taxonomy );
@@ -706,18 +706,18 @@ public function migrate( $args, $assoc_args ) {
706706

707707
clean_term_cache( $term->term_id );
708708

709-
WP_CLI::log( "Term '{$term->slug}' migrated!" );
709+
WP_CLI::log( "Term '{$term->slug}' migrated." );
710710

711711
$del = wp_delete_term( $term->term_id, $original_taxonomy->name );
712712

713713
if ( is_wp_error( $del ) ) {
714-
WP_CLI::error( "On deleting the term, " . $del->get_error_message() );
714+
WP_CLI::error( "Failed to delete the term '{$term->slug}'. Reason: " . $del->get_error_message() );
715715
}
716716

717717
WP_CLI::log( "Old instance of term '{$term->slug}' removed from its original taxonomy." );
718718
$post_count = count( $post_ids );
719719
$post_plural = WP_CLI\Utils\pluralize( 'post', $post_count );
720-
WP_CLI::success( "Migrated the term '{$term->slug}' from taxonomy '{$original_taxonomy->name}' to taxonomy '{$destination_taxonomy}' for {$post_count} {$post_plural}" );
720+
WP_CLI::success( "Migrated the term '{$term->slug}' from taxonomy '{$original_taxonomy->name}' to taxonomy '{$destination_taxonomy}' for {$post_count} {$post_plural}." );
721721
}
722722

723723
private function maybe_make_child() {

0 commit comments

Comments
 (0)