Exemple #1
0
 /**
  * writes data into the stream
  *
  * @param   string  $data
  * @return  int     amount of bytes written
  */
 public function stream_write($data)
 {
     if (self::READONLY === $this->mode) {
         return 0;
     }
     return $this->content->write($data);
 }
 /**
  * @test
  * @group  issue_33
  * @since  1.1.0
  */
 public function truncateToGreaterSizeAddsZeroBytes()
 {
     $this->assertEquals(11, $this->file->write("lorem ipsum"));
     $this->assertTrue($this->file->truncate(25));
     $this->assertEquals(25, $this->file->size());
     $this->assertEquals("lorem ipsum", $this->file->getContent());
 }
 /**
  * writes data into the stream
  *
  * @param   string  $data
  * @return  int     amount of bytes written
  */
 public function stream_write($data)
 {
     if (self::READONLY === $this->mode) {
         return 0;
     }
     if ($this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
         return 0;
     }
     return $this->content->write($data);
 }
 /**
  * test writing data into the file
  *
  * @test
  */
 public function write()
 {
     $this->file->setContent('foobarbaz');
     $this->assertTrue($this->file->seek(3, SEEK_SET));
     $this->assertEquals(3, $this->file->write('foo'));
     $this->assertEquals('foofoobaz', $this->file->getContent());
     $this->assertEquals(9, $this->file->size());
     $this->assertEquals(3, $this->file->write('bar'));
     $this->assertEquals('foofoobar', $this->file->getContent());
     $this->assertEquals(9, $this->file->size());
 }
 /**
  * writes data into the stream
  *
  * @param   string  $data
  * @return  int     amount of bytes written
  */
 public function stream_write($data)
 {
     return $this->content->write($data);
 }