Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d212c2e
Add `RecursiveDataStructureTraverser` helper to manipulate nested data
petitphp Jun 26, 2023
7292638
add pluck command to cache
petitphp Jun 26, 2023
8e1b63d
add pluck command to transient
petitphp Jun 26, 2023
6e286af
add patch command to cache
petitphp Jul 1, 2023
bd13459
add patch command to transient
petitphp Aug 23, 2023
05424ec
Add missing `expiration` option for patch cache command
petitphp Aug 23, 2023
ca02d28
Fix cs
petitphp Aug 28, 2023
15ad011
Update Behat features tests
petitphp Aug 31, 2023
ba1f610
Add temporary log to debug failing tests in github action
petitphp Aug 31, 2023
6b8d91c
Small CS fixes for WPCS v3
petitphp Sep 7, 2023
a70e2d7
Fix failing functional tests
petitphp Sep 15, 2023
5d0e6df
Add tests for RecursiveDataStructureTraverser.php
petitphp Sep 18, 2023
dd9eec3
Fix wrong command in docblock
petitphp Sep 19, 2023
d174717
Fix CS issue
petitphp Sep 19, 2023
ae6d0a6
Reuse has_stdin() from framework
schlessera Nov 14, 2023
b74bc47
Fix PHPCS issues
schlessera Nov 14, 2023
d28445f
Use `wp eval` to set the transient
petitphp Dec 4, 2023
b1afe2e
split `patch` feature tests and add additionnal checks with `transien…
petitphp Dec 8, 2023
8d9ba42
split `patch` feature tests for site transient and add additionnal ch…
petitphp Dec 11, 2023
7d3a483
Add test cases for invalid keys
petitphp Dec 11, 2023
d061301
Refactor `pluck` feature tests to use `wp eval` to set the transient
petitphp Dec 11, 2023
cf568fb
new feature test for calling cache pluck command with invalid key
petitphp Dec 12, 2023
3fa7fe1
add the new commands to the `composer.json`
petitphp Apr 26, 2024
119c991
use string interpolation for building message
petitphp Apr 29, 2024
2d17185
explicitly call update methods for clearer code
petitphp Apr 29, 2024
9eca4d9
fix tests
petitphp Apr 29, 2024
de71744
Merge branch 'main' into feature/pluck-patch-cache-transient
schlessera May 5, 2025
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
Prev Previous commit
Next Next commit
split patch feature tests and add additionnal checks with `transien…
…t get`
  • Loading branch information
petitphp authored and schlessera committed Aug 4, 2024
commit b1afe2e9bda21944ef7f1f4d7255ba600cb3b254
108 changes: 92 additions & 16 deletions features/transient-patch.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: Patch command available for the transient cache

Scenario: Nested values from transient can be updated at any depth.
Scenario: Nested values from transient can be inserted at any depth.
Given a WP install
And I run `wp eval "set_transient( 'my_key', ['foo' => 'bar'] );"`
And I run `wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"`
Expand All @@ -11,64 +11,140 @@ Feature: Patch command available for the transient cache
Success: Updated transient 'my_key'.
"""

When I run `wp transient patch insert my_key_2 foo fuz bar`
When I run `wp transient get my_key --format=json`
Then STDOUT should be:
"""
{"foo":"bar","fuz":"baz"}
"""

When I run `wp transient patch insert my_key foo bar`
Then STDOUT should be:
"""
Success: Value passed for transient 'my_key' is unchanged.
"""

When I run `wp transient get my_key --format=json`
Then STDOUT should be:
"""
{"foo":"bar","fuz":"baz"}
"""

When I run `wp transient patch insert my_key_2 foo fuz biz`
Then STDOUT should be:
"""
Success: Updated transient 'my_key_2'.
"""

When I try `wp transient patch insert unknown_key foo bar`
Then STDERR should be:
When I run `wp transient get my_key_2 --format=json`
Then STDOUT should be:
"""
Error: Cannot create key "foo" on data type boolean
{"foo":{"bar":"baz","fuz":"biz"}}
"""

When I run `wp transient patch insert my_key foo bar`
When I run `wp transient patch insert my_key_2 foo bar baz`
Then STDOUT should be:
"""
Success: Value passed for transient 'my_key' is unchanged.
Success: Value passed for transient 'my_key_2' is unchanged.
"""

When I run `wp transient get my_key_2 --format=json`
Then STDOUT should be:
"""
{"foo":{"bar":"baz","fuz":"biz"}}
"""

Scenario: Nested values from transient can be updated at any depth.
Given a WP install
And I run `wp eval "set_transient( 'my_key', ['foo' => 'bar'] );"`
And I run `wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"`

When I run `wp transient patch update my_key foo biz`
When I run `wp transient patch update my_key foo baz`
Then STDOUT should be:
"""
Success: Updated transient 'my_key'.
"""

When I run `wp transient get my_key --format=json`
Then STDOUT should be:
"""
{"foo":"baz"}
"""

When I run `wp transient patch update my_key foo baz`
Then STDOUT should be:
"""
Success: Value passed for transient 'my_key' is unchanged.
"""
Comment thread
swissspidy marked this conversation as resolved.

When I run `wp transient get my_key --format=json`
Then STDOUT should be:
"""
{"foo":"baz"}
"""

When I run `wp transient patch update my_key_2 foo bar biz`
Then STDOUT should be:
"""
Success: Updated transient 'my_key_2'.
"""

When I try `wp transient patch update unknown_key foo bar`
Then STDERR should be:
When I run `wp transient get my_key_2 --format=json`
Then STDOUT should be:
"""
Error: No data exists for key "foo"
{"foo":{"bar":"biz"}}
"""

When I run `wp transient patch update my_key foo bar`
When I run `wp transient patch update my_key_2 foo bar biz`
Then STDOUT should be:
"""
Success: Value passed for transient 'my_key' is unchanged.
Success: Value passed for transient 'my_key_2' is unchanged.
"""

When I run `wp transient get my_key_2 --format=json`
Then STDOUT should be:
"""
{"foo":{"bar":"biz"}}
"""

Scenario: Nested values from transient can be deleted at any depth.
Given a WP install
And I run `wp eval "set_transient( 'my_key', ['foo' => 'bar'] );"`
And I run `wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"`

When I run `wp transient patch delete my_key foo`
Then STDOUT should be:
"""
Success: Updated transient 'my_key'.
"""
Comment thread
swissspidy marked this conversation as resolved.

When I run `wp transient get my_key --format=json`
Then STDOUT should be:
"""
[]
"""

When I run `wp transient patch delete my_key_2 foo bar`
Then STDOUT should be:
"""
Success: Updated transient 'my_key_2'.
"""

When I try `wp transient patch delete unknown_key foo`
Then STDERR should be:
When I run `wp transient get my_key_2 --format=json`
Then STDOUT should be:
"""
Error: No data exists for key "foo"
{"foo":[]}
"""

When I run `wp transient patch delete my_key_2 foo`
Then STDOUT should be:
"""
Success: Updated transient 'my_key_2'.
"""

When I run `wp transient get my_key_2 --format=json`
Then STDOUT should be:
"""
[]
"""

Scenario: Nested values from site transient can be updated at any depth.
Expand Down