-
Notifications
You must be signed in to change notification settings - Fork 92
Migrate term from a taxonomy to another one #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
08f6b0b
first version, not tested yet
Mte90 356304e
first version, not tested yet
Mte90 391e876
first version, not tested yet
Mte90 56c005e
migrate to another command
Mte90 6e7e1ce
migrate to other parameters
Mte90 ed07314
next steps for importing
Mte90 9da669f
command finished
Mte90 c702f7e
Apply suggestions from code review
schlessera 3cedb9e
working on the review
Mte90 f816458
adding tests
Mte90 46b9110
finish tests
Mte90 6e49e48
fix test for wp 3.7
Mte90 0922845
Apply suggestions from code review
schlessera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| Feature: Manage term custom fields | ||
|
|
||
| @require-wp-4.4 | ||
| Scenario: Migrate an existing term by slug | ||
| Given a WP install | ||
|
|
||
| When I run `wp term create category apple` | ||
| Then STDOUT should not be empty | ||
|
|
||
| When I run `wp post create --post_title='Test post' --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {POST_ID} | ||
|
|
||
| When I run `wp post term set {POST_ID} category apple` | ||
| Then STDOUT should not be empty | ||
|
|
||
| When I run `wp term migrate apple --by=slug --from=category --to=post_tag` | ||
| Then STDOUT should be: | ||
| """ | ||
| Term 'apple' assigned to post 4. | ||
| Term 'apple' migrated. | ||
| Old instance of term 'apple' removed from its original taxonomy. | ||
| Success: Migrated the term 'apple' from taxonomy 'category' to taxonomy 'post_tag' for 1 post. | ||
| """ | ||
|
|
||
| @require-wp-4.4 | ||
| Scenario: Migrate an existing term by ID | ||
| Given a WP install | ||
|
|
||
| When I run `wp term create category apple --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {TERM_ID} | ||
|
|
||
| When I run `wp post create --post_title='Test post' --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {POST_ID} | ||
|
|
||
| When I run `wp post term set {POST_ID} category {TERM_ID}` | ||
| Then STDOUT should not be empty | ||
|
|
||
| When I run `wp term migrate {TERM_ID} --by=slug --from=category --to=post_tag` | ||
| Then STDOUT should be: | ||
| """ | ||
| Term '{TERM_ID}' assigned to post 4. | ||
| Term '{TERM_ID}' migrated. | ||
| Old instance of term '{TERM_ID}' removed from its original taxonomy. | ||
| Success: Migrated the term '{TERM_ID}' from taxonomy 'category' to taxonomy 'post_tag' for 1 post. | ||
| """ | ||
|
|
||
| @require-wp-4.4 | ||
| Scenario: Migrate a term in multiple posts | ||
| Given a WP install | ||
|
|
||
| When I run `wp term create category orange` | ||
| Then STDOUT should not be empty | ||
|
|
||
| When I run `wp post create --post_title='Test post' --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {POST_ID} | ||
|
|
||
| When I run `wp post term set {POST_ID} category orange` | ||
| Then STDOUT should not be empty | ||
|
|
||
| When I run `wp post create --post_title='Test post 2' --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {POST_ID} | ||
|
|
||
| When I run `wp post term set {POST_ID} category orange` | ||
| Then STDOUT should not be empty | ||
|
|
||
| When I run `wp term migrate orange --by=slug --from=category --to=post_tag` | ||
| Then STDOUT should be: | ||
| """ | ||
| Term 'orange' assigned to post 4. | ||
| Term 'orange' assigned to post 5. | ||
| Term 'orange' migrated. | ||
| Old instance of term 'orange' removed from its original taxonomy. | ||
| Success: Migrated the term 'orange' from taxonomy 'category' to taxonomy 'post_tag' for 2 posts. | ||
| """ | ||
|
|
||
| @require-wp-4.4 | ||
| Scenario: Try to migrate a term that does not exist | ||
| Given a WP install | ||
|
|
||
| When I try `wp term migrate peach --by=slug --from=category --to=post_tag` | ||
| Then STDERR should be: | ||
| """ | ||
| Error: Taxonomy term 'peach' for taxonomy 'category' doesn't exist. | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.