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 tests/Core/Command/Apps/AppsDisableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testCommandInput($appId, $statusCode, $pattern): void {
$this->assertSame($statusCode, $this->commandTester->getStatusCode());
}

public function dataCommandInput(): array {
public static function dataCommandInput(): array {
return [
[['admin_audit'], 0, 'admin_audit ([\d\.]*) disabled'],
[['comments'], 0, 'comments ([\d\.]*) disabled'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Command/Apps/AppsEnableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testCommandInput($appId, $groups, $statusCode, $pattern): void {
$this->assertSame($statusCode, $this->commandTester->getStatusCode());
}

public function dataCommandInput(): array {
public static function dataCommandInput(): array {
return [
[['admin_audit'], null, 0, 'admin_audit ([\d\.]*) enabled'],
[['comments'], null, 0, 'comments ([\d\.]*) enabled'],
Expand Down
12 changes: 6 additions & 6 deletions tests/Core/Command/Config/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp(): void {
$this->command = new Import($config);
}

public function validateAppsArrayData() {
public static function validateAppsArrayData(): array {
return [
[0],
[1],
Expand All @@ -58,7 +58,7 @@ public function testValidateAppsArray($configValue): void {
$this->assertTrue(true, 'Asserting that no exception is thrown');
}

public function validateAppsArrayThrowsData() {
public static function validateAppsArrayThrowsData(): array {
return [
[false],
[true],
Expand All @@ -81,7 +81,7 @@ public function testValidateAppsArrayThrows($configValue): void {
}
}

public function checkTypeRecursivelyData() {
public static function checkTypeRecursivelyData(): array {
return [
[0],
[1],
Expand All @@ -107,7 +107,7 @@ public function testCheckTypeRecursively($configValue): void {
$this->assertTrue(true, 'Asserting that no exception is thrown');
}

public function checkTypeRecursivelyThrowsData() {
public static function checkTypeRecursivelyThrowsData(): array {
return [
[new \Exception()],
[[new \Exception()]],
Expand All @@ -130,7 +130,7 @@ public function testCheckTypeRecursivelyThrows($configValue): void {
}
}

public function validateArrayData() {
public static function validateArrayData(): array {
return [
[['system' => []]],
[['apps' => []]],
Expand All @@ -148,7 +148,7 @@ public function testValidateArray($configArray): void {
$this->assertTrue(true, 'Asserting that no exception is thrown');
}

public function validateArrayThrowsData() {
public static function validateArrayThrowsData(): array {
return [
[[], 'At least one key of the following is expected:'],
[[0 => []], 'Found invalid entries in root'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Command/Config/ListConfigsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function setUp(): void {
$this->command = new ListConfigs($systemConfig, $appConfig);
}

public function listData() {
public static function listData(): array {
return [
[
'all',
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Command/Config/System/DeleteConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp(): void {
$this->command = new DeleteConfig($systemConfig);
}

public function deleteData() {
public static function deleteData(): array {
return [
[
'name1',
Expand Down Expand Up @@ -105,7 +105,7 @@ public function testDelete($configName, $configExists, $checkIfExists, $expected
$this->assertSame($expectedReturn, $this->invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]));
}

public function deleteArrayData() {
public static function deleteArrayData(): array {
return [
[
['name', 'sub'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Command/Config/System/GetConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function setUp(): void {
}


public function getData() {
public static function getData(): array {
return [
// String output as json
['name', 'newvalue', true, null, false, 'json', 0, json_encode('newvalue')],
Expand Down
6 changes: 3 additions & 3 deletions tests/Core/Command/Config/System/SetConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testSet($configNames, $newValue, $existingData, $expectedValue):
$this->invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}

public function setUpdateOnlyProvider() {
public static function setUpdateOnlyProvider(): array {
return [
[['name'], null],
[['a', 'b', 'c'], null],
Expand Down Expand Up @@ -113,7 +113,7 @@ public function testSetUpdateOnly($configNames, $existingData): void {
$this->invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}

public function castValueProvider() {
public static function castValueProvider(): array {
return [
[null, 'string', ['value' => '', 'readable-value' => 'empty string']],

Expand Down Expand Up @@ -141,7 +141,7 @@ public function testCastValue($value, $type, $expectedValue): void {
);
}

public function castValueInvalidProvider() {
public static function castValueInvalidProvider(): array {
return [
['123', 'foobar'],

Expand Down
20 changes: 10 additions & 10 deletions tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testExecute($newRoot, $answer, $successMoveKey): void {
$this->util,
$this->questionHelper
]
)->setMethods(['moveAllKeys'])->getMock();
)->onlyMethods(['moveAllKeys'])->getMock();

$this->util->expects($this->once())->method('getKeyStorageRoot')
->willReturn('');
Expand Down Expand Up @@ -122,7 +122,7 @@ public function testExecute($newRoot, $answer, $successMoveKey): void {
);
}

public function dataTestExecute() {
public static function dataTestExecute(): array {
return [
[null, true, true],
[null, true, false],
Expand All @@ -143,7 +143,7 @@ public function testMoveAllKeys(): void {
$this->util,
$this->questionHelper
]
)->setMethods(['prepareNewRoot', 'moveSystemKeys', 'moveUserKeys'])->getMock();
)->onlyMethods(['prepareNewRoot', 'moveSystemKeys', 'moveUserKeys'])->getMock();

$changeKeyStorageRoot->expects($this->once())->method('prepareNewRoot')->with('newRoot');
$changeKeyStorageRoot->expects($this->once())->method('moveSystemKeys')->with('oldRoot', 'newRoot');
Expand Down Expand Up @@ -179,7 +179,7 @@ public function testPrepareNewRootException($dirExists, $couldCreateFile): void
$this->invokePrivate($this->changeKeyStorageRoot, 'prepareNewRoot', ['newRoot']);
}

public function dataTestPrepareNewRootException() {
public static function dataTestPrepareNewRootException(): array {
return [
[true, false],
[true, null],
Expand All @@ -204,7 +204,7 @@ public function testMoveSystemKeys($dirExists, $targetExists, $executeRename): v
$this->util,
$this->questionHelper
]
)->setMethods(['targetExists'])->getMock();
)->onlyMethods(['targetExists'])->getMock();

$this->view->expects($this->once())->method('is_dir')
->with('oldRoot/files_encryption')->willReturn($dirExists);
Expand All @@ -221,7 +221,7 @@ public function testMoveSystemKeys($dirExists, $targetExists, $executeRename): v
$this->invokePrivate($changeKeyStorageRoot, 'moveSystemKeys', ['oldRoot', 'newRoot']);
}

public function dataTestMoveSystemKeys() {
public static function dataTestMoveSystemKeys(): array {
return [
[true, false, true],
[false, true, false],
Expand All @@ -241,7 +241,7 @@ public function testMoveUserKeys(): void {
$this->util,
$this->questionHelper
]
)->setMethods(['setupUserFS', 'moveUserEncryptionFolder'])->getMock();
)->onlyMethods(['setupUserFS', 'moveUserEncryptionFolder'])->getMock();

$this->userManager->expects($this->once())->method('getBackends')
->willReturn([$this->userInterface]);
Expand Down Expand Up @@ -271,7 +271,7 @@ public function testMoveUserEncryptionFolder($userExists, $isDir, $targetExists,
$this->util,
$this->questionHelper
]
)->setMethods(['targetExists', 'prepareParentFolder'])->getMock();
)->onlyMethods(['targetExists', 'prepareParentFolder'])->getMock();

$this->userManager->expects($this->once())->method('userExists')
->willReturn($userExists);
Expand All @@ -293,7 +293,7 @@ public function testMoveUserEncryptionFolder($userExists, $isDir, $targetExists,
$this->invokePrivate($changeKeyStorageRoot, 'moveUserEncryptionFolder', ['user1', 'oldRoot', 'newRoot']);
}

public function dataTestMoveUserEncryptionFolder() {
public static function dataTestMoveUserEncryptionFolder(): array {
return [
[true, true, false, true],
[true, false, true, false],
Expand Down Expand Up @@ -334,7 +334,7 @@ function ($fileExistsPath) use ($path, $pathExists) {
);
}

public function dataTestPrepareParentFolder() {
public static function dataTestPrepareParentFolder(): array {
return [
['/user/folder/sub_folder/keystorage', true],
['/user/folder/sub_folder/keystorage', false]
Expand Down
39 changes: 25 additions & 14 deletions tests/Core/Command/Encryption/DecryptAllTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@ protected function setUp(): void {
public function testMaintenanceAndTrashbin(): void {
// on construct we enable single-user-mode and disable the trash bin
// on destruct we disable single-user-mode again and enable the trash bin
$calls = [
['maintenance', true],
['maintenance', false],
];
$this->config->expects($this->exactly(2))
->method('setSystemValue')
->withConsecutive(
['maintenance', true],
['maintenance', false],
);
->willReturnCallback(function () use (&$calls) {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
$this->appManager->expects($this->once())
->method('disableApp')
->with('files_trashbin');
Expand Down Expand Up @@ -127,12 +131,16 @@ public function testExecute($encryptionEnabled, $continue): void {
->willReturn('user1');

if ($encryptionEnabled) {
$calls = [
['core', 'encryption_enabled', 'no'],
['core', 'encryption_enabled', 'yes'],
];
$this->config->expects($this->exactly(2))
->method('setAppValue')
->withConsecutive(
['core', 'encryption_enabled', 'no'],
['core', 'encryption_enabled', 'yes'],
);
->willReturnCallback(function () use (&$calls) {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
$this->questionHelper->expects($this->once())
->method('ask')
->willReturn($continue);
Expand All @@ -152,7 +160,7 @@ public function testExecute($encryptionEnabled, $continue): void {
$this->invokePrivate($instance, 'execute', [$this->consoleInput, $this->consoleOutput]);
}

public function dataTestExecute() {
public static function dataTestExecute(): array {
return [
[true, true],
[true, false],
Expand All @@ -174,13 +182,16 @@ public function testExecuteFailure(): void {
);

// make sure that we enable encryption again after a exception was thrown
$calls = [
['core', 'encryption_enabled', 'no'],
['core', 'encryption_enabled', 'yes'],
];
$this->config->expects($this->exactly(2))
->method('setAppValue')
->withConsecutive(
['core', 'encryption_enabled', 'no'],
['core', 'encryption_enabled', 'yes'],
);

->willReturnCallback(function () use (&$calls) {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
$this->encryptionManager->expects($this->once())
->method('isEnabled')
->willReturn(true);
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Command/Encryption/DisableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp(): void {
}


public function dataDisable() {
public static function dataDisable(): array {
return [
['yes', true, 'Encryption disabled'],
['no', false, 'Encryption is already disabled'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Command/Encryption/EncryptAllTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function testExecute($answer, $askResult): void {
$this->invokePrivate($command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}

public function dataTestExecute() {
public static function dataTestExecute(): array {
return [
['y', true], ['Y', true], ['n', false], ['N', false], ['', false]
];
Expand Down
14 changes: 9 additions & 5 deletions tests/Core/Command/Encryption/SetDefaultModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function setUp(): void {
}


public function dataSetDefaultModule() {
public static function dataSetDefaultModule(): array {
return [
['ID0', 'ID0', null, null, 'already'],
['ID0', 'ID1', 'ID1', true, 'info'],
Expand Down Expand Up @@ -113,12 +113,16 @@ public function testMaintenanceMode($oldModule, $newModule, $updateModule, $upda
->with('maintenance', false)
->willReturn(true);

$calls = [
'Maintenance mode must be disabled when setting default module,',
'in order to load the relevant encryption modules correctly.',
];
$this->consoleOutput->expects($this->exactly(2))
->method('writeln')
->withConsecutive(
[$this->stringContains('Maintenance mode must be disabled when setting default module,')],
[$this->stringContains('in order to load the relevant encryption modules correctly.')],
);
->willReturnCallback(function ($message) use (&$calls) {
$expected = array_shift($calls);
$this->assertStringContainsString($expected, $message);
});

self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Command/Group/InfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function setUp(): void {
$this->groupManager = $this->createMock(IGroupManager::class);
$this->command = $this->getMockBuilder(Info::class)
->setConstructorArgs([$this->groupManager])
->setMethods(['writeArrayInOutputFormat'])
->onlyMethods(['writeArrayInOutputFormat'])
->getMock();

$this->input = $this->createMock(InputInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Command/Group/ListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp(): void {
$this->groupManager = $this->createMock(IGroupManager::class);
$this->command = $this->getMockBuilder(ListCommand::class)
->setConstructorArgs([$this->groupManager])
->setMethods(['writeArrayInOutputFormat'])
->onlyMethods(['writeArrayInOutputFormat'])
->getMock();

$this->input = $this->createMock(InputInterface::class);
Expand Down
Loading
Loading