mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
test fixes
This commit is contained in:
parent
d642bd4b04
commit
824593c5ac
6 changed files with 27 additions and 23 deletions
|
|
@ -9,9 +9,9 @@ namespace Icewind\SMB\Test;
|
|||
use Icewind\SMB\AnonymousAuth;
|
||||
use Icewind\SMB\Exception\DependencyException;
|
||||
use Icewind\SMB\IAuth;
|
||||
use Icewind\SMB\ISystem;
|
||||
use Icewind\SMB\Native\NativeServer;
|
||||
use Icewind\SMB\ServerFactory;
|
||||
use Icewind\SMB\System;
|
||||
use Icewind\SMB\Wrapped\Server;
|
||||
|
||||
class ServerFactoryTest extends TestCase {
|
||||
|
|
@ -25,13 +25,14 @@ class ServerFactoryTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testSmbClient() {
|
||||
$this->requireBackendEnv('smbclient');
|
||||
$system = $this->getMockBuilder(System::class)
|
||||
->onlyMethods(['libSmbclientAvailable'])
|
||||
$system = $this->getMockBuilder(ISystem::class)
|
||||
->getMock();
|
||||
$system->expects($this->any())
|
||||
->method('libSmbclientAvailable')
|
||||
->willReturn(false);
|
||||
$system->expects($this->any())
|
||||
->method('getSmbclientPath')
|
||||
->willReturn("/usr/bin/smbclient");
|
||||
$factory = new ServerFactory(null, $system);
|
||||
$this->assertInstanceOf(Server::class, $factory->createServer('localhost', $this->credentials));
|
||||
}
|
||||
|
|
@ -41,15 +42,19 @@ class ServerFactoryTest extends TestCase {
|
|||
if (!function_exists('smbclient_state_new')) {
|
||||
$this->markTestSkipped('libsmbclient php extension not installed');
|
||||
}
|
||||
$factory = new ServerFactory();
|
||||
$system = $this->getMockBuilder(ISystem::class)
|
||||
->getMock();
|
||||
$system->expects($this->any())
|
||||
->method('libSmbclientAvailable')
|
||||
->willReturn(true);
|
||||
$factory = new ServerFactory(null, $system);
|
||||
$this->assertInstanceOf(NativeServer::class, $factory->createServer('localhost', $this->credentials));
|
||||
}
|
||||
|
||||
public function testNoBackend() {
|
||||
$this->expectException(DependencyException::class);
|
||||
$this->requireBackendEnv('smbclient');
|
||||
$system = $this->getMockBuilder(System::class)
|
||||
->setMethods(['libSmbclientAvailable', 'getSmbclientPath'])
|
||||
$system = $this->getMockBuilder(ISystem::class)
|
||||
->getMock();
|
||||
$system->expects($this->any())
|
||||
->method('libSmbclientAvailable')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue