aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-03-04 23:14:09 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2024-03-07 22:40:30 +0100
commit9c1a87aec4bcfa5069e7a762b2efd324cefc1810 (patch)
tree982e3dd1c4b1c7123c1a8967a467ffbc222704fe /apps
parentfa14daf9680bc0697376d966af4c4c79fa294934 (diff)
downloadnextcloud-server-9c1a87aec4bcfa5069e7a762b2efd324cefc1810.tar.gz
nextcloud-server-9c1a87aec4bcfa5069e7a762b2efd324cefc1810.zip
fix(updatenotification): Update tests to match with changed constructors
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php (renamed from apps/updatenotification/tests/ResetTokenBackgroundJobTest.php)23
-rw-r--r--apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php (renamed from apps/updatenotification/tests/Notification/BackgroundJobTest.php)40
-rw-r--r--apps/updatenotification/tests/Controller/AdminControllerTest.php31
-rw-r--r--apps/updatenotification/tests/Notification/NotifierTest.php2
4 files changed, 49 insertions, 47 deletions
diff --git a/apps/updatenotification/tests/ResetTokenBackgroundJobTest.php b/apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php
index 56a82b5b726..7361e4daf91 100644
--- a/apps/updatenotification/tests/ResetTokenBackgroundJobTest.php
+++ b/apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php
@@ -27,24 +27,29 @@ declare(strict_types=1);
*/
namespace OCA\UpdateNotification\Tests;
-use OCA\UpdateNotification\ResetTokenBackgroundJob;
+use OCA\UpdateNotification\BackgroundJob\ResetToken as BackgroundJobResetToken;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\IAppConfig;
use OCP\IConfig;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
-class ResetTokenBackgroundJobTest extends TestCase {
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
- private $config;
- /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
- private $timeFactory;
- /** @var ResetTokenBackgroundJob */
- private $resetTokenBackgroundJob;
+class ResetTokenTest extends TestCase {
+ private IConfig|MockObject $config;
+ private IAppConfig|MockObject $appConfig;
+ private ITimeFactory|MockObject $timeFactory;
+ private BackgroundJobResetToken $resetTokenBackgroundJob;
protected function setUp(): void {
parent::setUp();
+ $this->appConfig = $this->createMock(IAppConfig::class);
$this->config = $this->createMock(IConfig::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
- $this->resetTokenBackgroundJob = new ResetTokenBackgroundJob($this->config, $this->timeFactory);
+ $this->resetTokenBackgroundJob = new BackgroundJobResetToken(
+ $this->timeFactory,
+ $this->config,
+ $this->appConfig,
+ );
}
public function testRunWithNotExpiredToken() {
diff --git a/apps/updatenotification/tests/Notification/BackgroundJobTest.php b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
index d669a5832b4..fd9affc87b3 100644
--- a/apps/updatenotification/tests/Notification/BackgroundJobTest.php
+++ b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
@@ -25,12 +25,13 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-namespace OCA\UpdateNotification\Tests\Notification;
+namespace OCA\UpdateNotification\Tests\BackgroundJob;
use OC\Installer;
use OC\Updater\VersionCheck;
-use OCA\UpdateNotification\Notification\BackgroundJob;
+use OCA\UpdateNotification\BackgroundJob\UpdateAvailableNotifications;
use OCP\App\IAppManager;
+use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IGroup;
@@ -41,26 +42,21 @@ use OCP\Notification\INotification;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
-class BackgroundJobTest extends TestCase {
- /** @var IConfig|MockObject */
- protected $config;
- /** @var IManager|MockObject */
- protected $notificationManager;
- /** @var IGroupManager|MockObject */
- protected $groupManager;
- /** @var IAppManager|MockObject */
- protected $appManager;
- /** @var ITimeFactory|MockObject */
- protected $timeFactory;
- /** @var Installer|MockObject */
- protected $installer;
- /** @var VersionCheck|MockObject */
- protected $versionCheck;
+class UpdateAvailableNotificationsTest extends TestCase {
+ private IConfig|MockObject $config;
+ private IManager|MockObject $notificationManager;
+ private IGroupManager|MockObject $groupManager;
+ private IAppManager|MockObject $appManager;
+ private IAppConfig|MockObject $appConfig;
+ private ITimeFactory|MockObject $timeFactory;
+ private Installer|MockObject $installer;
+ private VersionCheck|MockObject $versionCheck;
protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
+ $this->appConfig = $this->createMock(IAppConfig::class);
$this->notificationManager = $this->createMock(IManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->appManager = $this->createMock(IAppManager::class);
@@ -71,13 +67,14 @@ class BackgroundJobTest extends TestCase {
/**
* @param array $methods
- * @return BackgroundJob|MockObject
+ * @return UpdateAvailableNotifications|MockObject
*/
protected function getJob(array $methods = []) {
if (empty($methods)) {
- return new BackgroundJob(
+ return new UpdateAvailableNotifications(
$this->timeFactory,
$this->config,
+ $this->appConfig,
$this->notificationManager,
$this->groupManager,
$this->appManager,
@@ -86,17 +83,18 @@ class BackgroundJobTest extends TestCase {
);
}
{
- return $this->getMockBuilder(BackgroundJob::class)
+ return $this->getMockBuilder(UpdateAvailableNotifications::class)
->setConstructorArgs([
$this->timeFactory,
$this->config,
+ $this->appConfig,
$this->notificationManager,
$this->groupManager,
$this->appManager,
$this->installer,
$this->versionCheck,
])
- ->setMethods($methods)
+ ->onlyMethods($methods)
->getMock();
}
}
diff --git a/apps/updatenotification/tests/Controller/AdminControllerTest.php b/apps/updatenotification/tests/Controller/AdminControllerTest.php
index 836dc25f4aa..b58eb30f82e 100644
--- a/apps/updatenotification/tests/Controller/AdminControllerTest.php
+++ b/apps/updatenotification/tests/Controller/AdminControllerTest.php
@@ -27,32 +27,29 @@ declare(strict_types=1);
*/
namespace OCA\UpdateNotification\Tests\Controller;
+use OCA\UpdateNotification\BackgroundJob\ResetToken;
use OCA\UpdateNotification\Controller\AdminController;
-use OCA\UpdateNotification\ResetTokenBackgroundJob;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
+use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\Security\ISecureRandom;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class AdminControllerTest extends TestCase {
- /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
- private $request;
- /** @var IJobList|\PHPUnit\Framework\MockObject\MockObject */
- private $jobList;
- /** @var ISecureRandom|\PHPUnit\Framework\MockObject\MockObject */
- private $secureRandom;
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
- private $config;
- /** @var AdminController */
- private $adminController;
- /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
- private $timeFactory;
- /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
- private $l10n;
+ private IRequest|MockObject $request;
+ private IJobList|MockObject $jobList;
+ private ISecureRandom|MockObject $secureRandom;
+ private IConfig|MockObject $config;
+ private ITimeFactory|MockObject $timeFactory;
+ private IL10N|MockObject $l10n;
+ private IAppConfig|MockObject $appConfig;
+
+ private AdminController $adminController;
protected function setUp(): void {
parent::setUp();
@@ -61,6 +58,7 @@ class AdminControllerTest extends TestCase {
$this->jobList = $this->createMock(IJobList::class);
$this->secureRandom = $this->createMock(ISecureRandom::class);
$this->config = $this->createMock(IConfig::class);
+ $this->appConfig = $this->createMock(IAppConfig::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->l10n = $this->createMock(IL10N::class);
@@ -70,6 +68,7 @@ class AdminControllerTest extends TestCase {
$this->jobList,
$this->secureRandom,
$this->config,
+ $this->appConfig,
$this->timeFactory,
$this->l10n
);
@@ -79,7 +78,7 @@ class AdminControllerTest extends TestCase {
$this->jobList
->expects($this->once())
->method('add')
- ->with(ResetTokenBackgroundJob::class);
+ ->with(ResetToken::class);
$this->secureRandom
->expects($this->once())
->method('generate')
diff --git a/apps/updatenotification/tests/Notification/NotifierTest.php b/apps/updatenotification/tests/Notification/NotifierTest.php
index f5d98e88e23..f22e46422eb 100644
--- a/apps/updatenotification/tests/Notification/NotifierTest.php
+++ b/apps/updatenotification/tests/Notification/NotifierTest.php
@@ -89,7 +89,7 @@ class NotifierTest extends TestCase {
$this->userSession,
$this->groupManager,
])
- ->setMethods($methods)
+ ->onlyMethods($methods)
->getMock();
}
}