Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ftp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/s3-external.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/s3-primary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 21 additions & 14 deletions apps/updatenotification/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/
namespace OCA\UpdateNotification\Tests\Settings;

use OC\User\Backend;
use OCA\UpdateNotification\Settings\Admin;
use OCA\UpdateNotification\UpdateChecker;
use OCP\AppFramework\Http\TemplateResponse;
Expand All @@ -39,6 +40,8 @@
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;
Expand Down Expand Up @@ -77,21 +80,21 @@ protected function setUp(): void {
$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
);
}

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')
Expand Down Expand Up @@ -213,9 +216,9 @@ public function testGetFormWithUpdate() {
}

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')
Expand Down Expand Up @@ -337,9 +340,9 @@ public function testGetFormWithUpdateAndChangedUpdateServer() {
}

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')
Expand Down Expand Up @@ -543,3 +546,7 @@ public function testFilterChanges($changes, $userLang, $expectation) {
$this->assertSame($expectation, $result);
}
}

abstract class CountUsersBackend implements UserInterface, ICountUsersBackend {

}
41 changes: 0 additions & 41 deletions tests/lib/Encryption/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

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;
Expand Down Expand Up @@ -190,43 +188,4 @@ public function dataTestStripPartialFileExtension() {
['/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);
}
}