Skip to content

Add support for --post_date_gmt in post generate#184

Merged
schlessera merged 4 commits intowp-cli:masterfrom
jblz:patch-1
Jul 13, 2018
Merged

Add support for --post_date_gmt in post generate#184
schlessera merged 4 commits intowp-cli:masterfrom
jblz:patch-1

Conversation

@jblz
Copy link
Copy Markdown
Contributor

@jblz jblz commented May 8, 2018

Sets the GMT / UTC date of the generated posts.

If the --post_date_gmt flag is provided, use that.
If not, default to the value of post_date (which defaults to the current date if it's not set).

Fixes #183

@jblz
Copy link
Copy Markdown
Contributor Author

jblz commented May 8, 2018

Needs Tests

@schlessera
Copy link
Copy Markdown
Member

@jblz Thanks for the pull request. Are you up for providing the tests as well?

@schlessera schlessera added the command:post-generate Related to 'post generate' command label May 15, 2018
@jblz
Copy link
Copy Markdown
Contributor Author

jblz commented May 15, 2018

Are you up for providing the tests as well?

@schlessera Happy to, but would love a pointer on where / how to add them.

I'm not seeing anything related here for example and you can probably point me in the right direction more quickly than I can figure it out on my own :)

@schlessera
Copy link
Copy Markdown
Member

@jblz The tests are done as functional tests in Behat.

You can find the current tests for wp post generate here: https://github.com/wp-cli/entity-command/blob/d44e0bfb09a63bafa5b1be0125ad619662b2f422/features/post-generate.feature

You can find an overview of how to work on tests in WP-CLI here: https://make.wordpress.org/cli/handbook/pull-requests/#running-and-writing-tests

@schlessera
Copy link
Copy Markdown
Member

@jblz Are you still up for working on the tests? Do you need further help with that?

Set the GMT date of the generated posts. Default: value of post_date (or current date if it's not set)
@jblz
Copy link
Copy Markdown
Contributor Author

jblz commented Jul 4, 2018

@schlessera Thanks for the nudge (& for the instructions on getting set up w/ behat). I managed to get my test env set up & make this actually work :)

I think it's ready for review if the CI comes back green.

"""

Scenario: Generating posts with post_date argument with time
When I run `wp post generate --count=1 --post_date="2018-07-02 00:00:00"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should use a different time here, otherwise you cannot tell whether the time was accepted as an argument or whether the default is being used.

"""

Scenario: Generating posts with post_date_gmt argument with time
When I run `wp post generate --count=1 --post_date_gmt="2018-07-04 00:00:00"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as with the post_date example, you should use a different time here, otherwise you cannot tell whether the time was accepted as an argument or whether the default is being used.

@schlessera
Copy link
Copy Markdown
Member

@jblz I'm glad to hear that! The tests look good apart from a minor nitpick with the time in two of them.

And as far as I can tell, they already uncovered a bug that you needed to fix to make the tests pass, right? So it was definitely not a waste of time to write the tests.

As soon as you have done the requested changes, this will be good to be merged.

@jblz
Copy link
Copy Markdown
Contributor Author

jblz commented Jul 4, 2018

they already uncovered a bug that you needed to fix to make the tests pass, right?

Yep! I needed to pull the current_time call out so we could tell if the caller was relying on defaults for post_date as well as post_date_gmt & do the correct thing in all cases.

So it was definitely not a waste of time to write the tests.

It rarely is!

Requested changes are in place.

@schlessera schlessera added this to the 1.3.1 milestone Jul 13, 2018
@schlessera
Copy link
Copy Markdown
Member

Thanks for the pull-request, @jblz !

@schlessera schlessera merged commit 9d3d891 into wp-cli:master Jul 13, 2018
@schlessera schlessera changed the title Post Generate: Add support for post_date_gmt Add support for --post_date_gmt in post generate Jul 13, 2018
@jblz jblz deleted the patch-1 branch July 13, 2018 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:post-generate Related to 'post generate' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants