1
0

MailTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\Settings\Tests\Settings\Admin;
  7. use OCA\Settings\Settings\Admin\Mail;
  8. use OCP\AppFramework\Http\TemplateResponse;
  9. use OCP\IConfig;
  10. use OCP\IL10N;
  11. use Test\TestCase;
  12. class MailTest extends TestCase {
  13. /** @var Mail */
  14. private $admin;
  15. /** @var IConfig */
  16. private $config;
  17. /** @var IL10N */
  18. private $l10n;
  19. protected function setUp(): void {
  20. parent::setUp();
  21. $this->config = $this->getMockBuilder(IConfig::class)->getMock();
  22. $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
  23. $this->admin = new Mail(
  24. $this->config,
  25. $this->l10n
  26. );
  27. }
  28. public function testGetForm() {
  29. $this->config
  30. ->expects($this->any())
  31. ->method('getSystemValue')
  32. ->willReturnMap([
  33. ['mail_domain', '', 'mx.nextcloud.com'],
  34. ['mail_from_address', '', 'no-reply@nextcloud.com'],
  35. ['mail_smtpmode', '', 'smtp'],
  36. ['mail_smtpsecure', '', true],
  37. ['mail_smtphost', '', 'smtp.nextcloud.com'],
  38. ['mail_smtpport', '', 25],
  39. ['mail_smtpauth', false, true],
  40. ['mail_smtpname', '', 'smtp.sender.com'],
  41. ['mail_smtppassword', '', 'mypassword'],
  42. ['mail_sendmailmode', 'smtp', 'smtp'],
  43. ]);
  44. $expected = new TemplateResponse(
  45. 'settings',
  46. 'settings/admin/additional-mail',
  47. [
  48. 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
  49. 'mail_domain' => 'mx.nextcloud.com',
  50. 'mail_from_address' => 'no-reply@nextcloud.com',
  51. 'mail_smtpmode' => 'smtp',
  52. 'mail_smtpsecure' => true,
  53. 'mail_smtphost' => 'smtp.nextcloud.com',
  54. 'mail_smtpport' => 25,
  55. 'mail_smtpauth' => true,
  56. 'mail_smtpname' => 'smtp.sender.com',
  57. 'mail_smtppassword' => '********',
  58. 'mail_sendmailmode' => 'smtp',
  59. ],
  60. ''
  61. );
  62. $this->assertEquals($expected, $this->admin->getForm());
  63. }
  64. public function testGetSection() {
  65. $this->assertSame('server', $this->admin->getSection());
  66. }
  67. public function testGetPriority() {
  68. $this->assertSame(10, $this->admin->getPriority());
  69. }
  70. }