Make WordPress Core

Ticket #22807: transient.diff

File transient.diff, 1019 bytes (added by sandyr, 12 years ago)

Unit test case to cover the case of transient timeout being set

  • tests/phpunit/tests/option/transient.php

     
    3333                $this->assertEquals( $value, get_transient( $key ) );
    3434                $this->assertTrue( delete_transient( $key ) );
    3535        }
    36 }
     36       
     37        function test_transient_data_with_timeout() {
     38                $key = rand_str();
     39                $value = rand_str();
     40                $value2 = rand_str();
     41               
     42                $this->assertTrue( set_transient( $key, $value,1 ) );
     43                sleep(2);
     44                $this->assertFalse( get_transient( $key ));
     45        }
     46       
     47        function test_transient_change_timeout() {
     48                $key = rand_str();
     49                $value = rand_str();
     50                $value2 = rand_str();
     51                $this->assertTrue( set_transient( $key, $value) );
     52                $this->assertEquals($value,get_transient( $key) );
     53                $this->assertTrue( set_transient( $key, $value2, 1) ); //Setting a timeout
     54                sleep(2);
     55                $this->assertFalse( get_transient( $key ));
     56        }
     57}
     58 No newline at end of file