Changeset 27719 for trunk/tests/phpunit/tests/option/transient.php
- Timestamp:
- 03/25/2014 06:22:49 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/option/transient.php
r25002 r27719 34 34 $this->assertTrue( delete_transient( $key ) ); 35 35 } 36 37 /** 38 * @ticket 22807 39 */ 40 function test_transient_data_with_timeout() { 41 $key = rand_str(); 42 $value = rand_str(); 43 $value2 = rand_str(); 44 45 $this->assertFalse( get_option( '_transient_timeout_' . $key ) ); 46 $now = time(); 47 48 $this->assertTrue( set_transient( $key, $value, 100 ) ); 49 50 // Ensure the transient timeout is set for 100-101 seconds in the future. 51 $this->assertGreaterThanOrEqual( $now + 100, get_option( '_transient_timeout_' . $key ) ); 52 $this->assertLessThanOrEqual( $now + 101, get_option( '_transient_timeout_' . $key ) ); 53 54 // Update the timeout to a second in the past and watch the transient be invalidated. 55 update_option( '_transient_timeout_' . $key, $now - 1 ); 56 $this->assertFalse( get_transient( $key ) ); 57 } 58 59 /** 60 * @ticket 22807 61 */ 62 function test_transient_add_timeout() { 63 $key = rand_str(); 64 $value = rand_str(); 65 $value2 = rand_str(); 66 $this->assertTrue( set_transient( $key, $value ) ); 67 $this->assertEquals( $value, get_transient( $key ) ); 68 69 $this->assertFalse( get_option( '_transient_timeout_' . $key ) ); 70 71 $now = time(); 72 // Add timeout to existing timeout-less transient. 73 $this->assertTrue( set_transient( $key, $value2, 1 ) ); 74 $this->assertGreaterThanOrEqual( $now, get_option( '_transient_timeout_' . $key ) ); 75 76 update_option( '_transient_timeout_' . $key, $now - 1 ); 77 $this->assertFalse( get_transient( $key ) ); 78 } 36 79 }
Note: See TracChangeset
for help on using the changeset viewer.