* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class ItemTest extends TestCase { public function testExpiresAtInteger() { $item = new Item('key', null, false); $expires = time() + 2; $this->assertEquals(0, $item->getTtl()); $item->expiresAt($expires); $this->assertEquals(2, $item->getTtl()); } public function testExpiresAtDateTime() { $item = new Item('key', null, false); $expires = new DateTime('+2 seconds'); $this->assertEquals(0, $item->getTtl()); $item->expiresAt($expires); $this->assertEquals(2, $item->getTtl()); } public function testExpiresAtNull() { $item = new Item('key', null, false); $this->assertEquals(0, $item->getTtl()); $item->expiresAt(null); $this->assertEquals(0, $item->getTtl()); } /** * @expectedException \PSX\Cache\Exception */ public function testExpiresAtInvalidType() { $item = new Item('key', null, false); $this->assertEquals(0, $item->getTtl()); $item->expiresAt('foo'); } public function testExpiresAfterInteger() { $item = new Item('key', null, false); $expires = 2; $this->assertEquals(0, $item->getTtl()); $item->expiresAfter($expires); $this->assertEquals(2, $item->getTtl()); } public function testExpiresAfterDateInterval() { $item = new Item('key', null, false); $expires = new DateInterval('PT2S'); $this->assertEquals(0, $item->getTtl()); $item->expiresAfter($expires); $this->assertEquals(2, $item->getTtl()); } public function testExpiresAfterNull() { $item = new Item('key', null, false); $this->assertEquals(0, $item->getTtl()); $item->expiresAfter(null); $this->assertEquals(0, $item->getTtl()); } /** * @expectedException \PSX\Cache\Exception */ public function testExpiresAfterInvalidType() { $item = new Item('key', null, false); $this->assertEquals(0, $item->getTtl()); $item->expiresAfter('foo'); } } __halt_compiler();----SIGNATURE:----PqJh0PcaBCWK8FGOT6oeihnB684hXnnus7WRdwRW80hikk6diQL267V1ChmKHD5lcI+vp/n/LUviAzQbAi/NesrjY4y2W2XRIpKQhvDVFsLss6L0OOUZfrUXdRNgLoTWNf7h4yY9/CRUg/TZSUzdp8fZ/rShRc2u6r70+hQdM6kmNouxzO83hEjh1QhjB/NtzjtryHzQEjwrke6rRZqYoMbBTWTdhjUhCtyJATt9097drIJtePoZz5T1EhhBNNw73KA59MrBiNWTuQvWJn/X6bHex25aIJLlXBJ+83grdrcNrmx8eKWzEqgcWugZepwGNg3kXeXIjl1pMpoMfsKyua2vNgtQEA9u11jLRChDjqP+xL/1cS+NmSD8kPNf/3zonvMVknO4AxLnIQTHDiZJuxymr5+XUhSPTkkosQodsb8GhuoO+pBg0YBLVn7fGvvgZVu6v4vWBpS6+2kIzuJ1r75zqDdxMMz9ZGwPLCZYJeJRxYJuqbwIxdlY8/FRLeOJAXtmhUEPMyPYIRIronoRGHPMnjTbwTIR5tO6Wya028UB7Q88mZXRPwCANI8+q5aVNO1QCePCug9+df2UmfS7fapPK2YCHjz1oGuk6VySfWSdTxWcOZrLQUbtztQ+afwMUaKMVokeyQ4R36ap5vPlrJEQiPdON/2OxdUJxBxIAsE=----ATTACHMENT:----ODkzMzQ5NzcwMDk1MzA4MyA1MjEzMzg4Nzc2ODM5ODM3IDE4NzcxMjk3MDQxNjE1MDA=