Esempio n. 1
0
 public function testProperties()
 {
     $filename = 'test';
     $driver = mockDriver($this);
     $file = mockFile($this, $driver, $filename);
     $this->assertEquals(100, $file->size);
 }
Esempio n. 2
0
 public function testWrite()
 {
     $driver = mockDriver($this);
     $file = mockFile($this, $driver, '');
     $out = mockFileWriter($this, $file);
     $this->assertEquals(10, $out->write('1234567890'));
 }
Esempio n. 3
0
function mockFileDriver(PHPUnit_Framework_TestCase $testcase, $filename)
{
    $driver = mockDriver($testcase);
    $file = mockFile($testcase, $driver, $filename);
    $driver->method('isFile')->willReturn(true);
    $driver->method('isDir')->willReturn(false);
    $driver->method('instantiateFile')->willReturn($file);
    return $driver;
}
Esempio n. 4
0
 public function testRead()
 {
     $driver = mockDriver($this);
     $file = mockFile($this, $driver, '');
     $in = mockFileInputStream($this, $file, 100);
     $this->assertTrue($in->has_more);
     $this->assertEquals(50, strlen($in->read(50)));
     $this->assertTrue($in->has_more);
     $this->assertEquals(50, strlen($in->read(50)));
     $this->assertFalse($in->has_more);
 }
Esempio n. 5
0
 public function testModifiedFileDoesntExist()
 {
     $this->setExpectedException(PathNotFoundException::class);
     $file = mockFile($this, $this->driver, $this->filename . 'idontexist');
     $this->assertInternalType('int', $this->driver->modified($file));
 }