@@ -20,121 +20,121 @@ |
||
20 | 20 | use Test\TestCase; |
21 | 21 | |
22 | 22 | class GetConfigTest extends TestCase { |
23 | - protected IAppConfig&MockObject $appConfig; |
|
24 | - protected ConfigManager&MockObject $configManager; |
|
25 | - protected InputInterface&MockObject $consoleInput; |
|
26 | - protected OutputInterface&MockObject $consoleOutput; |
|
27 | - protected Command $command; |
|
28 | - |
|
29 | - protected function setUp(): void { |
|
30 | - parent::setUp(); |
|
31 | - |
|
32 | - $this->appConfig = $this->createMock(IAppConfig::class); |
|
33 | - $this->configManager = $this->createMock(ConfigManager::class); |
|
34 | - $this->consoleInput = $this->createMock(InputInterface::class); |
|
35 | - $this->consoleOutput = $this->createMock(OutputInterface::class); |
|
36 | - |
|
37 | - $this->command = new GetConfig($this->appConfig, $this->configManager); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - public static function dataGet(): array { |
|
42 | - return [ |
|
43 | - // String output as json |
|
44 | - ['name', 'newvalue', true, null, false, 'json', 0, json_encode('newvalue')], |
|
45 | - // String output as plain text |
|
46 | - ['name', 'newvalue', true, null, false, 'plain', 0, 'newvalue'], |
|
47 | - // String falling back to default output as json |
|
48 | - ['name', null, false, 'newvalue', true, 'json', 0, json_encode('newvalue')], |
|
49 | - // String falling back without default: error |
|
50 | - ['name', null, false, null, false, 'json', 1, null], |
|
51 | - |
|
52 | - // Int "0" output as json/plain |
|
53 | - ['name', 0, true, null, false, 'json', 0, json_encode(0)], |
|
54 | - ['name', 0, true, null, false, 'plain', 0, '0'], |
|
55 | - // Int "1" output as json/plain |
|
56 | - ['name', 1, true, null, false, 'json', 0, json_encode(1)], |
|
57 | - ['name', 1, true, null, false, 'plain', 0, '1'], |
|
58 | - |
|
59 | - // Bool "true" output as json/plain |
|
60 | - ['name', true, true, null, false, 'json', 0, json_encode(true)], |
|
61 | - ['name', true, true, null, false, 'plain', 0, 'true'], |
|
62 | - // Bool "false" output as json/plain |
|
63 | - ['name', false, true, null, false, 'json', 0, json_encode(false)], |
|
64 | - ['name', false, true, null, false, 'plain', 0, 'false'], |
|
65 | - |
|
66 | - // Null output as json/plain |
|
67 | - ['name', null, true, null, false, 'json', 0, json_encode(null)], |
|
68 | - ['name', null, true, null, false, 'plain', 0, 'null'], |
|
69 | - |
|
70 | - // Array output as json/plain |
|
71 | - ['name', ['a', 'b'], true, null, false, 'json', 0, json_encode(['a', 'b'])], |
|
72 | - ['name', ['a', 'b'], true, null, false, 'plain', 0, "a\nb"], |
|
73 | - // Key array output as json/plain |
|
74 | - ['name', [0 => 'a', 1 => 'b'], true, null, false, 'json', 0, json_encode(['a', 'b'])], |
|
75 | - ['name', [0 => 'a', 1 => 'b'], true, null, false, 'plain', 0, "a\nb"], |
|
76 | - // Associative array output as json/plain |
|
77 | - ['name', ['a' => 1, 'b' => 2], true, null, false, 'json', 0, json_encode(['a' => 1, 'b' => 2])], |
|
78 | - ['name', ['a' => 1, 'b' => 2], true, null, false, 'plain', 0, "a: 1\nb: 2"], |
|
79 | - |
|
80 | - ]; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @dataProvider dataGet |
|
85 | - */ |
|
86 | - public function testGet(string $configName, mixed $value, bool $configExists, mixed $defaultValue, bool $hasDefault, string $outputFormat, int $expectedReturn, ?string $expectedMessage): void { |
|
87 | - if (!$expectedReturn) { |
|
88 | - if ($configExists) { |
|
89 | - $this->appConfig->expects($this->once()) |
|
90 | - ->method('getDetails') |
|
91 | - ->with('app-name', $configName) |
|
92 | - ->willReturn(['value' => $value]); |
|
93 | - } |
|
94 | - } |
|
95 | - |
|
96 | - if (!$configExists) { |
|
97 | - $this->appConfig->expects($this->once()) |
|
98 | - ->method('getDetails') |
|
99 | - ->with('app-name', $configName) |
|
100 | - ->willThrowException(new AppConfigUnknownKeyException()); |
|
101 | - } |
|
102 | - |
|
103 | - $this->consoleInput->expects($this->exactly(2)) |
|
104 | - ->method('getArgument') |
|
105 | - ->willReturnMap([ |
|
106 | - ['app', 'app-name'], |
|
107 | - ['name', $configName], |
|
108 | - ]); |
|
109 | - $this->consoleInput->method('getOption') |
|
110 | - ->willReturnMap([ |
|
111 | - ['default-value', $defaultValue], |
|
112 | - ['output', $outputFormat], |
|
113 | - ]); |
|
114 | - $this->consoleInput->method('hasParameterOption') |
|
115 | - ->willReturnMap([ |
|
116 | - ['--output', false, true], |
|
117 | - ['--default-value', false, $hasDefault], |
|
118 | - ]); |
|
119 | - |
|
120 | - if ($expectedMessage !== null) { |
|
121 | - global $output; |
|
122 | - |
|
123 | - $output = ''; |
|
124 | - $this->consoleOutput->method('writeln') |
|
125 | - ->willReturnCallback(function ($value) { |
|
126 | - global $output; |
|
127 | - $output .= $value . "\n"; |
|
128 | - return $output; |
|
129 | - }); |
|
130 | - } |
|
131 | - |
|
132 | - $this->assertSame($expectedReturn, self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput])); |
|
133 | - |
|
134 | - if ($expectedMessage !== null) { |
|
135 | - global $output; |
|
136 | - // Remove the trailing newline |
|
137 | - $this->assertSame($expectedMessage, substr($output, 0, -1)); |
|
138 | - } |
|
139 | - } |
|
23 | + protected IAppConfig&MockObject $appConfig; |
|
24 | + protected ConfigManager&MockObject $configManager; |
|
25 | + protected InputInterface&MockObject $consoleInput; |
|
26 | + protected OutputInterface&MockObject $consoleOutput; |
|
27 | + protected Command $command; |
|
28 | + |
|
29 | + protected function setUp(): void { |
|
30 | + parent::setUp(); |
|
31 | + |
|
32 | + $this->appConfig = $this->createMock(IAppConfig::class); |
|
33 | + $this->configManager = $this->createMock(ConfigManager::class); |
|
34 | + $this->consoleInput = $this->createMock(InputInterface::class); |
|
35 | + $this->consoleOutput = $this->createMock(OutputInterface::class); |
|
36 | + |
|
37 | + $this->command = new GetConfig($this->appConfig, $this->configManager); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + public static function dataGet(): array { |
|
42 | + return [ |
|
43 | + // String output as json |
|
44 | + ['name', 'newvalue', true, null, false, 'json', 0, json_encode('newvalue')], |
|
45 | + // String output as plain text |
|
46 | + ['name', 'newvalue', true, null, false, 'plain', 0, 'newvalue'], |
|
47 | + // String falling back to default output as json |
|
48 | + ['name', null, false, 'newvalue', true, 'json', 0, json_encode('newvalue')], |
|
49 | + // String falling back without default: error |
|
50 | + ['name', null, false, null, false, 'json', 1, null], |
|
51 | + |
|
52 | + // Int "0" output as json/plain |
|
53 | + ['name', 0, true, null, false, 'json', 0, json_encode(0)], |
|
54 | + ['name', 0, true, null, false, 'plain', 0, '0'], |
|
55 | + // Int "1" output as json/plain |
|
56 | + ['name', 1, true, null, false, 'json', 0, json_encode(1)], |
|
57 | + ['name', 1, true, null, false, 'plain', 0, '1'], |
|
58 | + |
|
59 | + // Bool "true" output as json/plain |
|
60 | + ['name', true, true, null, false, 'json', 0, json_encode(true)], |
|
61 | + ['name', true, true, null, false, 'plain', 0, 'true'], |
|
62 | + // Bool "false" output as json/plain |
|
63 | + ['name', false, true, null, false, 'json', 0, json_encode(false)], |
|
64 | + ['name', false, true, null, false, 'plain', 0, 'false'], |
|
65 | + |
|
66 | + // Null output as json/plain |
|
67 | + ['name', null, true, null, false, 'json', 0, json_encode(null)], |
|
68 | + ['name', null, true, null, false, 'plain', 0, 'null'], |
|
69 | + |
|
70 | + // Array output as json/plain |
|
71 | + ['name', ['a', 'b'], true, null, false, 'json', 0, json_encode(['a', 'b'])], |
|
72 | + ['name', ['a', 'b'], true, null, false, 'plain', 0, "a\nb"], |
|
73 | + // Key array output as json/plain |
|
74 | + ['name', [0 => 'a', 1 => 'b'], true, null, false, 'json', 0, json_encode(['a', 'b'])], |
|
75 | + ['name', [0 => 'a', 1 => 'b'], true, null, false, 'plain', 0, "a\nb"], |
|
76 | + // Associative array output as json/plain |
|
77 | + ['name', ['a' => 1, 'b' => 2], true, null, false, 'json', 0, json_encode(['a' => 1, 'b' => 2])], |
|
78 | + ['name', ['a' => 1, 'b' => 2], true, null, false, 'plain', 0, "a: 1\nb: 2"], |
|
79 | + |
|
80 | + ]; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @dataProvider dataGet |
|
85 | + */ |
|
86 | + public function testGet(string $configName, mixed $value, bool $configExists, mixed $defaultValue, bool $hasDefault, string $outputFormat, int $expectedReturn, ?string $expectedMessage): void { |
|
87 | + if (!$expectedReturn) { |
|
88 | + if ($configExists) { |
|
89 | + $this->appConfig->expects($this->once()) |
|
90 | + ->method('getDetails') |
|
91 | + ->with('app-name', $configName) |
|
92 | + ->willReturn(['value' => $value]); |
|
93 | + } |
|
94 | + } |
|
95 | + |
|
96 | + if (!$configExists) { |
|
97 | + $this->appConfig->expects($this->once()) |
|
98 | + ->method('getDetails') |
|
99 | + ->with('app-name', $configName) |
|
100 | + ->willThrowException(new AppConfigUnknownKeyException()); |
|
101 | + } |
|
102 | + |
|
103 | + $this->consoleInput->expects($this->exactly(2)) |
|
104 | + ->method('getArgument') |
|
105 | + ->willReturnMap([ |
|
106 | + ['app', 'app-name'], |
|
107 | + ['name', $configName], |
|
108 | + ]); |
|
109 | + $this->consoleInput->method('getOption') |
|
110 | + ->willReturnMap([ |
|
111 | + ['default-value', $defaultValue], |
|
112 | + ['output', $outputFormat], |
|
113 | + ]); |
|
114 | + $this->consoleInput->method('hasParameterOption') |
|
115 | + ->willReturnMap([ |
|
116 | + ['--output', false, true], |
|
117 | + ['--default-value', false, $hasDefault], |
|
118 | + ]); |
|
119 | + |
|
120 | + if ($expectedMessage !== null) { |
|
121 | + global $output; |
|
122 | + |
|
123 | + $output = ''; |
|
124 | + $this->consoleOutput->method('writeln') |
|
125 | + ->willReturnCallback(function ($value) { |
|
126 | + global $output; |
|
127 | + $output .= $value . "\n"; |
|
128 | + return $output; |
|
129 | + }); |
|
130 | + } |
|
131 | + |
|
132 | + $this->assertSame($expectedReturn, self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput])); |
|
133 | + |
|
134 | + if ($expectedMessage !== null) { |
|
135 | + global $output; |
|
136 | + // Remove the trailing newline |
|
137 | + $this->assertSame($expectedMessage, substr($output, 0, -1)); |
|
138 | + } |
|
139 | + } |
|
140 | 140 | } |
@@ -19,83 +19,83 @@ |
||
19 | 19 | use Test\TestCase; |
20 | 20 | |
21 | 21 | class DeleteConfigTest extends TestCase { |
22 | - protected IAppConfig&MockObject $appConfig; |
|
23 | - protected ConfigManager&MockObject $configManager; |
|
24 | - protected InputInterface&MockObject $consoleInput; |
|
25 | - protected OutputInterface&MockObject $consoleOutput; |
|
26 | - protected Command $command; |
|
22 | + protected IAppConfig&MockObject $appConfig; |
|
23 | + protected ConfigManager&MockObject $configManager; |
|
24 | + protected InputInterface&MockObject $consoleInput; |
|
25 | + protected OutputInterface&MockObject $consoleOutput; |
|
26 | + protected Command $command; |
|
27 | 27 | |
28 | - protected function setUp(): void { |
|
29 | - parent::setUp(); |
|
28 | + protected function setUp(): void { |
|
29 | + parent::setUp(); |
|
30 | 30 | |
31 | - $this->appConfig = $this->createMock(IAppConfig::class); |
|
32 | - $this->configManager = $this->createMock(ConfigManager::class); |
|
33 | - $this->consoleInput = $this->createMock(InputInterface::class); |
|
34 | - $this->consoleOutput = $this->createMock(OutputInterface::class); |
|
31 | + $this->appConfig = $this->createMock(IAppConfig::class); |
|
32 | + $this->configManager = $this->createMock(ConfigManager::class); |
|
33 | + $this->consoleInput = $this->createMock(InputInterface::class); |
|
34 | + $this->consoleOutput = $this->createMock(OutputInterface::class); |
|
35 | 35 | |
36 | - $this->command = new DeleteConfig($this->appConfig, $this->configManager); |
|
37 | - } |
|
36 | + $this->command = new DeleteConfig($this->appConfig, $this->configManager); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - public static function dataDelete(): array { |
|
41 | - return [ |
|
42 | - [ |
|
43 | - 'name', |
|
44 | - true, |
|
45 | - true, |
|
46 | - 0, |
|
47 | - 'info', |
|
48 | - ], |
|
49 | - [ |
|
50 | - 'name', |
|
51 | - true, |
|
52 | - false, |
|
53 | - 0, |
|
54 | - 'info', |
|
55 | - ], |
|
56 | - [ |
|
57 | - 'name', |
|
58 | - false, |
|
59 | - false, |
|
60 | - 0, |
|
61 | - 'info', |
|
62 | - ], |
|
63 | - [ |
|
64 | - 'name', |
|
65 | - false, |
|
66 | - true, |
|
67 | - 1, |
|
68 | - 'error', |
|
69 | - ], |
|
70 | - ]; |
|
71 | - } |
|
40 | + public static function dataDelete(): array { |
|
41 | + return [ |
|
42 | + [ |
|
43 | + 'name', |
|
44 | + true, |
|
45 | + true, |
|
46 | + 0, |
|
47 | + 'info', |
|
48 | + ], |
|
49 | + [ |
|
50 | + 'name', |
|
51 | + true, |
|
52 | + false, |
|
53 | + 0, |
|
54 | + 'info', |
|
55 | + ], |
|
56 | + [ |
|
57 | + 'name', |
|
58 | + false, |
|
59 | + false, |
|
60 | + 0, |
|
61 | + 'info', |
|
62 | + ], |
|
63 | + [ |
|
64 | + 'name', |
|
65 | + false, |
|
66 | + true, |
|
67 | + 1, |
|
68 | + 'error', |
|
69 | + ], |
|
70 | + ]; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @dataProvider dataDelete |
|
75 | - */ |
|
76 | - public function testDelete(string $configName, bool $configExists, bool $checkIfExists, int $expectedReturn, string $expectedMessage): void { |
|
77 | - $this->appConfig->expects(($checkIfExists) ? $this->once() : $this->never()) |
|
78 | - ->method('getKeys') |
|
79 | - ->with('app-name') |
|
80 | - ->willReturn($configExists ? [$configName] : []); |
|
73 | + /** |
|
74 | + * @dataProvider dataDelete |
|
75 | + */ |
|
76 | + public function testDelete(string $configName, bool $configExists, bool $checkIfExists, int $expectedReturn, string $expectedMessage): void { |
|
77 | + $this->appConfig->expects(($checkIfExists) ? $this->once() : $this->never()) |
|
78 | + ->method('getKeys') |
|
79 | + ->with('app-name') |
|
80 | + ->willReturn($configExists ? [$configName] : []); |
|
81 | 81 | |
82 | - $this->appConfig->expects(($expectedReturn === 0) ? $this->once() : $this->never()) |
|
83 | - ->method('deleteKey') |
|
84 | - ->with('app-name', $configName); |
|
82 | + $this->appConfig->expects(($expectedReturn === 0) ? $this->once() : $this->never()) |
|
83 | + ->method('deleteKey') |
|
84 | + ->with('app-name', $configName); |
|
85 | 85 | |
86 | - $this->consoleInput->expects($this->exactly(2)) |
|
87 | - ->method('getArgument') |
|
88 | - ->willReturnMap([ |
|
89 | - ['app', 'app-name'], |
|
90 | - ['name', $configName], |
|
91 | - ]); |
|
92 | - $this->consoleInput->method('hasParameterOption') |
|
93 | - ->with('--error-if-not-exists') |
|
94 | - ->willReturn($checkIfExists); |
|
86 | + $this->consoleInput->expects($this->exactly(2)) |
|
87 | + ->method('getArgument') |
|
88 | + ->willReturnMap([ |
|
89 | + ['app', 'app-name'], |
|
90 | + ['name', $configName], |
|
91 | + ]); |
|
92 | + $this->consoleInput->method('hasParameterOption') |
|
93 | + ->with('--error-if-not-exists') |
|
94 | + ->willReturn($checkIfExists); |
|
95 | 95 | |
96 | - $this->consoleOutput->method('writeln') |
|
97 | - ->with($this->stringContains($expectedMessage)); |
|
96 | + $this->consoleOutput->method('writeln') |
|
97 | + ->with($this->stringContains($expectedMessage)); |
|
98 | 98 | |
99 | - $this->assertSame($expectedReturn, self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput])); |
|
100 | - } |
|
99 | + $this->assertSame($expectedReturn, self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput])); |
|
100 | + } |
|
101 | 101 | } |
@@ -17,311 +17,311 @@ |
||
17 | 17 | use Test\TestCase; |
18 | 18 | |
19 | 19 | class ListConfigsTest extends TestCase { |
20 | - /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
21 | - protected $appConfig; |
|
22 | - /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
23 | - protected $systemConfig; |
|
24 | - /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
25 | - protected $configManager; |
|
20 | + /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
21 | + protected $appConfig; |
|
22 | + /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
23 | + protected $systemConfig; |
|
24 | + /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
25 | + protected $configManager; |
|
26 | 26 | |
27 | - /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
28 | - protected $consoleInput; |
|
29 | - /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
30 | - protected $consoleOutput; |
|
27 | + /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
28 | + protected $consoleInput; |
|
29 | + /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
30 | + protected $consoleOutput; |
|
31 | 31 | |
32 | - /** @var \Symfony\Component\Console\Command\Command */ |
|
33 | - protected $command; |
|
32 | + /** @var \Symfony\Component\Console\Command\Command */ |
|
33 | + protected $command; |
|
34 | 34 | |
35 | - protected function setUp(): void { |
|
36 | - parent::setUp(); |
|
35 | + protected function setUp(): void { |
|
36 | + parent::setUp(); |
|
37 | 37 | |
38 | - $systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class) |
|
39 | - ->disableOriginalConstructor() |
|
40 | - ->getMock(); |
|
41 | - $appConfig = $this->appConfig = $this->getMockBuilder(IAppConfig::class) |
|
42 | - ->disableOriginalConstructor() |
|
43 | - ->getMock(); |
|
44 | - $configManager = $this->configManager = $this->getMockBuilder(ConfigManager::class) |
|
45 | - ->disableOriginalConstructor() |
|
46 | - ->getMock(); |
|
38 | + $systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class) |
|
39 | + ->disableOriginalConstructor() |
|
40 | + ->getMock(); |
|
41 | + $appConfig = $this->appConfig = $this->getMockBuilder(IAppConfig::class) |
|
42 | + ->disableOriginalConstructor() |
|
43 | + ->getMock(); |
|
44 | + $configManager = $this->configManager = $this->getMockBuilder(ConfigManager::class) |
|
45 | + ->disableOriginalConstructor() |
|
46 | + ->getMock(); |
|
47 | 47 | |
48 | - $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); |
|
49 | - $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); |
|
48 | + $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); |
|
49 | + $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); |
|
50 | 50 | |
51 | - /** @var \OC\SystemConfig $systemConfig */ |
|
52 | - /** @var \OCP\IAppConfig $appConfig */ |
|
53 | - /** @var ConfigManager $configManager */ |
|
54 | - $this->command = new ListConfigs($systemConfig, $appConfig, $configManager); |
|
55 | - } |
|
51 | + /** @var \OC\SystemConfig $systemConfig */ |
|
52 | + /** @var \OCP\IAppConfig $appConfig */ |
|
53 | + /** @var ConfigManager $configManager */ |
|
54 | + $this->command = new ListConfigs($systemConfig, $appConfig, $configManager); |
|
55 | + } |
|
56 | 56 | |
57 | - public static function listData(): array { |
|
58 | - return [ |
|
59 | - [ |
|
60 | - 'all', |
|
61 | - // config.php |
|
62 | - [ |
|
63 | - 'secret', |
|
64 | - 'overwrite.cli.url', |
|
65 | - ], |
|
66 | - [ |
|
67 | - ['secret', 'N;', IConfig::SENSITIVE_VALUE], |
|
68 | - ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
69 | - ], |
|
70 | - // app config |
|
71 | - [ |
|
72 | - ['files', false, [ |
|
73 | - 'enabled' => 'yes', |
|
74 | - ]], |
|
75 | - ['core', false, [ |
|
76 | - 'global_cache_gc_lastrun' => '1430388388', |
|
77 | - ]], |
|
78 | - ], |
|
79 | - false, |
|
80 | - json_encode([ |
|
81 | - 'system' => [ |
|
82 | - 'secret' => IConfig::SENSITIVE_VALUE, |
|
83 | - 'overwrite.cli.url' => 'http://localhost', |
|
84 | - ], |
|
85 | - 'apps' => [ |
|
86 | - 'core' => [ |
|
87 | - 'global_cache_gc_lastrun' => '1430388388', |
|
88 | - ], |
|
89 | - 'files' => [ |
|
90 | - 'enabled' => 'yes', |
|
91 | - ], |
|
92 | - ], |
|
93 | - ]), |
|
94 | - ], |
|
95 | - [ |
|
96 | - 'all', |
|
97 | - // config.php |
|
98 | - [ |
|
99 | - 'secret', |
|
100 | - 'overwrite.cli.url', |
|
101 | - ], |
|
102 | - [ |
|
103 | - ['secret', 'N;', 'my secret'], |
|
104 | - ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
105 | - ], |
|
106 | - // app config |
|
107 | - [ |
|
108 | - ['files', false, [ |
|
109 | - 'enabled' => 'yes', |
|
110 | - ]], |
|
111 | - ['core', false, [ |
|
112 | - 'global_cache_gc_lastrun' => '1430388388', |
|
113 | - ]], |
|
114 | - ], |
|
115 | - true, |
|
116 | - json_encode([ |
|
117 | - 'system' => [ |
|
118 | - 'secret' => 'my secret', |
|
119 | - 'overwrite.cli.url' => 'http://localhost', |
|
120 | - ], |
|
121 | - 'apps' => [ |
|
122 | - 'core' => [ |
|
123 | - 'global_cache_gc_lastrun' => '1430388388', |
|
124 | - ], |
|
125 | - 'files' => [ |
|
126 | - 'enabled' => 'yes', |
|
127 | - ], |
|
128 | - ], |
|
129 | - ]), |
|
130 | - ], |
|
131 | - [ |
|
132 | - 'system', |
|
133 | - // config.php |
|
134 | - [ |
|
135 | - 'secret', |
|
136 | - 'objectstore', |
|
137 | - 'overwrite.cli.url', |
|
138 | - ], |
|
139 | - [ |
|
140 | - ['secret', 'N;', IConfig::SENSITIVE_VALUE], |
|
141 | - ['objectstore', 'N;', [ |
|
142 | - 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
143 | - 'arguments' => [ |
|
144 | - 'username' => 'facebook100000123456789', |
|
145 | - 'password' => IConfig::SENSITIVE_VALUE, |
|
146 | - ], |
|
147 | - ]], |
|
148 | - ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
149 | - ], |
|
150 | - // app config |
|
151 | - [ |
|
152 | - ['files', false, [ |
|
153 | - 'enabled' => 'yes', |
|
154 | - ]], |
|
155 | - ['core', false, [ |
|
156 | - 'global_cache_gc_lastrun' => '1430388388', |
|
157 | - ]], |
|
158 | - ], |
|
159 | - false, |
|
160 | - json_encode([ |
|
161 | - 'system' => [ |
|
162 | - 'secret' => IConfig::SENSITIVE_VALUE, |
|
163 | - 'objectstore' => [ |
|
164 | - 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
165 | - 'arguments' => [ |
|
166 | - 'username' => 'facebook100000123456789', |
|
167 | - 'password' => IConfig::SENSITIVE_VALUE, |
|
168 | - ], |
|
169 | - ], |
|
170 | - 'overwrite.cli.url' => 'http://localhost', |
|
171 | - ], |
|
172 | - ]), |
|
173 | - ], |
|
174 | - [ |
|
175 | - 'system', |
|
176 | - // config.php |
|
177 | - [ |
|
178 | - 'secret', |
|
179 | - 'overwrite.cli.url', |
|
180 | - ], |
|
181 | - [ |
|
182 | - ['secret', 'N;', 'my secret'], |
|
183 | - ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
184 | - ], |
|
185 | - // app config |
|
186 | - [ |
|
187 | - ['files', false, [ |
|
188 | - 'enabled' => 'yes', |
|
189 | - ]], |
|
190 | - ['core', false, [ |
|
191 | - 'global_cache_gc_lastrun' => '1430388388', |
|
192 | - ]], |
|
193 | - ], |
|
194 | - true, |
|
195 | - json_encode([ |
|
196 | - 'system' => [ |
|
197 | - 'secret' => 'my secret', |
|
198 | - 'overwrite.cli.url' => 'http://localhost', |
|
199 | - ], |
|
200 | - ]), |
|
201 | - ], |
|
202 | - [ |
|
203 | - 'files', |
|
204 | - // config.php |
|
205 | - [ |
|
206 | - 'secret', |
|
207 | - 'overwrite.cli.url', |
|
208 | - ], |
|
209 | - [ |
|
210 | - ['secret', 'N;', 'my secret'], |
|
211 | - ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
212 | - ], |
|
213 | - // app config |
|
214 | - [ |
|
215 | - ['files', false, [ |
|
216 | - 'enabled' => 'yes', |
|
217 | - ]], |
|
218 | - ['core', false, [ |
|
219 | - 'global_cache_gc_lastrun' => '1430388388', |
|
220 | - ]], |
|
221 | - ], |
|
222 | - false, |
|
223 | - json_encode([ |
|
224 | - 'apps' => [ |
|
225 | - 'files' => [ |
|
226 | - 'enabled' => 'yes', |
|
227 | - ], |
|
228 | - ], |
|
229 | - ]), |
|
230 | - ], |
|
231 | - [ |
|
232 | - 'files', |
|
233 | - // config.php |
|
234 | - [ |
|
235 | - 'secret', |
|
236 | - 'overwrite.cli.url', |
|
237 | - ], |
|
238 | - [ |
|
239 | - ['secret', 'N;', 'my secret'], |
|
240 | - ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
241 | - ], |
|
242 | - // app config |
|
243 | - [ |
|
244 | - ['files', false, [ |
|
245 | - 'enabled' => 'yes', |
|
246 | - ]], |
|
247 | - ['core', false, [ |
|
248 | - 'global_cache_gc_lastrun' => '1430388388', |
|
249 | - ]], |
|
250 | - ], |
|
251 | - true, |
|
252 | - json_encode([ |
|
253 | - 'apps' => [ |
|
254 | - 'files' => [ |
|
255 | - 'enabled' => 'yes', |
|
256 | - ], |
|
257 | - ], |
|
258 | - ]), |
|
259 | - ], |
|
260 | - ]; |
|
261 | - } |
|
57 | + public static function listData(): array { |
|
58 | + return [ |
|
59 | + [ |
|
60 | + 'all', |
|
61 | + // config.php |
|
62 | + [ |
|
63 | + 'secret', |
|
64 | + 'overwrite.cli.url', |
|
65 | + ], |
|
66 | + [ |
|
67 | + ['secret', 'N;', IConfig::SENSITIVE_VALUE], |
|
68 | + ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
69 | + ], |
|
70 | + // app config |
|
71 | + [ |
|
72 | + ['files', false, [ |
|
73 | + 'enabled' => 'yes', |
|
74 | + ]], |
|
75 | + ['core', false, [ |
|
76 | + 'global_cache_gc_lastrun' => '1430388388', |
|
77 | + ]], |
|
78 | + ], |
|
79 | + false, |
|
80 | + json_encode([ |
|
81 | + 'system' => [ |
|
82 | + 'secret' => IConfig::SENSITIVE_VALUE, |
|
83 | + 'overwrite.cli.url' => 'http://localhost', |
|
84 | + ], |
|
85 | + 'apps' => [ |
|
86 | + 'core' => [ |
|
87 | + 'global_cache_gc_lastrun' => '1430388388', |
|
88 | + ], |
|
89 | + 'files' => [ |
|
90 | + 'enabled' => 'yes', |
|
91 | + ], |
|
92 | + ], |
|
93 | + ]), |
|
94 | + ], |
|
95 | + [ |
|
96 | + 'all', |
|
97 | + // config.php |
|
98 | + [ |
|
99 | + 'secret', |
|
100 | + 'overwrite.cli.url', |
|
101 | + ], |
|
102 | + [ |
|
103 | + ['secret', 'N;', 'my secret'], |
|
104 | + ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
105 | + ], |
|
106 | + // app config |
|
107 | + [ |
|
108 | + ['files', false, [ |
|
109 | + 'enabled' => 'yes', |
|
110 | + ]], |
|
111 | + ['core', false, [ |
|
112 | + 'global_cache_gc_lastrun' => '1430388388', |
|
113 | + ]], |
|
114 | + ], |
|
115 | + true, |
|
116 | + json_encode([ |
|
117 | + 'system' => [ |
|
118 | + 'secret' => 'my secret', |
|
119 | + 'overwrite.cli.url' => 'http://localhost', |
|
120 | + ], |
|
121 | + 'apps' => [ |
|
122 | + 'core' => [ |
|
123 | + 'global_cache_gc_lastrun' => '1430388388', |
|
124 | + ], |
|
125 | + 'files' => [ |
|
126 | + 'enabled' => 'yes', |
|
127 | + ], |
|
128 | + ], |
|
129 | + ]), |
|
130 | + ], |
|
131 | + [ |
|
132 | + 'system', |
|
133 | + // config.php |
|
134 | + [ |
|
135 | + 'secret', |
|
136 | + 'objectstore', |
|
137 | + 'overwrite.cli.url', |
|
138 | + ], |
|
139 | + [ |
|
140 | + ['secret', 'N;', IConfig::SENSITIVE_VALUE], |
|
141 | + ['objectstore', 'N;', [ |
|
142 | + 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
143 | + 'arguments' => [ |
|
144 | + 'username' => 'facebook100000123456789', |
|
145 | + 'password' => IConfig::SENSITIVE_VALUE, |
|
146 | + ], |
|
147 | + ]], |
|
148 | + ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
149 | + ], |
|
150 | + // app config |
|
151 | + [ |
|
152 | + ['files', false, [ |
|
153 | + 'enabled' => 'yes', |
|
154 | + ]], |
|
155 | + ['core', false, [ |
|
156 | + 'global_cache_gc_lastrun' => '1430388388', |
|
157 | + ]], |
|
158 | + ], |
|
159 | + false, |
|
160 | + json_encode([ |
|
161 | + 'system' => [ |
|
162 | + 'secret' => IConfig::SENSITIVE_VALUE, |
|
163 | + 'objectstore' => [ |
|
164 | + 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
165 | + 'arguments' => [ |
|
166 | + 'username' => 'facebook100000123456789', |
|
167 | + 'password' => IConfig::SENSITIVE_VALUE, |
|
168 | + ], |
|
169 | + ], |
|
170 | + 'overwrite.cli.url' => 'http://localhost', |
|
171 | + ], |
|
172 | + ]), |
|
173 | + ], |
|
174 | + [ |
|
175 | + 'system', |
|
176 | + // config.php |
|
177 | + [ |
|
178 | + 'secret', |
|
179 | + 'overwrite.cli.url', |
|
180 | + ], |
|
181 | + [ |
|
182 | + ['secret', 'N;', 'my secret'], |
|
183 | + ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
184 | + ], |
|
185 | + // app config |
|
186 | + [ |
|
187 | + ['files', false, [ |
|
188 | + 'enabled' => 'yes', |
|
189 | + ]], |
|
190 | + ['core', false, [ |
|
191 | + 'global_cache_gc_lastrun' => '1430388388', |
|
192 | + ]], |
|
193 | + ], |
|
194 | + true, |
|
195 | + json_encode([ |
|
196 | + 'system' => [ |
|
197 | + 'secret' => 'my secret', |
|
198 | + 'overwrite.cli.url' => 'http://localhost', |
|
199 | + ], |
|
200 | + ]), |
|
201 | + ], |
|
202 | + [ |
|
203 | + 'files', |
|
204 | + // config.php |
|
205 | + [ |
|
206 | + 'secret', |
|
207 | + 'overwrite.cli.url', |
|
208 | + ], |
|
209 | + [ |
|
210 | + ['secret', 'N;', 'my secret'], |
|
211 | + ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
212 | + ], |
|
213 | + // app config |
|
214 | + [ |
|
215 | + ['files', false, [ |
|
216 | + 'enabled' => 'yes', |
|
217 | + ]], |
|
218 | + ['core', false, [ |
|
219 | + 'global_cache_gc_lastrun' => '1430388388', |
|
220 | + ]], |
|
221 | + ], |
|
222 | + false, |
|
223 | + json_encode([ |
|
224 | + 'apps' => [ |
|
225 | + 'files' => [ |
|
226 | + 'enabled' => 'yes', |
|
227 | + ], |
|
228 | + ], |
|
229 | + ]), |
|
230 | + ], |
|
231 | + [ |
|
232 | + 'files', |
|
233 | + // config.php |
|
234 | + [ |
|
235 | + 'secret', |
|
236 | + 'overwrite.cli.url', |
|
237 | + ], |
|
238 | + [ |
|
239 | + ['secret', 'N;', 'my secret'], |
|
240 | + ['overwrite.cli.url', 'N;', 'http://localhost'], |
|
241 | + ], |
|
242 | + // app config |
|
243 | + [ |
|
244 | + ['files', false, [ |
|
245 | + 'enabled' => 'yes', |
|
246 | + ]], |
|
247 | + ['core', false, [ |
|
248 | + 'global_cache_gc_lastrun' => '1430388388', |
|
249 | + ]], |
|
250 | + ], |
|
251 | + true, |
|
252 | + json_encode([ |
|
253 | + 'apps' => [ |
|
254 | + 'files' => [ |
|
255 | + 'enabled' => 'yes', |
|
256 | + ], |
|
257 | + ], |
|
258 | + ]), |
|
259 | + ], |
|
260 | + ]; |
|
261 | + } |
|
262 | 262 | |
263 | - /** |
|
264 | - * @dataProvider listData |
|
265 | - * |
|
266 | - * @param string $app |
|
267 | - * @param array $systemConfigs |
|
268 | - * @param array $systemConfigMap |
|
269 | - * @param array $appConfig |
|
270 | - * @param bool $private |
|
271 | - * @param string $expected |
|
272 | - */ |
|
273 | - public function testList($app, $systemConfigs, $systemConfigMap, $appConfig, $private, $expected): void { |
|
274 | - $this->systemConfig->expects($this->any()) |
|
275 | - ->method('getKeys') |
|
276 | - ->willReturn($systemConfigs); |
|
277 | - if ($private) { |
|
278 | - $this->systemConfig->expects($this->any()) |
|
279 | - ->method('getValue') |
|
280 | - ->willReturnMap($systemConfigMap); |
|
281 | - $this->appConfig->expects($this->any()) |
|
282 | - ->method('getValues') |
|
283 | - ->willReturnMap($appConfig); |
|
284 | - } else { |
|
285 | - $this->systemConfig->expects($this->any()) |
|
286 | - ->method('getFilteredValue') |
|
287 | - ->willReturnMap($systemConfigMap); |
|
288 | - $this->appConfig->expects($this->any()) |
|
289 | - ->method('getFilteredValues') |
|
290 | - ->willReturnMap($appConfig); |
|
291 | - } |
|
263 | + /** |
|
264 | + * @dataProvider listData |
|
265 | + * |
|
266 | + * @param string $app |
|
267 | + * @param array $systemConfigs |
|
268 | + * @param array $systemConfigMap |
|
269 | + * @param array $appConfig |
|
270 | + * @param bool $private |
|
271 | + * @param string $expected |
|
272 | + */ |
|
273 | + public function testList($app, $systemConfigs, $systemConfigMap, $appConfig, $private, $expected): void { |
|
274 | + $this->systemConfig->expects($this->any()) |
|
275 | + ->method('getKeys') |
|
276 | + ->willReturn($systemConfigs); |
|
277 | + if ($private) { |
|
278 | + $this->systemConfig->expects($this->any()) |
|
279 | + ->method('getValue') |
|
280 | + ->willReturnMap($systemConfigMap); |
|
281 | + $this->appConfig->expects($this->any()) |
|
282 | + ->method('getValues') |
|
283 | + ->willReturnMap($appConfig); |
|
284 | + } else { |
|
285 | + $this->systemConfig->expects($this->any()) |
|
286 | + ->method('getFilteredValue') |
|
287 | + ->willReturnMap($systemConfigMap); |
|
288 | + $this->appConfig->expects($this->any()) |
|
289 | + ->method('getFilteredValues') |
|
290 | + ->willReturnMap($appConfig); |
|
291 | + } |
|
292 | 292 | |
293 | - $this->appConfig->expects($this->any()) |
|
294 | - ->method('getApps') |
|
295 | - ->willReturn(['core', 'files']); |
|
296 | - $this->appConfig->expects($this->any()) |
|
297 | - ->method('getValues') |
|
298 | - ->willReturnMap($appConfig); |
|
293 | + $this->appConfig->expects($this->any()) |
|
294 | + ->method('getApps') |
|
295 | + ->willReturn(['core', 'files']); |
|
296 | + $this->appConfig->expects($this->any()) |
|
297 | + ->method('getValues') |
|
298 | + ->willReturnMap($appConfig); |
|
299 | 299 | |
300 | - $this->consoleInput->expects($this->once()) |
|
301 | - ->method('getArgument') |
|
302 | - ->with('app') |
|
303 | - ->willReturn($app); |
|
300 | + $this->consoleInput->expects($this->once()) |
|
301 | + ->method('getArgument') |
|
302 | + ->with('app') |
|
303 | + ->willReturn($app); |
|
304 | 304 | |
305 | - $this->consoleInput->expects($this->any()) |
|
306 | - ->method('getOption') |
|
307 | - ->willReturnMap([ |
|
308 | - ['output', 'json'], |
|
309 | - ['private', $private], |
|
310 | - ]); |
|
305 | + $this->consoleInput->expects($this->any()) |
|
306 | + ->method('getOption') |
|
307 | + ->willReturnMap([ |
|
308 | + ['output', 'json'], |
|
309 | + ['private', $private], |
|
310 | + ]); |
|
311 | 311 | |
312 | - global $output; |
|
312 | + global $output; |
|
313 | 313 | |
314 | - $output = ''; |
|
315 | - $this->consoleOutput->expects($this->any()) |
|
316 | - ->method('writeln') |
|
317 | - ->willReturnCallback(function ($value) { |
|
318 | - global $output; |
|
319 | - $output .= $value . "\n"; |
|
320 | - return $output; |
|
321 | - }); |
|
314 | + $output = ''; |
|
315 | + $this->consoleOutput->expects($this->any()) |
|
316 | + ->method('writeln') |
|
317 | + ->willReturnCallback(function ($value) { |
|
318 | + global $output; |
|
319 | + $output .= $value . "\n"; |
|
320 | + return $output; |
|
321 | + }); |
|
322 | 322 | |
323 | - $this->invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); |
|
323 | + $this->invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); |
|
324 | 324 | |
325 | - $this->assertEquals($expected, trim($output, "\n")); |
|
326 | - } |
|
325 | + $this->assertEquals($expected, trim($output, "\n")); |
|
326 | + } |
|
327 | 327 | } |