_key1 = uniqid(microtime(true), true); $this->_key2 = uniqid(microtime(true), true); $this->_cache = new Swift_KeyCache_DiskKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream(), sys_get_temp_dir()); } public function testStringDataCanBeSetAndFetched() { $this->_cache->setString( $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE ); $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); } public function testStringDataCanBeOverwritten() { $this->_cache->setString( $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE ); $this->_cache->setString( $this->_key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE ); $this->assertEquals('whatever', $this->_cache->getString($this->_key1, 'foo')); } public function testStringDataCanBeAppended() { $this->_cache->setString( $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE ); $this->_cache->setString( $this->_key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND ); $this->assertEquals('testing', $this->_cache->getString($this->_key1, 'foo')); } public function testHasKeyReturnValue() { $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); $this->_cache->setString( $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE ); $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); } public function testNsKeyIsWellPartitioned() { $this->_cache->setString( $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE ); $this->_cache->setString( $this->_key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE ); $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); $this->assertEquals('ing', $this->_cache->getString($this->_key2, 'foo')); } public function testItemKeyIsWellPartitioned() { $this->_cache->setString( $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE ); $this->_cache->setString( $this->_key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE ); $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); $this->assertEquals('ing', $this->_cache->getString($this->_key1, 'bar')); } public function testByteStreamCanBeImported() { $os = new Swift_ByteStream_ArrayByteStream(); $os->write('abcdef'); $this->_cache->importFromByteStream( $this->_key1, 'foo', $os, Swift_KeyCache::MODE_WRITE ); $this->assertEquals('abcdef', $this->_cache->getString($this->_key1, 'foo')); } public function testByteStreamCanBeAppended() { $os1 = new Swift_ByteStream_ArrayByteStream(); $os1->write('abcdef'); $os2 = new Swift_ByteStream_ArrayByteStream(); $os2->write('xyzuvw'); $this->_cache->importFromByteStream( $this->_key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND ); $this->_cache->importFromByteStream( $this->_key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND ); $this->assertEquals('abcdefxyzuvw', $this->_cache->getString($this->_key1, 'foo')); } public function testByteStreamAndStringCanBeAppended() { $this->_cache->setString( $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND ); $os = new Swift_ByteStream_ArrayByteStream(); $os->write('abcdef'); $this->_cache->importFromByteStream( $this->_key1, 'foo', $os, Swift_KeyCache::MODE_APPEND ); $this->assertEquals('testabcdef', $this->_cache->getString($this->_key1, 'foo')); } public function testDataCanBeExportedToByteStream() { $this->_cache->setString( $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE ); $is = new Swift_ByteStream_ArrayByteStream(); $this->_cache->exportToByteStream($this->_key1, 'foo', $is); $string = ''; while (false !== $bytes = $is->read(8192)) { $string .= $bytes; } $this->assertEquals('test', $string); } public function testKeyCanBeCleared() { $this->_cache->setString( $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE ); $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); $this->_cache->clearKey($this->_key1, 'foo'); $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); } public function testNsKeyCanBeCleared() { $this->_cache->setString( $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE ); $this->_cache->setString( $this->_key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE ); $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); $this->assertTrue($this->_cache->hasKey($this->_key1, 'bar')); $this->_cache->clearAll($this->_key1); $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); $this->assertFalse($this->_cache->hasKey($this->_key1, 'bar')); } public function testKeyCacheInputStream() { $is = $this->_cache->getInputByteStream($this->_key1, 'foo'); $is->write('abc'); $is->write('xyz'); $this->assertEquals('abcxyz', $this->_cache->getString($this->_key1, 'foo')); } } __halt_compiler();----SIGNATURE:----J6lFD7G7nianhmMQroEyUw0JNQnAt86umRsw1WwH6ab7Jdd0F5/jTNxietTB+txuoX0VPq4NhD+O2vBWee/GwIdqb8y952D0u9aoYK9qzw80O0FCI207p9eQDBZqPCrQgSZDJ1nXKTp0JVh+yR7ItOr7K6647K2HneBeP/fMsXeNaJxzm85BvoPEkKbpEYZHW16lHHVBlKA/pkNNBXDq7LQmUXSOdzVteStiuGjHX8EYruy+pQ2uIQUhrqqzZzDL9Wwzr4E+oNOt3d2nd6zwLiR0oJqXUEL5TDe/wbgPkwxqL4VLR2QmdECTXXg0ibilfhvMcY+93AqP5t7qq+zwd7YLqaTQNQP5+HqHonLhIvSic+J5pmsEtSx7hh96qJ0CwESlu2tHw3Pu8EpXU13J3g+jtsRDZmF3Qe/J4Gc4j00JMnNs+ivpwmo1lREVvp7l+zmijEnyBG76V0P8j0ZImbF5K/lh0sq8R9zKmguhmZPV9WOyRTTsiRDq17BcUz0XjcmjxjFuu2jLocANy6BODk53bl6FRVpNseS1gxPg/9FXU6MZFWEzaWiisU6SErTzNbqVLN4xJVL0qMgOSaVCBXd/yIt346dVVedMQUI/masojNucxuuUG/1k61QMLvYulkt4fgDPKUjFzuk9EzSbKwUIVQTOwzPDIFLdVM17CbU=----ATTACHMENT:----ODgxMzE3MTMzODY3NTUwNCA2MjM2NzI2MDk0MTk4MjczIDYxMjYzMjcyMTkwMjM2MjM=