|
| 1 | +Feature: Create Duplicate WordPress post from existing posts. |
| 2 | + |
| 3 | + Background: |
| 4 | + Given a WP install |
| 5 | + |
| 6 | + Scenario: Generate duplicate post. |
| 7 | + When I run `wp term create category "Test Category" --porcelain` |
| 8 | + Then save STDOUT as {TERM_ID} |
| 9 | + |
| 10 | + When I run `wp post create --post_title='Test Duplicate Post' --post_category={TERM_ID} --porcelain` |
| 11 | + And save STDOUT as {POST_ID} |
| 12 | + |
| 13 | + When I run `wp post create --from-post={POST_ID} --porcelain` |
| 14 | + Then STDOUT should be a number |
| 15 | + And save STDOUT as {DUPLICATE_POST_ID} |
| 16 | + |
| 17 | + When I run `wp post get {DUPLICATE_POST_ID} --field=title` |
| 18 | + Then STDOUT should be: |
| 19 | + """ |
| 20 | + Test Duplicate Post |
| 21 | + """ |
| 22 | + |
| 23 | + When I run `wp post term list {DUPLICATE_POST_ID} category --field=term_id` |
| 24 | + Then STDOUT should be: |
| 25 | + """ |
| 26 | + {TERM_ID} |
| 27 | + """ |
| 28 | + |
| 29 | + Scenario: Generate duplicate post with post metadata. |
| 30 | + When I run `wp post create --post_title='Test Post' --meta_input='{"key1":"value1","key2":"value2"}' --porcelain` |
| 31 | + Then save STDOUT as {POST_ID} |
| 32 | + |
| 33 | + When I run `wp post create --from-post={POST_ID} --porcelain` |
| 34 | + Then save STDOUT as {DUPLICATE_POST_ID} |
| 35 | + |
| 36 | + When I run `wp post meta list {DUPLICATE_POST_ID} --format=table` |
| 37 | + Then STDOUT should be a table containing rows: |
| 38 | + | post_id | meta_key | meta_value | |
| 39 | + | {DUPLICATE_POST_ID} | key1 | value1 | |
| 40 | + | {DUPLICATE_POST_ID} | key2 | value2 | |
| 41 | + |
| 42 | + Scenario: Generate duplicate page. |
| 43 | + When I run `wp post create --post_type="page" --post_title="Test Page" --post_content="Page Content" --porcelain` |
| 44 | + Then save STDOUT as {POST_ID} |
| 45 | + |
| 46 | + When I run `wp post create --from-post={POST_ID} --post_title="Duplicate Page" --porcelain` |
| 47 | + Then save STDOUT as {DUPLICATE_POST_ID} |
| 48 | + |
| 49 | + When I run `wp post list --post_type='page' --fields="title, content, type"` |
| 50 | + Then STDOUT should be a table containing rows: |
| 51 | + | post_title | post_content | post_type | |
| 52 | + | Test Page | Page Content | page | |
| 53 | + | Duplicate Page | Page Content | page | |
| 54 | + |
| 55 | + Scenario: Change type of duplicate post. |
| 56 | + When I run `wp post create --post_title='Test Post' --porcelain` |
| 57 | + Then save STDOUT as {POST_ID} |
| 58 | + |
| 59 | + When I run `wp post create --from-post={POST_ID} --post_type=page --porcelain` |
| 60 | + Then save STDOUT as {DUPLICATE_POST_ID} |
| 61 | + |
| 62 | + When I run `wp post get {DUPLICATE_POST_ID} --fields=type` |
| 63 | + Then STDOUT should be a table containing rows: |
| 64 | + | Field | Value | |
| 65 | + | post_type | page | |
0 commit comments