chore(tests): make "execute" method in Add command public

to simplify test execution

Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
This commit is contained in:
Misha M.-Kupriyanov 2025-10-14 12:50:31 +02:00 committed by backportbot[bot]
parent ad97420496
commit 170d9368e0
2 changed files with 4 additions and 11 deletions

View file

@ -36,7 +36,7 @@ class Add extends Base {
;
}
protected function execute(InputInterface $input, OutputInterface $output): int {
public function execute(InputInterface $input, OutputInterface $output): int {
$io = new SymfonyStyle($input, $output);
$settingClass = $input->getArgument('settingClass');
if (!in_array(IDelegatedSettings::class, (array)class_implements($settingClass), true)) {

View file

@ -44,13 +44,6 @@ class AddTest extends TestCase {
$this->output = $this->createMock(OutputInterface::class);
}
/**
* Helper method to execute the command using reflection since execute() is protected
*/
private function executeCommand(): int {
return self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
public function testExecuteSuccessfulDelegation(): void {
$settingClass = \OCA\Settings\Settings\Admin\Server::class;
$groupId = 'testgroup';
@ -79,7 +72,7 @@ class AddTest extends TestCase {
->with($groupId, $settingClass)
->willReturn($authorizedGroup);
$result = $this->executeCommand();
$result = $this->command->execute($this->input, $this->output);
$this->assertEquals(0, $result);
}
@ -93,7 +86,7 @@ class AddTest extends TestCase {
->with('settingClass')
->willReturn($settingClass);
$result = $this->executeCommand();
$result = $this->command->execute($this->input, $this->output);
// Should return exit code 2 for invalid setting class
$this->assertEquals(2, $result);
@ -116,7 +109,7 @@ class AddTest extends TestCase {
->with($groupId)
->willReturn(false);
$result = $this->executeCommand();
$result = $this->command->execute($this->input, $this->output);
// Should return exit code 3 for non-existent group
$this->assertEquals(3, $result);