|
|
|
|
@ -15,11 +15,10 @@ use OCP\ISession; |
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
|
|
|
|
|
|
|
|
|
class SetUserTimezoneCommandTest extends ALoginTestCommand { |
|
|
|
|
/** @var IConfig|MockObject */ |
|
|
|
|
private $config; |
|
|
|
|
|
|
|
|
|
/** @var ISession|MockObject */ |
|
|
|
|
private $session; |
|
|
|
|
private IConfig&MockObject $config; |
|
|
|
|
|
|
|
|
|
private ISession&MockObject $session; |
|
|
|
|
|
|
|
|
|
protected function setUp(): void { |
|
|
|
|
parent::setUp(); |
|
|
|
|
@ -50,6 +49,15 @@ class SetUserTimezoneCommandTest extends ALoginTestCommand { |
|
|
|
|
$this->user->expects($this->once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn($this->username); |
|
|
|
|
$this->config->expects($this->once()) |
|
|
|
|
->method('getUserValue') |
|
|
|
|
->with( |
|
|
|
|
$this->username, |
|
|
|
|
'core', |
|
|
|
|
'timezone', |
|
|
|
|
'' |
|
|
|
|
) |
|
|
|
|
->willReturn(''); |
|
|
|
|
$this->config->expects($this->once()) |
|
|
|
|
->method('setUserValue') |
|
|
|
|
->with( |
|
|
|
|
@ -69,4 +77,32 @@ class SetUserTimezoneCommandTest extends ALoginTestCommand { |
|
|
|
|
|
|
|
|
|
$this->assertTrue($result->isSuccess()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testProcessAlreadySet(): void { |
|
|
|
|
$data = $this->getLoggedInLoginDataWithTimezone(); |
|
|
|
|
$this->user->expects($this->once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn($this->username); |
|
|
|
|
$this->config->expects($this->once()) |
|
|
|
|
->method('getUserValue') |
|
|
|
|
->with( |
|
|
|
|
$this->username, |
|
|
|
|
'core', |
|
|
|
|
'timezone', |
|
|
|
|
'', |
|
|
|
|
) |
|
|
|
|
->willReturn('Europe/Berlin'); |
|
|
|
|
$this->config->expects($this->never()) |
|
|
|
|
->method('setUserValue'); |
|
|
|
|
$this->session->expects($this->once()) |
|
|
|
|
->method('set') |
|
|
|
|
->with( |
|
|
|
|
'timezone', |
|
|
|
|
$this->timeZoneOffset |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$result = $this->cmd->process($data); |
|
|
|
|
|
|
|
|
|
$this->assertTrue($result->isSuccess()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|