2020-06-02 06:48:37 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
/**
|
2024-05-29 05:32:54 -04:00
|
|
|
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2020-06-02 06:48:37 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\UserStatus\Tests\BackgroundJob;
|
|
|
|
|
|
|
|
|
|
use OCA\UserStatus\BackgroundJob\ClearOldStatusesBackgroundJob;
|
|
|
|
|
use OCA\UserStatus\Db\UserStatusMapper;
|
|
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
2025-05-13 16:23:39 -04:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2020-06-02 06:48:37 -04:00
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
|
|
class ClearOldStatusesBackgroundJobTest extends TestCase {
|
2025-05-13 16:23:39 -04:00
|
|
|
private ITimeFactory&MockObject $time;
|
|
|
|
|
private UserStatusMapper&MockObject $mapper;
|
|
|
|
|
private ClearOldStatusesBackgroundJob $job;
|
2020-06-02 06:48:37 -04:00
|
|
|
|
|
|
|
|
protected function setUp(): void {
|
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
$this->time = $this->createMock(ITimeFactory::class);
|
|
|
|
|
$this->mapper = $this->createMock(UserStatusMapper::class);
|
|
|
|
|
|
|
|
|
|
$this->job = new ClearOldStatusesBackgroundJob($this->time, $this->mapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testRun(): void {
|
|
|
|
|
$this->mapper->expects($this->once())
|
2022-05-27 05:28:59 -04:00
|
|
|
->method('clearOlderThanClearAt')
|
2020-06-02 06:48:37 -04:00
|
|
|
->with(1337);
|
2020-09-02 06:25:02 -04:00
|
|
|
$this->mapper->expects($this->once())
|
|
|
|
|
->method('clearStatusesOlderThan')
|
2020-09-30 10:17:18 -04:00
|
|
|
->with(437, 1337);
|
2020-06-02 06:48:37 -04:00
|
|
|
|
|
|
|
|
$this->time->method('getTime')
|
|
|
|
|
->willReturn(1337);
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->job, 'run', [[]]);
|
|
|
|
|
}
|
|
|
|
|
}
|