Exemplo n.º 1
0
 /**
  * @covers ::open
  * @covers ::isOpen
  * @covers ::write
  * @covers ::close
  */
 public function testOpenForWrite()
 {
     $file = new WritableStreamBackupFile($this->adapter->createTempFile());
     // Not open yet
     $this->assertFalse($file->isOpen());
     // Open for reading.
     $handle = $file->openForWrite();
     // Write to the file
     $file->write('Hello');
     $path = $file->realpath();
     $this->assertEquals(file_get_contents($file->realpath()), 'Hello');
     // Append to the file
     $file->write(', World!');
     $this->assertEquals(file_get_contents($file->realpath()), 'Hello, World!');
     $file->close();
     $this->assertFalse($file->isOpen());
     $this->assertFalse(is_resource($handle));
     // Test implicit file open and close.
     $new_file = new WritableStreamBackupFile($this->adapter->createTempFile());
     $path = $new_file->realpath();
     $new_file->write('Hello, World!');
     $this->assertEquals(file_get_contents($new_file->realpath()), 'Hello, World!');
     //      unset($new_file);
     //      // Make sure the file was deleted
     //      $this->assertFalse(file_exists($path));
 }