/** * 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.'); }
/** * Verify that a new raw signature can be generated for a file manager. */ public function testGenerateNewSignatureForAFileManager() { $file = new File('php://memory', 'w+'); $file->write('test'); $hash = hash('sha1', 'test', true); $signature = new Signature(); self::assertEquals($hash, $signature->generate($file), 'The new signature was not generated properly.'); $file->write($hash); self::assertEquals($hash, $signature->generate($file, true), 'The new signature was not generated properly.'); }
/** * Verify that a new Sqon is written. */ public function testWriteTheContentsOfANewSqon() { $bootstrap = new File('php://memory', 'w+'); $bootstrap->write('bootstrap'); $bootstrap->seek(0); $database = new File('php://memory', 'w+'); $database->write('database'); $database->seek(0); $sqon = new File('php://memory', 'w+'); (new Writer())->write($sqon, $bootstrap, $database); $sqon->seek(0); self::assertEquals('bootstrapdatabase' . hash('sha1', 'bootstrapdatabase', true), $sqon->read(), 'The contents of the Sqon file were not written properly.'); }
/** * Verify that the file is used by the stream manager. */ public function testUsingAFileStream() { $this->manager->write('test'); $this->manager->release(); self::assertEquals('test', file_get_contents($this->file), 'The file was not used by the stream manager.'); }