diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-05-26 22:07:04 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-05-26 22:07:32 +0300 |
commit | 3df83f9c746bcd39057530c7f52163543e40dbd8 (patch) | |
tree | c49d1893d5f176c19a2fee6407dc95699245d56d /tests | |
parent | 8f72ac860dc1d0eef9fa06c0f25459e4865ce627 (diff) |
Load accounts and their settings via initial state
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Unit/Controller/PageControllerTest.php | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php index f442c929e..837a97623 100644 --- a/tests/Unit/Controller/PageControllerTest.php +++ b/tests/Unit/Controller/PageControllerTest.php @@ -34,8 +34,8 @@ use OCA\Mail\Service\MailManager; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; -use OCP\IInitialStateService; use OCP\IRequest; use OCP\IURLGenerator; use OCP\IUser; @@ -75,7 +75,7 @@ class PageControllerTest extends TestCase { /** @var MailManager|MockObject */ private $mailManager; - /** @var IInitialStateService|MockObject */ + /** @var IInitialState|MockObject */ private $initialState; /** @var PageController */ @@ -97,7 +97,7 @@ class PageControllerTest extends TestCase { $this->userSession = $this->createMock(IUserSession::class); $this->preferences = $this->createMock(IUserPreferences::class); $this->mailManager = $this->createMock(MailManager::class); - $this->initialState = $this->createMock(IInitialStateService::class); + $this->initialState = $this->createMock(IInitialState::class); $this->logger = $this->createMock(LoggerInterface::class); $this->controller = new PageController( @@ -126,7 +126,7 @@ class PageControllerTest extends TestCase { ['external-avatars', 'true', 'true'], ['reply-mode', 'top', 'bottom'], ['collect-data', 'true', 'true'], - ['account-settings', json_encode([]), json_encode([])], + ['account-settings', null, json_encode([])], ]); $this->accountService->expects($this->once()) ->method('findByUserId') @@ -150,9 +150,6 @@ class PageControllerTest extends TestCase { ->will($this->returnValue([ 'accountId' => 1, ])); - $mailbox->expects($this->once()) - ->method('jsonSerialize') - ->willReturn(['id' => 'inbox']); $account1->expects($this->once()) ->method('getId') ->will($this->returnValue(1)); @@ -178,9 +175,7 @@ class PageControllerTest extends TestCase { 'a12', ], 'mailboxes' => [ - [ - 'id' => 'inbox', - ], + $mailbox, ], ], [ @@ -218,23 +213,23 @@ class PageControllerTest extends TestCase { ->with($this->equalTo('jane'), $this->equalTo('settings'), $this->equalTo('email'), $this->equalTo('')) ->will($this->returnValue('jane@doe.cz')); - $this->initialState->expects($this->exactly(2)) + $this->initialState->expects($this->exactly(5)) ->method('provideInitialState') ->withConsecutive( - ['mail', 'prefill_displayName', 'Jane Doe'], - ['mail', 'prefill_email', 'jane@doe.cz'] + ['debug', true], + ['accounts', $accountsJson], + ['account-settings', []], + ['prefill_displayName', 'Jane Doe'], + ['prefill_email', 'jane@doe.cz'] ); $expected = new TemplateResponse($this->appName, 'index', [ - 'debug' => true, 'attachment-size-limit' => 123, 'external-avatars' => 'true', 'reply-mode' => 'bottom', 'app-version' => '1.2.3', - 'accounts' => base64_encode(json_encode($accountsJson)), 'collect-data' => 'true', - 'account-settings' => base64_encode(json_encode([])), ]); $csp = new ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); |