aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/tests/Unit/BackgroundJob/ClearOldStatusesBackgroundJobTest.php
blob: 66142082343f135de8888e3ce2ca3827e5297289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\UserStatus\Tests\BackgroundJob;

use OCA\UserStatus\BackgroundJob\ClearOldStatusesBackgroundJob;
use OCA\UserStatus\Db\UserStatusMapper;
use OCP\AppFramework\Utility\ITimeFactory;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;

class ClearOldStatusesBackgroundJobTest extends TestCase {
	private ITimeFactory&MockObject $time;
	private UserStatusMapper&MockObject $mapper;
	private ClearOldStatusesBackgroundJob $job;

	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())
			->method('clearOlderThanClearAt')
			->with(1337);
		$this->mapper->expects($this->once())
			->method('clearStatusesOlderThan')
			->with(437, 1337);

		$this->time->method('getTime')
			->willReturn(1337);

		self::invokePrivate($this->job, 'run', [[]]);
	}
}