test fixes

This commit is contained in:
Robin Appelman 2025-10-25 23:00:02 +02:00
commit 824593c5ac
6 changed files with 27 additions and 23 deletions

View file

@ -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')