Skip to content

Commit

Permalink
Merge pull request #1090 from nextcloud/fix/remove-oc-backgroundjob-use
Browse files Browse the repository at this point in the history
chore: Migrate to OCP version of QueuedJob
  • Loading branch information
come-nc authored Feb 13, 2024
2 parents f36f3e4 + 63a35bc commit 970f0b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
25 changes: 12 additions & 13 deletions lib/Notification/BackgroundJob.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2016 Joas Schilling <[email protected]>
*
Expand All @@ -21,25 +24,21 @@

namespace OCA\FirstRunWizard\Notification;

use OC\BackgroundJob\QueuedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\QueuedJob;
use OCP\Notification\IManager as INotificationManager;

class BackgroundJob extends QueuedJob {

/** @var INotificationManager */
protected $notificationManager;

/**
* BackgroundJob constructor.
*
* @param INotificationManager $notificationManager
*/
public function __construct(INotificationManager $notificationManager) {
$this->notificationManager = $notificationManager;
public function __construct(
ITimeFactory $time,
protected INotificationManager $notificationManager,
) {
parent::__construct($time);
}

/**
* @param array $argument
* @return void
*/
protected function run($argument) {
$notification = $this->notificationManager->createNotification();
Expand All @@ -49,7 +48,7 @@ protected function run($argument) {
->setUser($argument['uid']);

if ($this->notificationManager->getCount($notification) === 0) {
$notification->setDateTime(new \DateTime());
$notification->setDateTime($this->time->getDateTime());
$this->notificationManager->notify($notification);
}
}
Expand Down
13 changes: 7 additions & 6 deletions tests/Notification/BackgroundJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
namespace OCA\FirstRunWizard\Tests\Notification;

use OCA\FirstRunWizard\Notification\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Notification\IManager;
use OCP\Notification\INotification;
use Test\TestCase;
Expand All @@ -35,17 +36,17 @@
* @group DB
*/
class BackgroundJobTest extends TestCase {
/** @var IManager|\PHPUnit_Framework_MockObject_MockObject */
protected $notificationManager;

/** @var BackgroundJob */
protected $job;
protected ITimeFactory $timeFactory;
protected IManager $notificationManager;
protected BackgroundJob $job;

protected function setUp(): void {
parent::setUp();
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->notificationManager = $this->createMock(IManager::class);
$this->job = new BackgroundJob(
$this->notificationManager
$this->timeFactory,
$this->notificationManager,
);
}

Expand Down

0 comments on commit 970f0b0

Please sign in to comment.