-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix risky test without assertion #32761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b9650ae
c5c7ba5
7cc9187
3f06f1f
8e62662
6df0a79
32cab81
de93d17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,7 @@ | |
|
|
||
| use OC\Encryption\Util; | ||
| use OC\Files\View; | ||
| use OCA\Files_External\Lib\StorageConfig; | ||
| use OCA\Files_External\Service\GlobalStoragesService; | ||
| use OCP\App\IAppManager; | ||
| use OCP\Encryption\IEncryptionModule; | ||
| use OCP\IConfig; | ||
| use Test\TestCase; | ||
|
|
@@ -40,11 +39,11 @@ protected function setUp(): void { | |
| ->disableOriginalConstructor() | ||
| ->getMock(); | ||
|
|
||
| $this->userManager = $this->getMockBuilder('OC\User\Manager') | ||
| $this->userManager = $this->getMockBuilder(\OC\User\Manager::class) | ||
| ->disableOriginalConstructor() | ||
| ->getMock(); | ||
|
|
||
| $this->groupManager = $this->getMockBuilder('OC\Group\Manager') | ||
| $this->groupManager = $this->getMockBuilder(\OC\Group\Manager::class) | ||
| ->disableOriginalConstructor() | ||
| ->getMock(); | ||
|
|
||
|
|
@@ -207,6 +206,15 @@ public function dataTestIsSystemWideMountPoint() { | |
| * @dataProvider dataTestIsSystemWideMountPoint | ||
| */ | ||
| public function testIsSystemWideMountPoint($expectedResult, $expectationText, $applicableUsers, $applicableGroups, $mountPointName = '/mp') { | ||
| $appManager = $this->createMock(IAppManager::class); | ||
| $appManager | ||
| ->expects($this->once()) | ||
| ->method('isEnabledForUser') | ||
| ->with('files_external') | ||
| ->willReturn(true); | ||
|
|
||
| $this->overwriteService(IAppManager::class, $appManager); | ||
|
|
||
| $this->groupManager->method('isInGroup') | ||
| ->will($this->returnValueMap([ | ||
| ['user1', 'group1', true], // user is only in group1 | ||
|
|
@@ -215,17 +223,28 @@ public function testIsSystemWideMountPoint($expectedResult, $expectationText, $a | |
|
|
||
| $storages = []; | ||
|
|
||
| $storageConfig = $this->createMock(StorageConfig::class); | ||
| // StorageConfig | ||
| $storageConfig = $this->getMockBuilder('OCA\\Files_External\\Lib\\StorageConfig') | ||
| ->setMethods([ | ||
| 'getMountPoint', | ||
| 'getApplicableUsers', | ||
| 'getApplicableGroups', | ||
| ]) | ||
| ->getMock(); | ||
| $storageConfig->method('getMountPoint')->willReturn($mountPointName); | ||
| $storageConfig->method('getApplicableUsers')->willReturn($applicableUsers); | ||
| $storageConfig->method('getApplicableGroups')->willReturn($applicableGroups); | ||
| $storages[] = $storageConfig; | ||
|
|
||
| $storagesServiceMock = $this->createMock(GlobalStoragesService::class); | ||
| $storagesServiceMock = $this->getMockBuilder('OCA\\Files_External\\Service\\GlobalStoragesService') | ||
| ->setMethods([ | ||
| 'getAllStorages', | ||
| ]) | ||
| ->getMock(); | ||
| $storagesServiceMock->expects($this->atLeastOnce())->method('getAllStorages') | ||
| ->willReturn($storages); | ||
|
|
||
| $this->overwriteService(GlobalStoragesService::class, $storagesServiceMock); | ||
| $this->overwriteService('OCA\\Files_External\\Service\\GlobalStoragesService', $storagesServiceMock); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why for core class you went from string to ::class and for files-external classes you go the other way around?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because core classes are fine. This class might not be loaded as the test is in core and the app is not force enabled nor default enabled
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe some day... owncloud/core#25422 |
||
|
|
||
| $this->assertEquals($expectedResult, $this->util->isSystemWideMountPoint('/files/mp', 'user1'), 'Test case: ' . $expectationText); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.