-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache user API call for 5 minutes (#907)
- Loading branch information
1 parent
7566f98
commit 25c8bfa
Showing
5 changed files
with
27 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,9 @@ public function testShouldReturnFalseWhenFetchedUserData() { | |
'is_monthly' => true, | ||
]; | ||
|
||
Functions\when( 'imagify_get_cached_user' )->justReturn( false ); | ||
Functions\when( 'get_transient' )->justReturn( false ); | ||
Functions\when( 'get_imagify_user' )->justReturn( $userData ); | ||
Functions\when( 'set_transient')->justReturn(); | ||
|
||
$this->assertFalse( ( new User() )->get_error() ); | ||
} | ||
|
@@ -55,8 +56,9 @@ public function testShouldReturnFromCachedUserDataIfAvailable() { | |
'is_monthly' => true, | ||
]; | ||
|
||
Functions\when( 'imagify_get_cached_user' )->justReturn( $userData ); | ||
Functions\when( 'get_transient' )->justReturn( $userData ); | ||
Functions\expect( 'get_imagify_user' )->never(); | ||
Functions\when( 'set_transient')->justReturn(); | ||
|
||
$this->assertSame( '[email protected]', ( new User() )->email ); | ||
} | ||
|
@@ -67,8 +69,9 @@ public function testShouldReturnFromCachedUserDataIfAvailable() { | |
public function testShouldReturnErrorWhenCouldNotFetchUserData() { | ||
$wp_error = new WP_Error( 'error_id', 'Error Message' ); | ||
|
||
Functions\when( 'imagify_get_cached_user' )->justReturn( false ); | ||
Functions\when( 'get_transient' )->justReturn( false ); | ||
Functions\when( 'get_imagify_user' )->justReturn( $wp_error ); | ||
Functions\when( 'set_transient')->justReturn(); | ||
|
||
$this->assertSame( $wp_error, ( new User() )->get_error() ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters