Skip to content

Commit

Permalink
fixup! Add imip processing
Browse files Browse the repository at this point in the history
  • Loading branch information
miaulalala committed Aug 22, 2022
1 parent 33842a8 commit 49ed373
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions tests/Unit/Job/PreviewEnhancementProcessingJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,65 +88,78 @@ public function testNoAccount(): void {
->method('findById')
->with(self::$argument['accountId'])
->willThrowException(new DoesNotExistException('Account does not exist'));

$this->logger->expects(self::once())
->method('debug');
$this->jobList->expects(self::once())
->method('remove');

$this->job->run(self::$argument);
}

public function testNoUser(): void {
$account = new Account(new MailAccount());
$mailAccount = new MailAccount();
$mailAccount->setUserId(1);
$account = new Account($mailAccount);

$this->accountService->expects(self::once())
->method('findById')
->with(self::$argument['accountId'])
->willReturn($account);

$this->manager->expects(self::once())
->method('get')
->with($account)
->with($account->getUserId())
->willReturn(null);
$this->logger->expects(self::once())
->method('debug');

$this->job->run(self::$argument);
}

public function testProvisionedNoPassword(): void {
$mailAccount = new MailAccount();
$mailAccount->setUserId(1);
$mailAccount->setProvisioningId(1);
$mailAccount->setInboundPassword(null);
$account = new Account($mailAccount);
$user = $this->createMock(IUser::class);
$user->setEnabled();

$this->accountService->expects(self::once())
->method('findById')
->with(self::$argument['accountId'])
->willReturn($account);

$this->manager->expects(self::once())
->method('get')
->with($account)
->with($account->getUserId())
->willReturn($user);
$user->expects(self::once())
->method('isEnabled')
->willReturn(true);
$this->logger->expects(self::once())
->method('info');

$this->job->run(self::$argument);
}

public function testProcessingError(): void {
$mailAccount = new MailAccount();
$mailAccount->setUserId(1);
$account = new Account($mailAccount);
$time = time();
$user = $this->createMock(IUser::class);
$user->setEnabled();

$this->accountService->expects(self::once())
->method('findById')
->with(self::$argument['accountId'])
->willReturn($account);

$this->manager->expects(self::once())
->method('get')
->with($account)
->with($account->getUserId())
->willReturn($user);
$user->expects(self::once())
->method('isEnabled')
->willReturn(true);
$this->time->expects(self::once())
->method('getTime')
->willReturn($time);
Expand All @@ -156,24 +169,29 @@ public function testProcessingError(): void {
->willThrowException(new Exception());
$this->logger->expects(self::once())
->method('error');

$this->job->run(self::$argument);
}

public function testProcessing(): void {
$mailAccount = new MailAccount();
$mailAccount->setUserId(1);
$account = new Account($mailAccount);
$time = time();
$user = $this->createMock(IUser::class);
$user->setEnabled();

$this->accountService->expects(self::once())
->method('findById')
->with(self::$argument['accountId'])
->willReturn($account);

$this->manager->expects(self::once())
->method('get')
->with($account)
->with($account->getUserId())
->willReturn($user);
$user->expects(self::once())
->method('isEnabled')
->willReturn(true);
$this->time->expects(self::once())
->method('getTime')
->willReturn($time);
Expand All @@ -182,6 +200,7 @@ public function testProcessing(): void {
->with(($time - (60 * 60 * 24 * 14)), $account);
$this->logger->expects(self::never())
->method('error');

$this->job->run(self::$argument);
}
}

0 comments on commit 49ed373

Please sign in to comment.