-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! feat(ocs): notify of new messages and provide API endpoint to …
…retrieve its contents
- Loading branch information
1 parent
e581687
commit afd43a0
Showing
1 changed file
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
namespace Unit\Controller; | ||
|
||
use ChristophWurst\Nextcloud\Testing\TestCase; | ||
use OCA\Mail\Account; | ||
use OCA\Mail\Controller\MessageApiController; | ||
use OCA\Mail\Db\LocalMessage; | ||
use OCA\Mail\Db\MailAccount; | ||
use OCA\Mail\IMAP\IMAPClientFactory; | ||
use OCA\Mail\Service\AccountService; | ||
use OCA\Mail\Service\AliasesService; | ||
use OCA\Mail\Service\Attachment\AttachmentService; | ||
use OCA\Mail\Service\DkimService; | ||
use OCA\Mail\Service\ItineraryService; | ||
use OCA\Mail\Service\MailManager; | ||
use OCA\Mail\Service\OutboxService; | ||
use OCA\Mail\Service\Search\MailSearch; | ||
use OCA\Mail\Service\TrustedSenderService; | ||
use OCP\AppFramework\Utility\ITimeFactory; | ||
use OCP\Files\IMimeTypeDetector; | ||
use OCP\IRequest; | ||
use OCP\IURLGenerator; | ||
use OCP\IUserManager; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class MessageApiControllerTest extends TestCase { | ||
private string $appName; | ||
private string $userId; | ||
private AliasesService|MockObject $aliasesService; | ||
private AttachmentService|MockObject $attachmentService; | ||
private OutboxService|MockObject $outboxService; | ||
private LoggerInterface|MockObject $logger; | ||
private MockObject|ITimeFactory $time; | ||
private MessageApiController $controller; | ||
private MockObject|AccountService $accountService; | ||
private OutboxService|MockObject $service; | ||
private MockObject|IRequest $request; | ||
private string $fromEmail = '[email protected]'; | ||
private int $accountId = 1; | ||
private Account $account; | ||
private LocalMessage $message; | ||
private IUserManager|MockObject $userManager; | ||
private TrustedSenderService|MockObject $trustedSenderService; | ||
private MailManager|MockObject $mailManager; | ||
private MailSearch|MockObject $mailSearch; | ||
private MockObject|IURLGenerator $urlGenerator; | ||
private MockObject|IMimeTypeDetector $mimeTypeDetector; | ||
private IMAPClientFactory|MockObject $imapClientFactory; | ||
private DkimService|MockObject $dkimService; | ||
private MockObject|ItineraryService $itineraryService; | ||
|
||
protected function setUp(): void { | ||
parent::setUp(); | ||
|
||
$this->appName = 'mail'; | ||
$this->service = $this->createMock(OutboxService::class); | ||
$this->userId = 'john'; | ||
$this->request = $this->createMock(IRequest::class); | ||
$this->accountService = $this->createMock(AccountService::class); | ||
$this->aliasesService = $this->createMock(AliasesService::class); | ||
$this->attachmentService = $this->createMock(AttachmentService::class); | ||
$this->outboxService = $this->createMock(OutboxService::class); | ||
$this->mailManager = $this->createMock(MailManager::class); | ||
$this->mailSearch = $this->createMock(MailSearch::class); | ||
$this->imapClientFactory = $this->createMock(IMAPClientFactory::class); | ||
$this->mimeTypeDetector = $this->createMock(IMimeTypeDetector::class); | ||
$this->urlGenerator = $this->createMock(IURLGenerator::class); | ||
$this->userManager = $this->createMock(IUserManager::class); | ||
$this->attachmentService = $this->createMock(AttachmentService::class); | ||
$this->outboxService = $this->createMock(OutboxService::class); | ||
$this->logger = $this->createMock(LoggerInterface::class); | ||
$this->time = $this->createMock(ITimeFactory::class); | ||
$this->dkimService = $this->createMock(DkimService::class); | ||
$this->itineraryService = $this->createMock(ItineraryService::class); | ||
$this->trustedSenderService = $this->createMock(TrustedSenderService::class); | ||
|
||
$this->controller = new MessageApiController($this->appName, | ||
$this->userId, | ||
$this->request, | ||
$this->accountService, | ||
$this->aliasesService, | ||
$this->attachmentService, | ||
$this->outboxService, | ||
$this->mailSearch, | ||
$this->mailManager, | ||
$this->imapClientFactory, | ||
$this->logger, | ||
$this->time, | ||
$this->urlGenerator, | ||
$this->mimeTypeDetector, | ||
$this->dkimService, | ||
$this->itineraryService, | ||
$this->trustedSenderService, | ||
); | ||
|
||
$mailAccount = new MailAccount(); | ||
$mailAccount->setId($this->accountId); | ||
$mailAccount->setEmail($this->fromEmail); | ||
$this->account = new Account($mailAccount); | ||
$this->message = new LocalMessage(); | ||
$this->message->setAccountId($this->accountId); | ||
$this->message->setSubject(''); | ||
$this->message->setBody(''); | ||
$this->message->setHtml(true); | ||
$this->message->setType(LocalMessage::TYPE_OUTGOING); | ||
} | ||
|
||
public function testGet() { | ||
|
||
|
||
|
||
} | ||
} |