コード例 #1
0
 public function set_contents()
 {
     $data = 'Test';
     $f = new Stream();
     $this->assertEquals(strlen($data), FileUtil::setContents($f, $data), 'bytes written equals');
     $this->assertEquals($data, FileUtil::getContents($f));
 }
コード例 #2
0
 public function setUp()
 {
     $tempDir = realpath(System::tempDir());
     $this->fixture = new FilesystemPropertySource($tempDir);
     // Create a temporary ini file
     $this->tempFile = new File($tempDir, 'temp.ini');
     FileUtil::setContents($this->tempFile, "[section]\nkey=value\n");
 }
コード例 #3
0
 /**
  * Sets up test case - creates temporary file
  *
  */
 public function setUp()
 {
     try {
         $this->file = new TempFile();
         FileUtil::setContents($this->file, 'Created by FileOutputStreamTest');
     } catch (\io\IOException $e) {
         throw new \unittest\PrerequisitesNotMetError('Cannot write temporary file', $e, array($this->file));
     }
 }
コード例 #4
0
 /**
  * Sets up test case - creates temporary file
  *
  * @return void
  */
 public function setUp()
 {
     try {
         $this->file = new TempFile();
         FileUtil::setContents($this->file, 'Created by FileInputStreamTest');
     } catch (IOException $e) {
         throw new PrerequisitesNotMetError('Cannot write temporary file', $e, [$this->file]);
     }
 }
コード例 #5
0
 public static function createFiles()
 {
     self::$temp = new Folder(System::tempDir(), uniqid(microtime(true)));
     self::$temp->create();
     $partials = new Folder(self::$temp, 'partials');
     $partials->create();
     FileUtil::setContents(new File(self::$temp, 'test.mustache'), 'Mustache template {{id}}');
     FileUtil::setContents(new File($partials, 'navigation.mustache'), '{{#if nav}}nav{{/if}}');
 }
コード例 #6
0
 /**
  * Execute action
  *
  * @return  int
  */
 public function perform()
 {
     $this->archive->open(Archive::READ);
     $args = $this->getArguments();
     while ($entry = $this->archive->getEntry()) {
         if (!$this->_filter($entry, $args)) {
             continue;
         }
         $f = new File($entry);
         $data = $this->archive->extract($entry);
         if (!($this->options & Options::SIMULATE)) {
             // Create folder on demand. Note that inside a XAR, the directory
             // separator is *ALWAYS* a forward slash, so we need to change
             // it to whatever the OS we're currently running on uses.
             $dir = new Folder(str_replace('/', DIRECTORY_SEPARATOR, dirname($entry)));
             if (!$dir->exists()) {
                 $dir->create();
             }
             FileUtil::setContents($f, $data);
         }
         $this->options & Options::VERBOSE && $this->out->writeLinef('%10s %s', number_format(strlen($data), 0, false, '.'), $entry);
     }
     $this->archive->close();
 }
コード例 #7
0
 /**
  * Store data
  *
  * @param   string name
  * @param   string data
  */
 protected function store($name, $data)
 {
     FileUtil::setContents(new File($this->path, $name), $data);
 }
コード例 #8
0
 public function read_bc()
 {
     $s = new Stream();
     FileUtil::setContents($s, base64_decode('/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gNzUK/9sAQwAIBgYHBgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCMcHCg3KSwwMTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ0YMiEcITIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQgAAQABAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A9/ooooA//9k='));
     Image::loadFrom(new \img\io\StreamReader(ref($s)));
 }
コード例 #9
0
 public function read_bc()
 {
     $s = new Stream();
     FileUtil::setContents($s, base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAACklEQVQImWNgAAAAAgAB9HFkpgAAAABJRU5ErkJggg=='));
     Image::loadFrom(new \img\io\StreamReader(ref($s)));
 }
コード例 #10
0
 public function read_bc()
 {
     $s = new Stream();
     FileUtil::setContents($s, base64_decode('R0lGODdhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs='));
     Image::loadFrom(new \img\io\StreamReader(ref($s)));
 }
コード例 #11
0
 public function readMalformedDataBC()
 {
     $s = new Stream();
     FileUtil::setContents($s, '@@MALFORMED@@');
     Image::loadFrom(new \img\io\StreamReader(ref($s)));
 }
コード例 #12
0
 /**
  * Called when a test run finishes.
  *
  * @param   unittest.TestSuite suite
  * @param   unittest.TestResult result
  */
 public function testRunFinished(\unittest\TestSuite $suite, TestResult $result)
 {
     $coverage = xdebug_get_code_coverage();
     xdebug_stop_code_coverage();
     $results = array();
     foreach ($coverage as $fileName => $data) {
         foreach ($this->paths as $path) {
             if (substr($fileName, 0, strlen($path)) !== $path) {
                 continue;
             }
             $results[dirname($fileName)][basename($fileName)] = $data;
             break;
         }
     }
     $pathsNode = new Node('paths');
     foreach ($results as $pathName => $files) {
         $pathNode = new Node('path');
         $pathNode->setAttribute('name', $pathName);
         foreach ($files as $fileName => $data) {
             $fileNode = new Node('file');
             $fileNode->setAttribute('name', $fileName);
             $num = 1;
             $reader = new TextReader(new FileInputStream($pathName . '/' . $fileName));
             while (($line = $reader->readLine()) !== null) {
                 $lineNode = new Node('line', new CData($line));
                 if (isset($data[$num])) {
                     if (1 === $data[$num]) {
                         $lineNode->setAttribute('checked', 'checked');
                     } elseif (-1 === $data[$num]) {
                         $lineNode->setAttribute('unchecked', 'unchecked');
                     }
                 }
                 $fileNode->addChild($lineNode);
                 ++$num;
             }
             $pathNode->addChild($fileNode);
         }
         $pathsNode->addChild($pathNode);
     }
     $pathsNode->setAttribute('time', date('Y-m-d H:i:s'));
     $this->processor->setXMLBuf($pathsNode->getSource());
     $this->processor->run();
     FileUtil::setContents(new File($this->reportFile), $this->processor->output());
 }
コード例 #13
0
 public function set_contents_writes_bytes()
 {
     $out = new MemoryOutputStream();
     FileUtil::setContents(new File(Streams::writeableFd($out)), 'Test');
     $this->assertEquals('Test', $out->getBytes());
 }