Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 34 additions & 11 deletions features/export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Feature: Export content.
"""

When I run `wp export --post_type=page --post_status=draft`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Then ... steps normally denote assertion steps, but this is still setup. If we would want to be more correct with the Behat syntax here, we would not turn it into When...Then, but rather into Given... And to show that this is still setup, and not the act/assert part.

But given this is unrelated to the current PR, I would just avoid these changes for now to keep the PR more focused.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have followed the examples in the previous tests in export.features.
Perhaps the similar rows must be changed as well.


When I run `wp site empty --yes`
Then STDOUT should not be empty
Expand Down Expand Up @@ -100,7 +100,7 @@ Feature: Export content.
"""

When I run `wp export --post_type=page,post`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}

When I run `wp site empty --yes`
Then STDOUT should not be empty
Expand Down Expand Up @@ -175,8 +175,7 @@ Feature: Export content.
"""

When I run `wp export --post__in={POST_ID}`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}

Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
And the {EXPORT_FILE} file should not contain:
"""
<wp:post_id>{ATTACHMENT_ID}</wp:post_id>
Expand Down Expand Up @@ -223,7 +222,7 @@ Feature: Export content.
And save STDOUT as {POST_ID_TWO}

When I run `wp export --post__in="{POST_ID} {POST_ID_TWO}"`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}

When I run `wp site empty --yes`
Then STDOUT should not be empty
Expand Down Expand Up @@ -256,7 +255,7 @@ Feature: Export content.
And save STDOUT as {POST_ID_TWO}

When I run `wp export --post__in="{POST_ID},{POST_ID_TWO}"`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}

When I run `wp site empty --yes`
Then STDOUT should not be empty
Expand Down Expand Up @@ -291,7 +290,7 @@ Feature: Export content.
"""

When I run `wp export --post_type=post --start_date=2013-08-02 --end_date=2013-08-02`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}

When I run `wp site empty --yes`
Then STDOUT should not be empty
Expand Down Expand Up @@ -522,7 +521,7 @@ Feature: Export content.
"""

When I run `wp export --start_id=6`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}

When I run `wp site empty --yes`
Then STDOUT should not be empty
Expand Down Expand Up @@ -557,7 +556,7 @@ Feature: Export content.
"""

When I run `wp export --post_type__not_in=post`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}

When I run `wp site empty --yes`
Then STDOUT should not be empty
Expand Down Expand Up @@ -585,7 +584,7 @@ Feature: Export content.
"""

When I run `wp export --post_type__not_in=post,page`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}

When I run `wp site empty --yes`
Then STDOUT should not be empty
Expand Down Expand Up @@ -662,7 +661,7 @@ Feature: Export content.
"""

When I run `wp export --skip_comments`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}

When I run `wp site empty --yes`
Then STDOUT should not be empty
Expand Down Expand Up @@ -1292,3 +1291,27 @@ Feature: Export content.
"""
2
"""

Scenario: Export term meta
Given a WP install

When I run `wp term meta add 1 term_metakey term_metavalue`
Then STDOUT should contain:
"""
Success:
"""

When I run `wp export`
And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
Then the {EXPORT_FILE} file should contain:
"""
<wp:termmeta>
"""
And the {EXPORT_FILE} file should contain:
"""
<wp:meta_key><![CDATA[term_metakey]]></wp:meta_key>
"""
And the {EXPORT_FILE} file should contain:
"""
<wp:meta_value><![CDATA[term_metavalue]]></wp:meta_value>
"""
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<!-- For help understanding the `testVersion` configuration setting:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="5.6-"/>
<config name="testVersion" value="7.2-"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this coming from a missing rebase or did You manually introduce this unrelated change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't talk to me. I have not changed this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a missing rebase: 976d08f


<!-- Verify that everything in the global namespace is either namespaced or prefixed.
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
Expand Down
18 changes: 18 additions & 0 deletions src/WP_Export_WXR_Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function categories() {
->tag( 'wp:category_parent', $category->parent_slug )
->optional_cdata( 'wp:cat_name', $category->name )
->optional_cdata( 'wp:category_description', $category->description )
->oxymel( $this->term_meta( $category ) )
->end;
}
return $oxymel->to_string();
Expand Down Expand Up @@ -256,6 +257,7 @@ protected function terms( $terms ) {
$oxymel
->optional_cdata( 'wp:term_name', $term->name )
->optional_cdata( 'wp:term_description', $term->description )
->oxymel( $this->term_meta( $term ) )
->end;
}
return $oxymel->to_string();
Expand All @@ -276,4 +278,20 @@ protected function comment_meta( $comment ) {
}
return $oxymel;
}

protected function term_meta( $term ) {
global $wpdb;
$metas = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->termmeta WHERE term_id = %d", $term->term_id ) );
if ( ! $metas ) {
return new Oxymel();
}
$oxymel = new WP_Export_Oxymel();
foreach ( $metas as $meta ) {
$oxymel->tag( 'wp:termmeta' )->contains
->tag( 'wp:meta_key' )->contains->cdata( $meta->meta_key )->end
->tag( 'wp:meta_value' )->contains->cdata( $meta->meta_value )->end
->end;
}
return $oxymel;
}
}