Skip to content

Commit 98762f2

Browse files
swissspidyclaude
andcommitted
Cover the paths the first round of tests missed
Three gaps, all raised on the pull request. Only '--post_modified' was ever passed, so the branch that fills in the local time from a GMT one was never run. It has a scenario now, and to make the derivation visible rather than incidental the site is put in a timezone with an offset: noon GMT is 07:00 in New York in January and 08:00 in June, and both are asserted, on create and on update. The scenario for the default modification date asserted only that the field was not empty, which a stale value satisfies just as well as a fresh one. It now sets a known date first and asserts the update does not leave it behind. Neither of the user scenarios ran on multisite, where the user is made by wpmu_create_user() with a login, a password and an email, and everything else is applied afterwards by wp_update_user(). That is a different path to wp_insert_user() and it is covered now. Both new scenarios fail against main, where the nicename comes back as the login instead. The multisite login is 'robert' rather than 'bob' because multisite requires four characters, which is a good illustration of why the branch was worth testing separately. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014SSZzqMJRDTiLiDxQEPYcL
1 parent 2b500b4 commit 98762f2

2 files changed

Lines changed: 102 additions & 1 deletion

File tree

‎features/post.feature‎

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,15 +724,71 @@ Feature: Manage WordPress posts
724724
Scenario: A post's modification date defaults to the current time
725725
Given a WP install
726726

727-
When I run `wp post create --post_title='Undated post' --post_status=publish --porcelain`
727+
# Given a known modification date, so that an update which failed to set one
728+
# would leave this value behind and be caught.
729+
When I run `wp post create --post_title='Undated post' --post_status=publish --post_modified='2019-02-03 04:05:06' --porcelain`
728730
Then STDOUT should be a number
729731
And save STDOUT as {POST_ID}
730732

733+
When I run `wp post get {POST_ID} --field=post_modified`
734+
Then STDOUT should be:
735+
"""
736+
2019-02-03 04:05:06
737+
"""
738+
731739
When I run `wp post update {POST_ID} --post_title='Retitled'`
732740
Then STDOUT should be:
733741
"""
734742
Success: Updated post {POST_ID}.
735743
"""
736744

737745
When I run `wp post get {POST_ID} --field=post_modified`
746+
Then STDOUT should not contain:
747+
"""
748+
2019-02-03 04:05:06
749+
"""
750+
And STDOUT should not be empty
751+
752+
Scenario: Setting only the GMT modification date derives the local one
753+
Given a WP install
754+
755+
# A timezone with an offset, so the derived local value is distinguishable
756+
# from the GMT one it was derived from. 1 January is outside DST in New York.
757+
When I run `wp option update timezone_string 'America/New_York'`
738758
Then STDOUT should not be empty
759+
760+
When I run `wp post create --post_title='GMT only' --post_status=publish --post_modified_gmt='2020-01-01 12:00:00' --porcelain`
761+
Then STDOUT should be a number
762+
And save STDOUT as {POST_ID}
763+
764+
When I run `wp post get {POST_ID} --field=post_modified_gmt`
765+
Then STDOUT should be:
766+
"""
767+
2020-01-01 12:00:00
768+
"""
769+
770+
When I run `wp post get {POST_ID} --field=post_modified`
771+
Then STDOUT should be:
772+
"""
773+
2020-01-01 07:00:00
774+
"""
775+
776+
# And the same on update, which takes the other of the two code paths.
777+
When I run `wp post update {POST_ID} --post_modified_gmt='2020-06-01 12:00:00'`
778+
Then STDOUT should be:
779+
"""
780+
Success: Updated post {POST_ID}.
781+
"""
782+
783+
When I run `wp post get {POST_ID} --field=post_modified_gmt`
784+
Then STDOUT should be:
785+
"""
786+
2020-06-01 12:00:00
787+
"""
788+
789+
# June is inside DST, so the offset is four hours rather than five.
790+
When I run `wp post get {POST_ID} --field=post_modified`
791+
Then STDOUT should be:
792+
"""
793+
2020-06-01 08:00:00
794+
"""

‎features/user.feature‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,3 +849,48 @@ Feature: Manage WordPress users
849849
"""
850850
true
851851
"""
852+
853+
# Multisite creates the user through wpmu_create_user(), which takes only a
854+
# login, a password and an email, and then applies the rest with
855+
# wp_update_user(). That is a different path to wp_insert_user(), so both
856+
# fields are worth asserting again here.
857+
Scenario: Create a user with a nicename and rich editing preference on multisite
858+
Given a WP multisite install
859+
860+
# Multisite requires a login of at least four characters, and a login that
861+
# differs from the nicename shows the nicename was applied rather than
862+
# derived.
863+
When I run `wp user create robert robert@example.com --user_nicename=bobby --rich_editing=false --porcelain`
864+
Then STDOUT should be a number
865+
And save STDOUT as {USER_ID}
866+
867+
When I run `wp user get {USER_ID} --field=user_nicename`
868+
Then STDOUT should be:
869+
"""
870+
bobby
871+
"""
872+
873+
When I run `wp user meta get {USER_ID} rich_editing`
874+
Then STDOUT should be:
875+
"""
876+
false
877+
"""
878+
879+
Scenario: Creating a user without a nicename falls back to the login on multisite
880+
Given a WP multisite install
881+
882+
When I run `wp user create carol carol@example.com --porcelain`
883+
Then STDOUT should be a number
884+
And save STDOUT as {USER_ID}
885+
886+
When I run `wp user get {USER_ID} --field=user_nicename`
887+
Then STDOUT should be:
888+
"""
889+
carol
890+
"""
891+
892+
When I run `wp user meta get {USER_ID} rich_editing`
893+
Then STDOUT should be:
894+
"""
895+
true
896+
"""

0 commit comments

Comments
 (0)