Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
style(occ): clean up SettingTest class
Signed-off-by: Salvatore Martire <[email protected]>
  • Loading branch information
salmart-dev committed Jun 13, 2025
commit 438136a41227e0168e90140daebd40c33ddcd3c2
41 changes: 14 additions & 27 deletions tests/Core/Command/User/SettingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,31 @@

namespace Tests\Core\Command\User;

use InvalidArgumentException;
use OC\Core\Command\User\Setting;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class SettingTest extends TestCase {
/** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject */
protected $userManager;
/** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */
protected $config;
/** @var \OCP\IDBConnection|\PHPUnit\Framework\MockObject\MockObject */
protected $connection;
/** @var \Symfony\Component\Console\Input\InputInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $consoleInput;
/** @var \Symfony\Component\Console\Output\OutputInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $consoleOutput;
protected IUserManager&MockObject $userManager;
protected IConfig&MockObject $config;
protected IDBConnection&MockObject $connection;
protected InputInterface&MockObject $consoleInput;
protected MockObject&OutputInterface $consoleOutput;

protected function setUp(): void {
parent::setUp();

$this->userManager = $this->getMockBuilder(IUserManager::class)
->disableOriginalConstructor()
->getMock();
$this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->connection = $this->getMockBuilder(IDBConnection::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMockBuilder(InputInterface::class)
->disableOriginalConstructor()
->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)
->disableOriginalConstructor()
->getMock();
$this->userManager = $this->createMock(IUserManager::class);
$this->config = $this->createMock(IConfig::class);
$this->connection = $this->createMock(IDBConnection::class);
$this->consoleInput = $this->createMock(InputInterface::class);
$this->consoleOutput = $this->createMock(OutputInterface::class);
}

public function getCommand(array $methods = []) {
Expand Down Expand Up @@ -217,7 +204,7 @@ public function testCheckInput($arguments, $options, $parameterOptions, $user, $
try {
$this->invokePrivate($command, 'checkInput', [$this->consoleInput]);
$this->assertFalse($expectedException);
} catch (\InvalidArgumentException $e) {
} catch (InvalidArgumentException $e) {
$this->assertEquals($expectedException, $e->getMessage());
}
}
Expand All @@ -226,7 +213,7 @@ public function testCheckInputExceptionCatch(): void {
$command = $this->getCommand(['checkInput']);
$command->expects($this->once())
->method('checkInput')
->willThrowException(new \InvalidArgumentException('test'));
->willThrowException(new InvalidArgumentException('test'));

$this->consoleOutput->expects($this->once())
->method('writeln')
Expand Down