public function testCreateUrlencodedSuccess() { $testuri = 'smb://' . SMB_HOST . '/' . SMB_SHARE . '/ex%25%25%25ample.txt'; $realfile = SMB_LOCAL . '/ex%%%ample.txt'; $state = smbclient_state_new(); smbclient_state_init($state, null, SMB_USER, SMB_PASS); $file = smbclient_creat($state, $testuri); $this->assertTrue(is_resource($file)); $this->assertFileExists($realfile); #unlink($realfile); }
public function testLseekCurPositive() { $state = smbclient_state_new(); smbclient_state_init($state, null, SMB_USER, SMB_PASS); $file = smbclient_creat($state, $this->testuri); smbclient_write($state, $file, 'abcdefgh'); $ret = smbclient_lseek($state, $file, 3, SEEK_CUR); $this->assertEquals(11, $ret); smbclient_write($state, $file, 'foo', 3); smbclient_close($state, $file); $this->assertStringEqualsFile($this->realfile, sprintf('%s%c%c%c%s', 'abcdefgh', 0, 0, 0, 'foo')); }
public function testWriteOversized() { $state = smbclient_state_new(); smbclient_state_init($state, null, SMB_USER, SMB_PASS); $file = smbclient_creat($state, $this->testuri); $this->assertTrue(is_resource($file)); // Write way more bytes than data: $ret = smbclient_write($state, $file, $this->testdata, 1000); $this->assertTrue(is_integer($ret)); $this->assertEquals(strlen($this->testdata), $ret); // Use the regular filesystem to check the file that was created: $this->assertFileExists($this->realfile); $this->assertEquals(filesize($this->realfile), $ret); $this->assertStringEqualsFile($this->realfile, $this->testdata); }
/** * @param string $uri * @param int $mask * @return resource */ public function create($uri, $mask = 0666) { $result = @smbclient_creat($this->state, $uri, $mask); $this->testResult($result, $uri); return $result; }