mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Merge pull request #55870 from nextcloud/chore/phpunit-11
chore: migrate to PHPUnit 11
This commit is contained in:
commit
340ea17532
29 changed files with 908 additions and 766 deletions
2
.github/workflows/phpunit-32bits.yml
vendored
2
.github/workflows/phpunit-32bits.yml
vendored
|
|
@ -68,4 +68,4 @@ jobs:
|
|||
php -f tests/enable_all.php
|
||||
|
||||
- name: PHPUnit
|
||||
run: composer run test -- --exclude-group PRIMARY-azure,PRIMARY-s3,PRIMARY-swift,Memcached,Redis,RoutingWeirdness
|
||||
run: composer run test -- --exclude-group PRIMARY-azure --exclude-group PRIMARY-s3 --exclude-group PRIMARY-swift --exclude-group Memcached --exclude-group Redis --exclude-group RoutingWeirdness
|
||||
|
|
|
|||
2
.github/workflows/phpunit-memcached.yml
vendored
2
.github/workflows/phpunit-memcached.yml
vendored
|
|
@ -99,7 +99,7 @@ jobs:
|
|||
php -f tests/enable_all.php
|
||||
|
||||
- name: PHPUnit memcached tests
|
||||
run: composer run test -- --group Memcache,Memcached --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.xml' || '' }}
|
||||
run: composer run test -- --group Memcache --group Memcached --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.xml' || '' }}
|
||||
|
||||
- name: Upload code coverage
|
||||
if: ${{ !cancelled() && matrix.coverage }}
|
||||
|
|
|
|||
2
.github/workflows/phpunit-nodb.yml
vendored
2
.github/workflows/phpunit-nodb.yml
vendored
|
|
@ -105,7 +105,7 @@ jobs:
|
|||
php -f tests/enable_all.php
|
||||
|
||||
- name: PHPUnit nodb testsuite
|
||||
run: composer run test -- --exclude-group DB,SLOWDB --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.nodb.xml' || '' }}
|
||||
run: composer run test -- --exclude-group DB --exclude-group SLOWDB --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.nodb.xml' || '' }}
|
||||
|
||||
- name: Upload nodb code coverage
|
||||
if: ${{ !cancelled() && matrix.coverage }}
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ class IMipPluginCharsetTest extends TestCase {
|
|||
->with('core', 'mail_providers_enabled', true)
|
||||
->willReturn(true);
|
||||
$mailMessage = new MailProviderMessage();
|
||||
$mailService = $this->createStubForIntersectionOfInterfaces([IService::class, IMessageSend::class]);
|
||||
$mailService = $this->createMockForIntersectionOfInterfaces([IService::class, IMessageSend::class]);
|
||||
$mailService->method('initiateMessage')
|
||||
->willReturn($mailMessage);
|
||||
$mailService->expects(self::once())
|
||||
|
|
|
|||
|
|
@ -36,9 +36,7 @@ use Sabre\VObject\Component\VEvent;
|
|||
use Sabre\VObject\Reader;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \OCA\DAV\Listener\OutOfOfficeListener
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\CoversClass(OutOfOfficeListener::class)]
|
||||
class OutOfOfficeListenerTest extends TestCase {
|
||||
|
||||
private ServerFactory&MockObject $serverFactory;
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@ namespace OCA\Settings\Tests\SetupChecks;
|
|||
|
||||
use OCA\Settings\SetupChecks\AppDirsWithDifferentOwner;
|
||||
use OCP\IL10N;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
class AppDirsWithDifferentOwnerTest extends TestCase {
|
||||
private IL10N $l10n;
|
||||
private AppDirsWithDifferentOwner $check;
|
||||
|
||||
private IL10N&MockObject $l10n;
|
||||
|
||||
/**
|
||||
* Holds a list of directories created during tests.
|
||||
*
|
||||
|
|
@ -42,8 +44,6 @@ class AppDirsWithDifferentOwnerTest extends TestCase {
|
|||
* Then calls the 'getAppDirsWithDifferentOwner' method.
|
||||
* The result is expected to be empty since
|
||||
* there are no directories with different owners than the current user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAppDirectoryOwnersOk(): void {
|
||||
$tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
|
||||
|
|
@ -69,8 +69,6 @@ class AppDirsWithDifferentOwnerTest extends TestCase {
|
|||
/**
|
||||
* Calls the check for a none existing app root that is marked as not writable.
|
||||
* It's expected that no error happens since the check shouldn't apply.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAppDirectoryOwnersNotWritable(): void {
|
||||
$tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
|
||||
|
|
@ -89,11 +87,9 @@ class AppDirsWithDifferentOwnerTest extends TestCase {
|
|||
|
||||
/**
|
||||
* Removes directories created during tests.
|
||||
*
|
||||
* @after
|
||||
* @return void
|
||||
*/
|
||||
public function removeTestDirectories() {
|
||||
#[\PHPUnit\Framework\Attributes\After()]
|
||||
public function removeTestDirectories(): void {
|
||||
foreach ($this->dirsToRemove as $dirToRemove) {
|
||||
rmdir($dirToRemove);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ else
|
|||
fi
|
||||
|
||||
if ! [ -x "$PHPUNIT" ]; then
|
||||
echo "phpunit executable not found, please install phpunit version >= 10.5 manually or via:" >&2
|
||||
echo "phpunit executable not found, please install phpunit version >= 11.5 manually or via:" >&2
|
||||
echo " composer install" >&2
|
||||
exit 3
|
||||
fi
|
||||
|
|
@ -69,8 +69,8 @@ PHPUNIT_VERSION=$($PHPUNIT --version | cut -d" " -f2)
|
|||
PHPUNIT_MAJOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f1)
|
||||
PHPUNIT_MINOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f2)
|
||||
|
||||
if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 10 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 10 -a "$PHPUNIT_MINOR_VERSION" -ge 5 \) ]; then
|
||||
echo "phpunit version >= 10.5 required. Version found: $PHPUNIT_VERSION" >&2
|
||||
if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 11 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 11 -a "$PHPUNIT_MINOR_VERSION" -ge 5 \) ]; then
|
||||
echo "phpunit version >= 11.5 required. Version found: $PHPUNIT_VERSION" >&2
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
{
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.1"
|
||||
"php": "8.2"
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
"require-dev": {
|
||||
"behat/behat": "^3.15",
|
||||
"dms/phpunit-arraysubset-asserts": "^0.5",
|
||||
"guzzlehttp/guzzle": "^7.9",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"phpunit/phpunit": "^11.5",
|
||||
"sabre/dav": "^4.7",
|
||||
"symfony/event-dispatcher": "^6.4"
|
||||
}
|
||||
|
|
|
|||
791
build/integration/composer.lock
generated
791
build/integration/composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-FileCopyrightText: 2017 ownCloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
use DMS\PHPUnitExtensions\ArraySubset\Assert as AssertArraySubset;
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
|
@ -121,7 +121,9 @@ trait Trashbin {
|
|||
return $item['{http://nextcloud.org/ns}trashbin-filename'];
|
||||
}, $elementList));
|
||||
|
||||
AssertArraySubset::assertArraySubset([$name], array_values($trashContent));
|
||||
if (array_search($name, array_values($trashContent)) === false) {
|
||||
Assert::fail("$name" . ' is not in trash listing');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
"PHP_CLI_SERVER_WORKERS=${NEXTCLOUD_WORKERS:=4} php -S ${NEXTCLOUD_HOST:=localhost}:${NEXTCLOUD_PORT:=8080} -t ./"
|
||||
],
|
||||
"test": "phpunit --fail-on-warning --fail-on-risky --display-warnings --display-deprecations --display-phpunit-deprecations --colors=always --configuration tests/phpunit-autotest.xml",
|
||||
"test:db": "@composer run test -- --group DB,SLOWDB",
|
||||
"test:db": "@composer run test -- --group DB --group SLOWDB",
|
||||
"test:files_external": "phpunit --fail-on-warning --fail-on-risky --display-warnings --display-deprecations --display-phpunit-deprecations --colors=always --configuration tests/phpunit-autotest-external.xml",
|
||||
"rector": "rector --config=build/rector.php && composer cs:fix",
|
||||
"openapi": "./build/openapi-checker.sh"
|
||||
|
|
|
|||
|
|
@ -31,29 +31,16 @@ use Test\TestCase;
|
|||
* Unit tests for \OC\Core\Service\LoginFlowV2Service
|
||||
*/
|
||||
class LoginFlowV2ServiceUnitTest extends TestCase {
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/** @var ICrypto */
|
||||
private $crypto;
|
||||
private LoginFlowV2Service $subjectUnderTest;
|
||||
|
||||
/** @var LoggerInterface|MockObject */
|
||||
private $logger;
|
||||
|
||||
/** @var LoginFlowV2Mapper */
|
||||
private $mapper;
|
||||
|
||||
/** @var ISecureRandom */
|
||||
private $secureRandom;
|
||||
|
||||
/** @var LoginFlowV2Service */
|
||||
private $subjectUnderTest;
|
||||
|
||||
/** @var ITimeFactory */
|
||||
private $timeFactory;
|
||||
|
||||
/** @var \OC\Authentication\Token\IProvider */
|
||||
private $tokenProvider;
|
||||
private IConfig&MockObject $config;
|
||||
private ICrypto&MockObject $crypto;
|
||||
private LoggerInterface&MockObject $logger;
|
||||
private LoginFlowV2Mapper&MockObject $mapper;
|
||||
private ISecureRandom&MockObject $secureRandom;
|
||||
private ITimeFactory&MockObject $timeFactory;
|
||||
private IProvider&MockObject $tokenProvider;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -265,10 +252,10 @@ class LoginFlowV2ServiceUnitTest extends TestCase {
|
|||
|
||||
$this->config->expects($this->exactly(1))
|
||||
->method('getSystemValue')
|
||||
->willReturn($this->returnCallback(function ($key) use ($allowedClients) {
|
||||
->willReturnCallback(function ($key) use ($allowedClients) {
|
||||
// Note: \OCP\IConfig::getSystemValue returns either an array or string.
|
||||
return $key == 'core.login_flow_v2.allowed_user_agents' ? $allowedClients : '';
|
||||
}));
|
||||
});
|
||||
|
||||
$loginFlowV2 = new LoginFlowV2();
|
||||
$loginFlowV2->setClientName('Rogue Curl Client/1.0');
|
||||
|
|
@ -291,10 +278,10 @@ class LoginFlowV2ServiceUnitTest extends TestCase {
|
|||
|
||||
$this->config->expects($this->exactly(1))
|
||||
->method('getSystemValue')
|
||||
->willReturn($this->returnCallback(function ($key) use ($allowedClients) {
|
||||
->willReturnCallback(function ($key) use ($allowedClients) {
|
||||
// Note: \OCP\IConfig::getSystemValue returns either an array or string.
|
||||
return $key == 'core.login_flow_v2.allowed_user_agents' ? $allowedClients : '';
|
||||
}));
|
||||
});
|
||||
|
||||
$this->mapper->expects($this->once())
|
||||
->method('getByLoginToken')
|
||||
|
|
@ -444,10 +431,10 @@ class LoginFlowV2ServiceUnitTest extends TestCase {
|
|||
public function testCreateTokens(): void {
|
||||
$this->config->expects($this->exactly(2))
|
||||
->method('getSystemValue')
|
||||
->willReturn($this->returnCallback(function ($key) {
|
||||
->willReturnCallback(function ($key) {
|
||||
// Note: \OCP\IConfig::getSystemValue returns either an array or string.
|
||||
return $key == 'openssl' ? [] : '';
|
||||
}));
|
||||
});
|
||||
|
||||
$this->mapper->expects($this->once())
|
||||
->method('insert');
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class TestMiddleware extends Middleware {
|
|||
}
|
||||
|
||||
class TestController extends Controller {
|
||||
public function method(): void {
|
||||
public function controllerMethod(): void {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,10 +115,10 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
|
|||
|
||||
private function getControllerMock() {
|
||||
return $this->getMockBuilder(TestController::class)
|
||||
->onlyMethods(['method'])
|
||||
->onlyMethods(['controllerMethod'])
|
||||
->setConstructorArgs(['app',
|
||||
new Request(
|
||||
['method' => 'GET'],
|
||||
['controllerMethod' => 'GET'],
|
||||
$this->createMock(IRequestId::class),
|
||||
$this->createMock(IConfig::class)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -29,11 +29,9 @@ class GuestAvatarTest extends TestCase {
|
|||
|
||||
/**
|
||||
* Setups a guest avatar instance for tests.
|
||||
*
|
||||
* @before
|
||||
* @return void
|
||||
*/
|
||||
public function setupGuestAvatar() {
|
||||
#[\PHPUnit\Framework\Attributes\Before()]
|
||||
public function setupGuestAvatar(): void {
|
||||
/* @var MockObject|LoggerInterface $logger */
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$config = $this->createMock(IConfig::class);
|
||||
|
|
|
|||
|
|
@ -150,7 +150,8 @@ class FileCacheTest extends TestCache {
|
|||
->method('filemtime')
|
||||
->willReturn(100);
|
||||
$mockStorage->expects($this->atLeastOnce())
|
||||
->method('unlink')->willReturnOnConsecutiveCalls($this->throwException($testException), $this->returnValue(true));
|
||||
->method('unlink')
|
||||
->willReturnOnConsecutiveCalls($this->throwException($testException), true);
|
||||
|
||||
$this->instance->set('key1', 'value1');
|
||||
$this->instance->set('key2', 'value2');
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class PartitionedQueryBuilderTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
if (PHP_INT_SIZE < 8) {
|
||||
$this->markTestSkipped('Test requires 64bit');
|
||||
return;
|
||||
}
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->shardConnectionManager = Server::get(ShardConnectionManager::class);
|
||||
|
|
@ -36,7 +37,11 @@ class PartitionedQueryBuilderTest extends TestCase {
|
|||
}
|
||||
|
||||
protected function tearDown(): void {
|
||||
$this->cleanupDb();
|
||||
// PHP unit also runs tearDown when the test is skipped, but we only initialized when using 64bit
|
||||
// see https://github.com/sebastianbergmann/phpunit/issues/6394
|
||||
if (PHP_INT_SIZE >= 8) {
|
||||
$this->cleanupDb();
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ class FilenameValidatorTest extends TestCase {
|
|||
$this->l10n = $this->createMock(IFactory::class);
|
||||
$this->l10n
|
||||
->method('get')
|
||||
->with('core')
|
||||
->willReturn($l10n);
|
||||
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
|
|
|
|||
|
|
@ -21,18 +21,14 @@ use Test\TestCase;
|
|||
class InMemoryFileTest extends TestCase {
|
||||
/**
|
||||
* Holds a pdf file with know attributes for tests.
|
||||
*
|
||||
* @var InMemoryFile
|
||||
*/
|
||||
private $testPdf;
|
||||
private InMemoryFile $testPdf;
|
||||
|
||||
/**
|
||||
* Sets the test file from "./resources/test.pdf".
|
||||
*
|
||||
* @before
|
||||
* @return void
|
||||
*/
|
||||
public function setupTestPdf() {
|
||||
#[\PHPUnit\Framework\Attributes\Before()]
|
||||
public function setupTestPdf(): void {
|
||||
$fileContents = file_get_contents(
|
||||
__DIR__ . '/../../../data/test.pdf'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,12 @@ class CasTraitTest extends TestCase {
|
|||
*/
|
||||
private function getCache() {
|
||||
$sourceCache = new ArrayCache();
|
||||
$mock = $this->getMockForTrait('\OC\Memcache\CasTrait');
|
||||
$mock = $this->getMockBuilder(CasTraitTestClass::class)->onlyMethods([
|
||||
'set',
|
||||
'get',
|
||||
'add',
|
||||
'remove',
|
||||
])->getMock();
|
||||
|
||||
$mock->expects($this->any())
|
||||
->method('set')
|
||||
|
|
|
|||
24
tests/lib/Memcache/CasTraitTestClass.php
Normal file
24
tests/lib/Memcache/CasTraitTestClass.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Test\Memcache;
|
||||
|
||||
use OC\Memcache\CASTrait;
|
||||
|
||||
class CasTraitTestClass {
|
||||
use CASTrait;
|
||||
|
||||
// abstract methods from Memcache
|
||||
public function set($key, $value, $ttl = 0) {
|
||||
}
|
||||
public function get($key) {
|
||||
}
|
||||
public function add($key, $value, $ttl = 0) {
|
||||
}
|
||||
public function remove($key) {
|
||||
}
|
||||
}
|
||||
|
|
@ -18,21 +18,15 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
class MemoryInfoTest extends TestCase {
|
||||
/**
|
||||
* The "memory_limit" value before tests.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $iniSettingBeforeTest;
|
||||
private string $iniSettingBeforeTest;
|
||||
|
||||
/**
|
||||
* @beforeClass
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\BeforeClass()]
|
||||
public function backupMemoryInfoIniSetting() {
|
||||
$this->iniSettingBeforeTest = ini_get('memory_limit');
|
||||
}
|
||||
|
||||
/**
|
||||
* @afterClass
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\AfterClass()]
|
||||
public function restoreMemoryInfoIniSetting() {
|
||||
ini_set('memory_limit', $this->iniSettingBeforeTest);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class PreviewMapperTest extends TestCase {
|
|||
private IGenerator $snowflake;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->previewMapper = Server::get(PreviewMapper::class);
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->snowflake = Server::get(IGenerator::class);
|
||||
|
|
@ -38,6 +39,11 @@ class PreviewMapperTest extends TestCase {
|
|||
$qb->delete('previews')->executeStatement();
|
||||
}
|
||||
|
||||
public function tearDown(): void {
|
||||
$this->previewMapper->deleteAll();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetAvailablePreviews(): void {
|
||||
// Empty
|
||||
$this->assertEquals([], $this->previewMapper->getAvailablePreviews([]));
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class PreviewServiceTest extends TestCase {
|
|||
private IGenerator $snowflakeGenerator;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->previewService = Server::get(PreviewService::class);
|
||||
$this->previewMapper = Server::get(PreviewMapper::class);
|
||||
$this->snowflakeGenerator = Server::get(IGenerator::class);
|
||||
|
|
@ -33,6 +34,7 @@ class PreviewServiceTest extends TestCase {
|
|||
|
||||
public function tearDown(): void {
|
||||
$this->previewService->deleteAll();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetAvailableFileIds(): void {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ class TestCollationRepair extends Collation {
|
|||
/**
|
||||
* Tests for the converting of MySQL tables to InnoDB engine
|
||||
*
|
||||
*
|
||||
* @see \OC\Repair\RepairMimeTypes
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\Group('DB')]
|
||||
|
|
@ -48,13 +47,13 @@ class RepairCollationTest extends TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->connection = Server::get(ConnectionAdapter::class);
|
||||
$this->config = Server::get(IConfig::class);
|
||||
if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_MYSQL) {
|
||||
$this->markTestSkipped('Test only relevant on MySql');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$this->config = Server::get(IConfig::class);
|
||||
$dbPrefix = $this->config->getSystemValueString('dbtableprefix');
|
||||
$this->tableName = $this->getUniqueID($dbPrefix . '_collation_test');
|
||||
$this->connection->prepare("CREATE TABLE $this->tableName(text VARCHAR(16)) COLLATE utf8_unicode_ci")->execute();
|
||||
|
|
@ -63,7 +62,11 @@ class RepairCollationTest extends TestCase {
|
|||
}
|
||||
|
||||
protected function tearDown(): void {
|
||||
$this->connection->getInner()->createSchemaManager()->dropTable($this->tableName);
|
||||
$this->connection = Server::get(ConnectionAdapter::class);
|
||||
if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL) {
|
||||
// tear down only needed on MySQL
|
||||
$this->connection->getInner()->createSchemaManager()->dropTable($this->tableName);
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,9 +32,13 @@ class ResourceLocatorTest extends \Test\TestCase {
|
|||
->method('getSystemValueString')
|
||||
->with('theme', '')
|
||||
->willReturn($theme);
|
||||
return $this->getMockForAbstractClass(ResourceLocator::class,
|
||||
[$this->logger, $this->config],
|
||||
'', true, true, true, []);
|
||||
return $this->getMockBuilder(ResourceLocator::class)
|
||||
->onlyMethods(['doFind', 'doFindTheme'])
|
||||
->setConstructorArgs(
|
||||
[$this->logger, $this->config],
|
||||
'', true, true, true, []
|
||||
)
|
||||
->getMock();
|
||||
}
|
||||
|
||||
public function testFind(): void {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace Test\Traits;
|
|||
use OCP\Http\Client\IClient;
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\Http\Client\IResponse;
|
||||
use PHPUnit\Framework\MockObject\Rule\AnyInvokedCount;
|
||||
|
||||
trait ClientServiceTrait {
|
||||
/** @var IClientService|\PHPUnit\Framework\MockObject\MockObject */
|
||||
|
|
@ -31,11 +32,10 @@ trait ClientServiceTrait {
|
|||
* Returns a matcher that matches when the method is executed
|
||||
* zero or more times.
|
||||
*
|
||||
* @return \PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount
|
||||
*
|
||||
* @since Method available since Release 3.0.0
|
||||
* @since Method available since Release 3.0.0
|
||||
* @since 33.0.0 - non static and hard typed return type due to phpunit upgrade to v11
|
||||
*/
|
||||
abstract public static function any();
|
||||
abstract public function any(): AnyInvokedCount;
|
||||
|
||||
protected function setUpClientServiceTrait() {
|
||||
$this->clientService = $this->createMock(IClientService::class);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use OCP\IConfig;
|
|||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Server;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -31,16 +32,11 @@ use Test\TestCase;
|
|||
*/
|
||||
#[\PHPUnit\Framework\Attributes\Group('DB')]
|
||||
class ManagerTest extends TestCase {
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
/** @var IEventDispatcher */
|
||||
private $eventDispatcher;
|
||||
/** @var ICacheFactory */
|
||||
private $cacheFactory;
|
||||
/** @var ICache */
|
||||
private $cache;
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
private IConfig&MockObject $config;
|
||||
private IEventDispatcher&MockObject $eventDispatcher;
|
||||
private ICacheFactory&MockObject $cacheFactory;
|
||||
private ICache&MockObject $cache;
|
||||
private LoggerInterface&MockObject $logger;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -68,7 +64,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testUserExistsSingleBackendExists(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->once())
|
||||
|
|
@ -98,7 +94,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testUserExistsSingleBackendNotExists(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->once())
|
||||
|
|
@ -120,7 +116,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testUserExistsTwoBackendsSecondExists(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend1
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend1
|
||||
*/
|
||||
$backend1 = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend1->expects($this->once())
|
||||
|
|
@ -129,7 +125,7 @@ class ManagerTest extends TestCase {
|
|||
->willReturn(false);
|
||||
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend2
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend2
|
||||
*/
|
||||
$backend2 = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend2->expects($this->once())
|
||||
|
|
@ -146,7 +142,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testUserExistsTwoBackendsFirstExists(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend1
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend1
|
||||
*/
|
||||
$backend1 = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend1->expects($this->once())
|
||||
|
|
@ -155,7 +151,7 @@ class ManagerTest extends TestCase {
|
|||
->willReturn(true);
|
||||
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend2
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend2
|
||||
*/
|
||||
$backend2 = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend2->expects($this->never())
|
||||
|
|
@ -170,7 +166,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testCheckPassword(): void {
|
||||
/**
|
||||
* @var \OC\User\Backend | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \OC\User\Backend&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->once())
|
||||
|
|
@ -197,7 +193,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testCheckPasswordNotSupported(): void {
|
||||
/**
|
||||
* @var \OC\User\Backend | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \OC\User\Backend&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->never())
|
||||
|
|
@ -215,7 +211,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testGetOneBackendExists(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->once())
|
||||
|
|
@ -233,7 +229,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testGetOneBackendNotExists(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->once())
|
||||
|
|
@ -263,7 +259,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testGetOneBackendDoNotTranslateLoginNames(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->once())
|
||||
|
|
@ -281,7 +277,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testSearchOneBackend(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->once())
|
||||
|
|
@ -304,7 +300,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testSearchTwoBackendLimitOffset(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend1
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend1
|
||||
*/
|
||||
$backend1 = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend1->expects($this->once())
|
||||
|
|
@ -315,7 +311,7 @@ class ManagerTest extends TestCase {
|
|||
->method('loginName2UserName');
|
||||
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend2
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend2
|
||||
*/
|
||||
$backend2 = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend2->expects($this->once())
|
||||
|
|
@ -370,7 +366,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
#[\PHPUnit\Framework\Attributes\DataProvider('dataCreateUserInvalid')]
|
||||
public function testCreateUserInvalid($uid, $password, $exception): void {
|
||||
/** @var \Test\Util\User\Dummy|\PHPUnit\Framework\MockObject\MockObject $backend */
|
||||
/** @var \Test\Util\User\Dummy&MockObject $backend */
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->once())
|
||||
->method('implementsActions')
|
||||
|
|
@ -387,7 +383,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testCreateUserSingleBackendNotExists(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->any())
|
||||
|
|
@ -417,7 +413,7 @@ class ManagerTest extends TestCase {
|
|||
$this->expectException(\Exception::class);
|
||||
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->any())
|
||||
|
|
@ -440,7 +436,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testCreateUserSingleBackendNotSupported(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->any())
|
||||
|
|
@ -470,9 +466,7 @@ class ManagerTest extends TestCase {
|
|||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Could not create account');
|
||||
|
||||
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject $config */
|
||||
$config = $this->createMock(IConfig::class);
|
||||
/** @var \Test\Util\User\Dummy|\PHPUnit\Framework\MockObject\MockObject $backend */
|
||||
/** @var \Test\Util\User\Dummy&MockObject $backend */
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend
|
||||
->expects($this->once())
|
||||
|
|
@ -489,7 +483,7 @@ class ManagerTest extends TestCase {
|
|||
$this->expectException(\Exception::class);
|
||||
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend1
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend1
|
||||
*/
|
||||
$backend1 = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend1->expects($this->any())
|
||||
|
|
@ -505,7 +499,7 @@ class ManagerTest extends TestCase {
|
|||
->willReturn(false);
|
||||
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend2
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend2
|
||||
*/
|
||||
$backend2 = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend2->expects($this->any())
|
||||
|
|
@ -537,7 +531,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testCountUsersOneBackend(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->once())
|
||||
|
|
@ -566,7 +560,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testCountUsersTwoBackends(): void {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit\Framework\MockObject\MockObject $backend
|
||||
* @var \Test\Util\User\Dummy&MockObject $backend
|
||||
*/
|
||||
$backend1 = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend1->expects($this->once())
|
||||
|
|
@ -753,6 +747,7 @@ class ManagerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testDeleteUser(): void {
|
||||
/** @var AllConfig&MockObject */
|
||||
$config = $this->getMockBuilder(AllConfig::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
|
@ -776,6 +771,7 @@ class ManagerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testGetByEmail(): void {
|
||||
/** @var AllConfig&MockObject */
|
||||
$config = $this->getMockBuilder(AllConfig::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@
|
|||
}
|
||||
},
|
||||
"require": {
|
||||
"phpunit/phpunit": "^10.5.35"
|
||||
"phpunit/phpunit": "^11.5"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
616
vendor-bin/phpunit/composer.lock
generated
616
vendor-bin/phpunit/composer.lock
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue