Esempio n. 1
0
 public function testMemory()
 {
     $file = new Zend_Search_Lucene_Storage_File_Filesystem(dirname(__FILE__) . '/_files/sample_data');
     $fileData = $file->readBytes($file->size());
     $file->close();
     unset($file);
     $file = new Zend_Search_Lucene_Storage_File_Memory($fileData);
     $this->assertTrue($file instanceof Zend_Search_Lucene_Storage_File);
     $fileSize = strlen($fileData);
     $file->seek(0, SEEK_END);
     $this->assertEquals($file->tell(), $fileSize);
     $file->seek(2, SEEK_SET);
     $this->assertEquals($file->tell(), 2);
     $file->seek(3, SEEK_CUR);
     $this->assertEquals($file->tell(), 5);
     $file->seek(0, SEEK_SET);
     $this->assertEquals($file->tell(), 0);
     $this->assertEquals($file->readByte(), 10);
     $this->assertEquals($file->readBytes(8), "���Df�");
     $this->assertEquals($file->readInt(), 49057123);
     $this->assertEquals($file->readLong(), 753823522);
     $this->assertEquals($file->readVInt(), 234586758);
     $this->assertEquals($file->readString(), "UTF-8 string with non-ascii (Cyrillic) symbols\nUTF-8 строка с не-ASCII (кириллическими) символами");
     $this->assertEquals($file->readBinary(), "���Df�");
     // these methods do nothing, but should be provided by object
     $file->lock(LOCK_EX);
     $file->unlock();
 }
 public function __construct($filename, $mode = 'r+b')
 {
     parent::__construct($filename, $mode);
     sfLuceneStorageFilesystem::chmod($filename, 0777);
 }