mirror of
https://github.com/nextcloud/server.git
synced 2026-04-25 08:08:33 -04:00
fix(updatenotification): Update tests to match with changed constructors
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
fa14daf968
commit
9c1a87aec4
4 changed files with 49 additions and 47 deletions
|
|
@ -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() {
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class NotifierTest extends TestCase {
|
|||
$this->userSession,
|
||||
$this->groupManager,
|
||||
])
|
||||
->setMethods($methods)
|
||||
->onlyMethods($methods)
|
||||
->getMock();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue