Fix cron jobs

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling
2022-04-04 21:54:50 +02:00
committed by Julius Härtl
parent e4607b1a76
commit 99d720d935
5 changed files with 32 additions and 13 deletions

View File

@@ -30,24 +30,30 @@ use OCA\Deck\Db\BoardMapper;
use OCA\Deck\InvalidAttachmentType;
use OCA\Deck\Service\AttachmentService;
use OCA\Deck\Service\IAttachmentService;
use OCP\AppFramework\Utility\ITimeFactory;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class DeleteCronTest extends \Test\TestCase {
class DeleteCronTest extends TestCase {
/** @var BoardMapper|\PHPUnit\Framework\MockObject\MockObject */
/** @var ITimeFactory|MockObject */
private $timeFactory;
/** @var BoardMapper|MockObject */
protected $boardMapper;
/** @var AttachmentService|\PHPUnit\Framework\MockObject\MockObject */
/** @var AttachmentService|MockObject */
private $attachmentService;
/** @var AttachmentMapper|\PHPUnit\Framework\MockObject\MockObject */
/** @var AttachmentMapper|MockObject */
private $attachmentMapper;
/** @var DeleteCron */
protected $deleteCron;
public function setUp(): void {
parent::setUp();
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->boardMapper = $this->createMock(BoardMapper::class);
$this->attachmentService = $this->createMock(AttachmentService::class);
$this->attachmentMapper = $this->createMock(AttachmentMapper::class);
$this->deleteCron = new DeleteCron($this->boardMapper, $this->attachmentService, $this->attachmentMapper);
$this->deleteCron = new DeleteCron($this->timeFactory, $this->boardMapper, $this->attachmentService, $this->attachmentMapper);
}
protected function getBoard($id) {

View File

@@ -26,28 +26,34 @@ namespace OCA\Deck\Cron;
use OCA\Deck\Db\Card;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Notification\NotificationHelper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\ILogger;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class ScheduledNoificationsTest extends \Test\TestCase {
class ScheduledNoificationsTest extends TestCase {
/** @var CardMapper|\PHPUnit\Framework\MockObject\MockObject */
/** @var ITimeFactory|MockObject */
protected $timeFactory;
/** @var CardMapper|MockObject */
protected $cardMapper;
/** @var NotificationHelper|\PHPUnit\Framework\MockObject\MockObject */
/** @var NotificationHelper|MockObject */
protected $notificationHelper;
/** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
/** @var ILogger|MockObject */
protected $logger;
/** @var ScheduledNotifications */
protected $scheduledNotifications;
public function setUp(): void {
parent::setUp();
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->cardMapper = $this->createMock(CardMapper::class);
$this->notificationHelper = $this->createMock(NotificationHelper::class);
$this->logger = $this->createMock(ILogger::class);
$this->scheduledNotifications = new ScheduledNotifications($this->cardMapper, $this->notificationHelper, $this->logger);
$this->scheduledNotifications = new ScheduledNotifications($this->timeFactory, $this->cardMapper, $this->notificationHelper, $this->logger);
}
public function testDeleteCron() {
public function testScheduledCron() {
$c1 = new Card();
$c2 = new Card();
$cards = [$c1, $c2];