예제 #1
0
파일: ReaderTest.php 프로젝트: sqon/sqon
 /**
  * Verify that the signature can be read.
  */
 public function testReadFileSignatureFromSqon()
 {
     $file = new File('php://memory', 'w+');
     $file->write(hash('sha1', 'test', true));
     $file->seek(0);
     $reader = new Reader($file);
     self::assertEquals(hash('sha1', 'test', true), $reader->getSignature(), 'The signature was not properly read from the Sqon.');
 }
예제 #2
0
파일: Sqon.php 프로젝트: sqon/sqon
 /**
  * {@inheritdoc}
  */
 public static function open($path)
 {
     if (!self::isValid($path)) {
         // @codeCoverageIgnoreStart
         throw new SqonException("The Sqon \"{$path}\" has an invalid signature.");
         // @codeCoverageIgnoreEnd
     }
     $temp = tempnam(sys_get_temp_dir(), 'sqon-');
     if (!$temp) {
         // @codeCoverageIgnoreStart
         throw new SqonException('A new temporary file could not be created.');
         // @codeCoverageIgnoreEnd
     }
     $reader = new Reader(new File($path, 'r'));
     $reader->getDatabase(new File($temp, 'w'));
     return new self($path, $reader->getBootstrap(), $temp, new Database(new PDO("sqlite:{$temp}")));
 }