Exemplo n.º 1
0
 /**
  * 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.');
 }
Exemplo n.º 2
0
 /**
  * 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.');
 }
Exemplo n.º 3
0
 /**
  * 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.');
 }
 /**
  * Returns the file contents of an archived file.
  *
  * @param PharFileInfo $file The archived file.
  *
  * @return string The contents of the file.
  */
 protected function getFileContents(PharFileInfo $file)
 {
     $reader = File::create($file->getPathname());
     $contents = '';
     do {
         $contents .= $reader->fgets();
     } while (!$reader->eof());
     return $contents;
 }
Exemplo n.º 5
0
 /**
  * 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.');
 }
Exemplo n.º 6
0
 /**
  * Dumps the container configuration as an XML file for rebuilding.
  *
  * @param ContainerBuilder $container The container builder.
  * @param string           $file      The path to the cache file.
  */
 private function dumpXmlConfig(ContainerBuilder $container, $file)
 {
     $file = sprintf('%s%s%s.xml', dirname($file), DIRECTORY_SEPARATOR, pathinfo($file, PATHINFO_FILENAME));
     $container->getDefinition(self::getId('helper.container'))->addMethodCall('setFile', array($file));
     $dumper = new XmlDumper($container);
     $writer = new File($file, 'w');
     $writer->fwrite($dumper->dump());
 }
Exemplo n.º 7
0
 /**
  * Returns the contents of a file.
  *
  * @param string $path The path to the file.
  *
  * @return string The contents of the file.
  */
 private function getFileContents($path)
 {
     $contents = '';
     $file = File::create($path);
     do {
         $contents .= $file->fgets();
     } while (!$file->eof());
     return $contents;
 }