/**
  * @expectedException PHPUnit_Framework_Error_Warning
  */
 public function testRenameFileNotExists()
 {
     $state = smbclient_state_new();
     smbclient_state_init($state, null, SMB_USER, SMB_PASS);
     $this->assertFalse(smbclient_rename($state, 'smb://' . SMB_HOST . '/' . SMB_SHARE . '/does-not-exist', $state, 'smb://' . SMB_HOST . '/' . SMB_SHARE . '/somewhere-else'));
     $this->assertEquals(2, smbclient_state_errno($state));
     // ENOENT
 }
 /**
  * @expectedException PHPUnit_Framework_Error_Warning
  */
 public function testGetxattrFileNotFound()
 {
     $state = smbclient_state_new();
     smbclient_state_init($state, null, SMB_USER, SMB_PASS);
     $attr = smbclient_getxattr($state, 'smb://' . SMB_HOST . '/' . SMB_SHARE . '/testdir/does-not-exist', 'system.dos_attr.mode');
     $this->assertFalse($attr);
     $this->assertEquals(smbclient_state_errno($state), 2);
     // ENOENT
 }
 /**
  * @expectedException PHPUnit_Framework_Error_Warning
  */
 public function testOpendirNotDir()
 {
     $state = smbclient_state_new();
     smbclient_state_init($state, null, SMB_USER, SMB_PASS);
     $dir = smbclient_opendir($state, 'smb://' . SMB_HOST . '/' . SMB_SHARE . '/testfile.txt');
     $this->assertFalse($dir);
     $errno = smbclient_state_errno($state);
     $this->assertEquals(20, $errno);
     // ENOTDIR
 }
示例#4
0
 protected function handleError($path)
 {
     $error = smbclient_state_errno($this->state);
     switch ($error) {
         // see error.h
         case 0:
             return;
         case 1:
         case 13:
             throw new ForbiddenException($path, $error);
         case 2:
             throw new NotFoundException($path, $error);
         case 17:
             throw new AlreadyExistsException($path, $error);
         case 20:
             throw new InvalidTypeException($path, $error);
         case 21:
             throw new InvalidTypeException($path, $error);
         case 39:
             throw new NotEmptyException($path, $error);
         case 110:
             throw new TimedOutException($path, $error);
         case 111:
             throw new ConnectionRefusedException($path, $error);
         case 112:
             throw new HostDownException($path, $error);
         case 113:
             throw new NoRouteToHostException($path, $error);
         default:
             $message = 'Unknown error (' . $error . ')';
             if ($path) {
                 $message .= ' for ' . $path;
             }
             throw new Exception($message, $error);
     }
 }