diff --git a/.github/workflows/ftp.yml b/.github/workflows/ftp.yml index aa9fe3aad79136175662379a78b3a6379884bc77..be2d2ba02547470b9ff7e67a1c358850ffd30242 100644 --- a/.github/workflows/ftp.yml +++ b/.github/workflows/ftp.yml @@ -43,7 +43,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - tools: phpunit + tools: phpunit:9 extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd - name: Set up Nextcloud diff --git a/.github/workflows/s3-external.yml b/.github/workflows/s3-external.yml index dedab6b0c16fbdde752121313befc0f4b58e9492..8931f35277c76fc9c77853706f89ea74db0a2be6 100644 --- a/.github/workflows/s3-external.yml +++ b/.github/workflows/s3-external.yml @@ -44,7 +44,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - tools: phpunit + tools: phpunit:9 extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd - name: Set up Nextcloud @@ -93,7 +93,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - tools: phpunit + tools: phpunit:9 extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd - name: Set up Nextcloud diff --git a/.github/workflows/s3-primary.yml b/.github/workflows/s3-primary.yml index a6ee0970adaa44a5acb08f31e59ceeca5f6dcafe..aad0f2a1b621a1243680ccd268d0042514882d46 100644 --- a/.github/workflows/s3-primary.yml +++ b/.github/workflows/s3-primary.yml @@ -38,7 +38,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - tools: phpunit + tools: phpunit:9 extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd - name: Set up Nextcloud diff --git a/apps/updatenotification/tests/Settings/AdminTest.php b/apps/updatenotification/tests/Settings/AdminTest.php index 852504fb45aa4122973aabbd2168ad940fc67c4d..15b5b2b450af0213e921ccf3d5e1d0bb6c1e87b6 100644 --- a/apps/updatenotification/tests/Settings/AdminTest.php +++ b/apps/updatenotification/tests/Settings/AdminTest.php @@ -29,6 +29,7 @@ declare(strict_types=1); */ namespace OCA\UpdateNotification\Tests\Settings; +use OC\User\Backend; use OCA\UpdateNotification\Settings\Admin; use OCA\UpdateNotification\UpdateChecker; use OCP\AppFramework\Http\TemplateResponse; @@ -39,6 +40,8 @@ use OCP\IGroupManager; use OCP\L10N\IFactory; use OCP\L10N\ILanguageIterator; use OCP\Support\Subscription\IRegistry; +use OCP\User\Backend\ICountUsersBackend; +use OCP\UserInterface; use OCP\Util; use Test\TestCase; use OCP\IUserManager; @@ -77,11 +80,11 @@ class AdminTest extends TestCase { $this->logger = $this->createMock(LoggerInterface::class); $this->admin = new Admin( - $this->config, - $this->updateChecker, - $this->groupManager, - $this->dateTimeFormatter, - $this->l10nFactory, + $this->config, + $this->updateChecker, + $this->groupManager, + $this->dateTimeFormatter, + $this->l10nFactory, $this->subscriptionRegistry, $this->userManager, $this->logger @@ -89,9 +92,9 @@ class AdminTest extends TestCase { } public function testGetFormWithUpdate() { - $backend1 = $this->createMock(UserInterface::class); - $backend2 = $this->createMock(UserInterface::class); - $backend3 = $this->createMock(UserInterface::class); + $backend1 = $this->createMock(CountUsersBackend::class); + $backend2 = $this->createMock(CountUsersBackend::class); + $backend3 = $this->createMock(CountUsersBackend::class); $backend1 ->expects($this->once()) ->method('implementsActions') @@ -213,9 +216,9 @@ class AdminTest extends TestCase { } public function testGetFormWithUpdateAndChangedUpdateServer() { - $backend1 = $this->createMock(UserInterface::class); - $backend2 = $this->createMock(UserInterface::class); - $backend3 = $this->createMock(UserInterface::class); + $backend1 = $this->createMock(CountUsersBackend::class); + $backend2 = $this->createMock(CountUsersBackend::class); + $backend3 = $this->createMock(CountUsersBackend::class); $backend1 ->expects($this->once()) ->method('implementsActions') @@ -337,9 +340,9 @@ class AdminTest extends TestCase { } public function testGetFormWithUpdateAndCustomersUpdateServer() { - $backend1 = $this->createMock(UserInterface::class); - $backend2 = $this->createMock(UserInterface::class); - $backend3 = $this->createMock(UserInterface::class); + $backend1 = $this->createMock(CountUsersBackend::class); + $backend2 = $this->createMock(CountUsersBackend::class); + $backend3 = $this->createMock(CountUsersBackend::class); $backend1 ->expects($this->once()) ->method('implementsActions') @@ -543,3 +546,7 @@ class AdminTest extends TestCase { $this->assertSame($expectation, $result); } } + +abstract class CountUsersBackend implements UserInterface, ICountUsersBackend { + +} diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php index 02155be11ddab2fb4416dced481ab1729325fff4..84d81dd1cbb4bed1dc64ac4f36ff3306fa182f46 100644 --- a/tests/lib/Encryption/UtilTest.php +++ b/tests/lib/Encryption/UtilTest.php @@ -4,8 +4,6 @@ namespace Test\Encryption; use OC\Encryption\Util; use OC\Files\View; -use OCA\Files_External\Lib\StorageConfig; -use OCA\Files_External\Service\GlobalStoragesService; use OCP\Encryption\IEncryptionModule; use OCP\IConfig; use Test\TestCase; @@ -190,43 +188,4 @@ class UtilTest extends TestCase { ['/foo/test.txt.ocTransferId7567.part', '/foo/test.txt'], ]; } - - public function dataTestIsSystemWideMountPoint() { - return [ - [false, 'non-matching mount point name', [], [], '/mp_another'], - [true, 'applicable to all', [], []], - [true, 'applicable to user directly', ['user1'], []], - [true, 'applicable to group directly', [], ['group1']], - [false, 'non-applicable to current user', ['user2'], []], - [false, 'non-applicable to current user\'s group', [], ['group2']], - [true, 'mount point without leading slash', [], [], 'mp'], - ]; - } - - /** - * @dataProvider dataTestIsSystemWideMountPoint - */ - public function testIsSystemWideMountPoint($expectedResult, $expectationText, $applicableUsers, $applicableGroups, $mountPointName = '/mp') { - $this->groupManager->method('isInGroup') - ->will($this->returnValueMap([ - ['user1', 'group1', true], // user is only in group1 - ['user1', 'group2', false], - ])); - - $storages = []; - - $storageConfig = $this->createMock(StorageConfig::class); - $storageConfig->method('getMountPoint')->willReturn($mountPointName); - $storageConfig->method('getApplicableUsers')->willReturn($applicableUsers); - $storageConfig->method('getApplicableGroups')->willReturn($applicableGroups); - $storages[] = $storageConfig; - - $storagesServiceMock = $this->createMock(GlobalStoragesService::class); - $storagesServiceMock->expects($this->atLeastOnce())->method('getAllStorages') - ->willReturn($storages); - - $this->overwriteService(GlobalStoragesService::class, $storagesServiceMock); - - $this->assertEquals($expectedResult, $this->util->isSystemWideMountPoint('/files/mp', 'user1'), 'Test case: ' . $expectationText); - } }