Skip to content

Commit 0721e52

Browse files
chore(tests): make "execute" method in Add command public
to simplify test execution Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
1 parent 329aeb2 commit 0721e52

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

apps/settings/lib/Command/AdminDelegation/Add.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function configure(): void {
3636
;
3737
}
3838

39-
protected function execute(InputInterface $input, OutputInterface $output): int {
39+
public function execute(InputInterface $input, OutputInterface $output): int {
4040
$io = new SymfonyStyle($input, $output);
4141
$settingClass = $input->getArgument('settingClass');
4242
if (!in_array(IDelegatedSettings::class, (array)class_implements($settingClass), true)) {

apps/settings/tests/Command/AdminDelegation/AddTest.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ protected function setUp(): void {
4444
$this->output = $this->createMock(OutputInterface::class);
4545
}
4646

47-
/**
48-
* Helper method to execute the command using reflection since execute() is protected
49-
*/
50-
private function executeCommand(): int {
51-
return self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
52-
}
53-
5447
public function testExecuteSuccessfulDelegation(): void {
5548
$settingClass = \OCA\Settings\Settings\Admin\Server::class;
5649
$groupId = 'testgroup';
@@ -79,7 +72,7 @@ public function testExecuteSuccessfulDelegation(): void {
7972
->with($groupId, $settingClass)
8073
->willReturn($authorizedGroup);
8174

82-
$result = $this->executeCommand();
75+
$result = $this->command->execute($this->input, $this->output);
8376

8477
$this->assertEquals(0, $result);
8578
}
@@ -93,7 +86,7 @@ public function testExecuteInvalidSettingClass(): void {
9386
->with('settingClass')
9487
->willReturn($settingClass);
9588

96-
$result = $this->executeCommand();
89+
$result = $this->command->execute($this->input, $this->output);
9790

9891
// Should return exit code 2 for invalid setting class
9992
$this->assertEquals(2, $result);
@@ -116,7 +109,7 @@ public function testExecuteNonExistentGroup(): void {
116109
->with($groupId)
117110
->willReturn(false);
118111

119-
$result = $this->executeCommand();
112+
$result = $this->command->execute($this->input, $this->output);
120113

121114
// Should return exit code 3 for non-existent group
122115
$this->assertEquals(3, $result);

0 commit comments

Comments
 (0)