ClearOldStatusesBackgroundJobTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\UserStatus\Tests\BackgroundJob;
  8. use OCA\UserStatus\BackgroundJob\ClearOldStatusesBackgroundJob;
  9. use OCA\UserStatus\Db\UserStatusMapper;
  10. use OCP\AppFramework\Utility\ITimeFactory;
  11. use Test\TestCase;
  12. class ClearOldStatusesBackgroundJobTest extends TestCase {
  13. /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
  14. private $time;
  15. /** @var UserStatusMapper|\PHPUnit\Framework\MockObject\MockObject */
  16. private $mapper;
  17. /** @var ClearOldStatusesBackgroundJob */
  18. private $job;
  19. protected function setUp(): void {
  20. parent::setUp();
  21. $this->time = $this->createMock(ITimeFactory::class);
  22. $this->mapper = $this->createMock(UserStatusMapper::class);
  23. $this->job = new ClearOldStatusesBackgroundJob($this->time, $this->mapper);
  24. }
  25. public function testRun(): void {
  26. $this->mapper->expects($this->once())
  27. ->method('clearOlderThanClearAt')
  28. ->with(1337);
  29. $this->mapper->expects($this->once())
  30. ->method('clearStatusesOlderThan')
  31. ->with(437, 1337);
  32. $this->time->method('getTime')
  33. ->willReturn(1337);
  34. self::invokePrivate($this->job, 'run', [[]]);
  35. }
  36. }