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
|
|
@ -27,7 +27,7 @@ use Icewind\SMB\Options;
|
|||
use Icewind\SMB\System;
|
||||
use Icewind\SMB\TimeZoneProvider;
|
||||
|
||||
abstract class AbstractShareTest extends TestCase {
|
||||
abstract class AbstractShareTestBase extends TestCase {
|
||||
/**
|
||||
* @var \Icewind\SMB\IServer $server
|
||||
*/
|
||||
|
|
@ -15,7 +15,7 @@ use Icewind\SMB\Options;
|
|||
use Icewind\SMB\System;
|
||||
use Icewind\SMB\TimeZoneProvider;
|
||||
|
||||
class NativeShareTest extends AbstractShareTest {
|
||||
class NativeShareTest extends AbstractShareTestBase {
|
||||
public function getServerClass(): string {
|
||||
$this->requireBackendEnv('libsmbclient');
|
||||
if (!function_exists('smbclient_state_new')) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use Icewind\SMB\Exception\AlreadyExistsException;
|
|||
use Icewind\SMB\Exception\Exception;
|
||||
use Icewind\SMB\Exception\RevisionMismatchException;
|
||||
use Icewind\SMB\INotifyHandler;
|
||||
use Icewind\SMB\IShare;
|
||||
use Icewind\SMB\ISystem;
|
||||
use Icewind\SMB\Options;
|
||||
use Icewind\SMB\System;
|
||||
use Icewind\SMB\TimeZoneProvider;
|
||||
|
|
@ -199,8 +199,7 @@ class NotifyHandlerTest extends TestCase {
|
|||
public function testNoStdBuf(): void {
|
||||
$this->requireBackendEnv('smbclient');
|
||||
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
|
||||
$system = $this->getMockBuilder(System::class)
|
||||
->onlyMethods(['getStdBufPath'])
|
||||
$system = $this->getMockBuilder(ISystem::class)
|
||||
->getMock();
|
||||
$system->method('getStdBufPath')
|
||||
->willReturn(null);
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Icewind\SMB\System;
|
|||
use Icewind\SMB\TimeZoneProvider;
|
||||
use Icewind\SMB\Wrapped\Server as NormalServer;
|
||||
|
||||
class ShareTest extends AbstractShareTest {
|
||||
class ShareTest extends AbstractShareTestBase {
|
||||
public function getServerClass(): string {
|
||||
$this->requireBackendEnv('smbclient');
|
||||
return NormalServer::class;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
- SPDX-FileCopyrightText: 2012 Robin Appelman <robin@icewind.nl>
|
||||
- SPDX-License-Identifier: MIT
|
||||
-->
|
||||
<phpunit bootstrap="bootstrap.php">
|
||||
<testsuite name='SMB'>
|
||||
<directory suffix='.php'>./</directory>
|
||||
</testsuite>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">../src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">../src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuite name="SMB">
|
||||
<directory suffix=".php">./</directory>
|
||||
</testsuite>
|
||||
</phpunit>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue