/** * @expectedException PHPUnit_Framework_Error_Warning */ public function testClosedirDouble() { $state = smbclient_state_new(); smbclient_state_init($state, null, SMB_USER, SMB_PASS); $dir = smbclient_opendir($state, 'smb://' . SMB_HOST . '/' . SMB_SHARE); $this->assertTrue(smbclient_closedir($state, $dir)); $this->assertFalse(smbclient_closedir($state, $dir)); }
/** * @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 }
public function testReaddirSuccess() { $state = smbclient_state_new(); smbclient_state_init($state, null, SMB_USER, SMB_PASS); $dir = smbclient_opendir($state, 'smb://' . SMB_HOST . '/' . SMB_SHARE); $smb = array(); while (($out = smbclient_readdir($state, $dir)) !== false) { $smb[] = $out['name']; } // Compare this with a copy we get through the filesystem: $local = scandir(SMB_LOCAL); // Sort both arrays to ensure equality: sort($smb); sort($local); $this->assertEquals($smb, $local); }
public function testOptionNTHash() { $state = smbclient_state_new(); if (smbclient_option_get($state, SMBCLIENT_OPT_USE_NT_HASH) === null) { smbclient_state_free($state); return; } smbclient_option_set($state, SMBCLIENT_OPT_USE_NT_HASH, true); // NTLM hash of 'password' generated at http://www.tobtu.com/lmntlm.php smbclient_state_init($state, null, SMB_USER, SMB_HASH); $dir = smbclient_opendir($state, 'smb://' . SMB_HOST . '/' . SMB_SHARE); while (($out = smbclient_readdir($state, $dir)) !== false) { } $this->assertTrue(is_resource($dir)); smbclient_closedir($state, $dir); smbclient_state_free($state); }
/** * @param string $uri * @return resource */ public function opendir($uri) { $result = @smbclient_opendir($this->state, $uri); $this->testResult($result, $uri); return $result; }