Skip to content

Commit

Permalink
Merge pull request #48 from ocean90/add/transient-list
Browse files Browse the repository at this point in the history
Introduce a list command to list all transients
  • Loading branch information
schlessera committed Dec 1, 2018
2 parents 9e7a786 + 40c24e7 commit 4ac6efc
Show file tree
Hide file tree
Showing 2 changed files with 393 additions and 0 deletions.
190 changes: 190 additions & 0 deletions features/transient.feature
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,193 @@ Feature: Manage WordPress transient cache
"""
bar6
"""

Scenario: List transients on single site
Given a WP install
And I run `wp transient set foo bar`
And I run `wp transient set foo2 bar2 610`
And I run `wp option update _transient_timeout_foo2 95649119999`
And I run `wp transient set foo3 bar3 300`
And I run `wp option update _transient_timeout_foo3 1321009871`
And I run `wp transient set foo4 bar4 --network`
And I run `wp transient set foo5 bar5 610 --network`
And I run `wp option update _site_transient_timeout_foo5 95649119999`
And I run `wp transient set foo6 bar6 300 --network`
And I run `wp option update _site_transient_timeout_foo6 1321009871`

When I run `wp transient list --format=csv`
Then STDOUT should be:
"""
name,value,expiration
foo,bar,false
foo2,bar2,95649119999
foo3,bar3,1321009871
"""

When I run `wp transient list --format=csv --human-readable`
Then STDOUT should contain:
"""
foo,bar,"never expires"
"""
And STDOUT should contain:
"""
foo3,bar3,expired
"""
And STDOUT should not contain:
"""
foo2,bar2,95649119999
"""

When I run `wp transient list --network --format=csv`
Then STDOUT should be:
"""
name,value,expiration
foo4,bar4,false
foo5,bar5,95649119999
foo6,bar6,1321009871
"""

Scenario: List transients on multisite
Given a WP multisite install
And I run `wp transient set foo bar`
And I run `wp transient set foo2 bar2 610`
And I run `wp option update _transient_timeout_foo2 95649119999`
And I run `wp transient set foo3 bar3 300`
And I run `wp option update _transient_timeout_foo3 1321009871`
And I run `wp transient set foo4 bar4 --network`
And I run `wp transient set foo5 bar5 610 --network`
And I run `wp site option update _site_transient_timeout_foo5 95649119999`
And I run `wp transient set foo6 bar6 300 --network`
And I run `wp site option update _site_transient_timeout_foo6 1321009871`

When I run `wp transient list --format=csv`
Then STDOUT should be:
"""
name,value,expiration
foo,bar,false
foo2,bar2,95649119999
foo3,bar3,1321009871
"""

When I run `wp transient list --format=csv --human-readable`
Then STDOUT should contain:
"""
foo,bar,"never expires"
"""
And STDOUT should contain:
"""
foo3,bar3,expired
"""
And STDOUT should not contain:
"""
foo2,bar2,95649119999
"""

When I run `wp transient list --network --format=csv`
Then STDOUT should be:
"""
name,value,expiration
foo4,bar4,false
foo5,bar5,95649119999
foo6,bar6,1321009871
"""

Scenario: List transients with search and exclude pattern
Given a WP install
And I run `wp transient set foo bar`
And I run `wp transient set foo2 bar2`
And I run `wp transient set foo3 bar3`
And I run `wp transient set foo4 bar4 --network`
And I run `wp transient set foo5 bar5 --network`

When I run `wp transient list --format=csv --fields=name --search="foo"`
Then STDOUT should be:
"""
name
foo
"""

When I run `wp transient list --format=csv --fields=name --search="foo*"`
Then STDOUT should be:
"""
name
foo
foo2
foo3
"""

When I run `wp transient list --format=csv --fields=name --search="*oo"`
Then STDOUT should be:
"""
name
foo
"""

When I run `wp transient list --format=csv --fields=name --search="*oo*"`
Then STDOUT should be:
"""
name
foo
foo2
foo3
"""

When I run `wp transient list --format=csv --fields=name --search="*oo?"`
Then STDOUT should be:
"""
name
foo2
foo3
"""

When I run `wp transient list --format=csv --fields=name --search="foo?"`
Then STDOUT should be:
"""
name
foo2
foo3
"""

When I run `wp transient list --format=csv --fields=name --search="doesnotexist*"`
Then STDOUT should be:
"""
name
"""

When I run `wp transient list --format=csv --fields=name --search="foo*" --exclude="foo2"`
Then STDOUT should be:
"""
name
foo
foo3
"""

When I run `wp transient list --format=csv --fields=name --search="foo*" --exclude="*3"`
Then STDOUT should be:
"""
name
foo
foo2
"""

When I run `wp transient list --format=csv --fields=name --search="foo*" --exclude="foo?"`
Then STDOUT should be:
"""
name
foo
"""

When I run `wp transient list --format=csv --fields=name --search="foo*" --network`
Then STDOUT should be:
"""
name
foo4
foo5
"""

When I run `wp transient list --format=csv --fields=name --search="foo*" --exclude="foo5" --network`
Then STDOUT should be:
"""
name
foo4
"""
Loading

0 comments on commit 4ac6efc

Please sign in to comment.