Changeset 47122 for trunk/tests/phpunit/tests/option/transient.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/option/transient.php
r46586 r47122 94 94 */ 95 95 function test_nonexistent_key_dont_delete_if_false() { 96 // Create a bogus a transient 96 // Create a bogus a transient. 97 97 $key = 'test_transient'; 98 98 set_transient( $key, 'test', 60 * 10 ); 99 99 $this->assertEquals( 'test', get_transient( $key ) ); 100 100 101 // Useful variables for tracking 101 // Useful variables for tracking. 102 102 $transient_timeout = '_transient_timeout_' . $key; 103 103 104 // Mock an action for tracking action calls 104 // Mock an action for tracking action calls. 105 105 $a = new MockAction(); 106 106 107 // Make sure the timeout option returns false 107 // Make sure the timeout option returns false. 108 108 add_filter( 'option_' . $transient_timeout, '__return_false' ); 109 109 110 // Add some actions to make sure options are _not_ deleted 110 // Add some actions to make sure options are _not_ deleted. 111 111 add_action( 'delete_option', array( $a, 'action' ) ); 112 112 113 // Act 113 // Act. 114 114 get_transient( $key ); 115 115 116 // Make sure delete option was not called for both the transient and the timeout116 // Make sure 'delete_option' was not called for both the transient and the timeout. 117 117 $this->assertEquals( 0, $a->get_call_count() ); 118 118 } … … 122 122 */ 123 123 function test_nonexistent_key_old_timeout() { 124 // Create a transient 124 // Create a transient. 125 125 $key = 'test_transient'; 126 126 set_transient( $key, 'test', 60 * 10 ); 127 127 $this->assertEquals( 'test', get_transient( $key ) ); 128 128 129 // Make sure the timeout option returns false 129 // Make sure the timeout option returns false. 130 130 $timeout = '_transient_timeout_' . $key; 131 131 $transient_option = '_transient_' . $key; 132 132 add_filter( 'option_' . $timeout, '__return_zero' ); 133 133 134 // Mock an action for tracking action calls 134 // Mock an action for tracking action calls. 135 135 $a = new MockAction(); 136 136 137 // Add some actions to make sure options are deleted 137 // Add some actions to make sure options are deleted. 138 138 add_action( 'delete_option', array( $a, 'action' ) ); 139 139 140 // Act 140 // Act. 141 141 get_transient( $key ); 142 142 143 // Make sure delete option was called for both the transient and the timeout143 // Make sure 'delete_option' was called for both the transient and the timeout. 144 144 $this->assertEquals( 2, $a->get_call_count() ); 145 145
Note: See TracChangeset
for help on using the changeset viewer.