/** * Verify that the embedded database can be extracted. */ public function testExtractEmbeddedDatabaseFromSqon() { $path = $this->createTemporaryFile(); file_put_contents($path, trim(file_get_contents($this->script))); file_put_contents($path, 'database', FILE_APPEND); file_put_contents($path, sha1_file($path, true), FILE_APPEND); $database = new File('php://memory', 'w+'); $reader = new Reader(new File($path, 'r')); $reader->getDatabase($database); $database->seek(0); self::assertEquals('database', $database->read(), 'The embedded database was not extracted properly.'); }
/** * {@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}"))); }