1
0

MailTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  12. *
  13. * @license GNU AGPL version 3 or any later version
  14. *
  15. * This program is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License as
  17. * published by the Free Software Foundation, either version 3 of the
  18. * License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. *
  28. */
  29. namespace OCA\Settings\Tests\Settings\Admin;
  30. use OCA\Settings\Settings\Admin\Mail;
  31. use OCP\AppFramework\Http\TemplateResponse;
  32. use OCP\IConfig;
  33. use OCP\IL10N;
  34. use Test\TestCase;
  35. class MailTest extends TestCase {
  36. /** @var Mail */
  37. private $admin;
  38. /** @var IConfig */
  39. private $config;
  40. /** @var IL10N */
  41. private $l10n;
  42. protected function setUp(): void {
  43. parent::setUp();
  44. $this->config = $this->getMockBuilder(IConfig::class)->getMock();
  45. $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
  46. $this->admin = new Mail(
  47. $this->config,
  48. $this->l10n
  49. );
  50. }
  51. public function testGetForm() {
  52. $this->config
  53. ->expects($this->any())
  54. ->method('getSystemValue')
  55. ->willReturnMap([
  56. ['mail_domain', '', 'mx.nextcloud.com'],
  57. ['mail_from_address', '', 'no-reply@nextcloud.com'],
  58. ['mail_smtpmode', '', 'smtp'],
  59. ['mail_smtpsecure', '', true],
  60. ['mail_smtphost', '', 'smtp.nextcloud.com'],
  61. ['mail_smtpport', '', 25],
  62. ['mail_smtpauth', false, true],
  63. ['mail_smtpname', '', 'smtp.sender.com'],
  64. ['mail_smtppassword', '', 'mypassword'],
  65. ['mail_sendmailmode', 'smtp', 'smtp'],
  66. ]);
  67. $expected = new TemplateResponse(
  68. 'settings',
  69. 'settings/admin/additional-mail',
  70. [
  71. 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
  72. 'mail_domain' => 'mx.nextcloud.com',
  73. 'mail_from_address' => 'no-reply@nextcloud.com',
  74. 'mail_smtpmode' => 'smtp',
  75. 'mail_smtpsecure' => true,
  76. 'mail_smtphost' => 'smtp.nextcloud.com',
  77. 'mail_smtpport' => 25,
  78. 'mail_smtpauth' => true,
  79. 'mail_smtpname' => 'smtp.sender.com',
  80. 'mail_smtppassword' => '********',
  81. 'mail_sendmailmode' => 'smtp',
  82. ],
  83. ''
  84. );
  85. $this->assertEquals($expected, $this->admin->getForm());
  86. }
  87. public function testGetSection() {
  88. $this->assertSame('server', $this->admin->getSection());
  89. }
  90. public function testGetPriority() {
  91. $this->assertSame(10, $this->admin->getPriority());
  92. }
  93. }