You are here

function ResourceStreamTestCase::testFwrite in D7 Media 6

File

resource/tests/ResourceStream.test, line 98
This provides SimpleTests for the core stream wrapper functionality.

Class

ResourceStreamTestCase
Base class for file tests that adds some additional file specific assertions and helper functions.

Code

function testFwrite() {
  $this->handle = fopen($this->scheme . $this->path, 'a+');
  $this
    ->assertTrue($this->handle, "Open {$this->scheme}{$this->path} in mode a+");
  $data = '1234';
  $this
    ->assertTrue(fwrite($this->handle, $data), "fwrite ({$data}) to handle");
  $this
    ->assertTrue(fseek($this->handle, -4, SEEK_END), "Seek to pos before fwrite.");
  $read = fread($this->handle, 4);
  $this
    ->assertTrue($data == $read, "fread ({$read}) == fwritten ({$data}) bytes");
  $this
    ->assertTrue(fclose($this->handle), "Close file.");
}