1
0

AdditionalTest.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Lukas Reschke <lukas@statuscode.ch>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace Test\Settings\Admin;
  24. use OC\Settings\Admin\Additional;
  25. use OCP\AppFramework\Http\TemplateResponse;
  26. use OCP\IConfig;
  27. use Test\TestCase;
  28. class AdditionalTest extends TestCase {
  29. /** @var Additional */
  30. private $admin;
  31. /** @var IConfig */
  32. private $config;
  33. public function setUp() {
  34. parent::setUp();
  35. $this->config = $this->getMockBuilder(IConfig::class)->getMock();
  36. $this->admin = new Additional(
  37. $this->config
  38. );
  39. }
  40. public function testGetForm() {
  41. $this->config
  42. ->expects($this->at(0))
  43. ->method('getSystemValue')
  44. ->with('mail_domain', '')
  45. ->willReturn('mx.nextcloud.com');
  46. $this->config
  47. ->expects($this->at(1))
  48. ->method('getSystemValue')
  49. ->with('mail_from_address', '')
  50. ->willReturn('no-reply@nextcloud.com');
  51. $this->config
  52. ->expects($this->at(2))
  53. ->method('getSystemValue')
  54. ->with('mail_smtpmode', '')
  55. ->willReturn('php');
  56. $this->config
  57. ->expects($this->at(3))
  58. ->method('getSystemValue')
  59. ->with('mail_smtpsecure', '')
  60. ->willReturn(true);
  61. $this->config
  62. ->expects($this->at(4))
  63. ->method('getSystemValue')
  64. ->with('mail_smtphost', '')
  65. ->willReturn('smtp.nextcloud.com');
  66. $this->config
  67. ->expects($this->at(5))
  68. ->method('getSystemValue')
  69. ->with('mail_smtpport', '')
  70. ->willReturn(25);
  71. $this->config
  72. ->expects($this->at(6))
  73. ->method('getSystemValue')
  74. ->with('mail_smtpauthtype', '')
  75. ->willReturn('login');
  76. $this->config
  77. ->expects($this->at(7))
  78. ->method('getSystemValue')
  79. ->with('mail_smtpauth', false)
  80. ->willReturn(true);
  81. $this->config
  82. ->expects($this->at(8))
  83. ->method('getSystemValue')
  84. ->with('mail_smtpname', '')
  85. ->willReturn('smtp.sender.com');
  86. $this->config
  87. ->expects($this->at(9))
  88. ->method('getSystemValue')
  89. ->with('mail_smtppassword', '')
  90. ->willReturn('mypassword');
  91. $expected = new TemplateResponse(
  92. 'settings',
  93. 'settings/admin/additional-mail',
  94. [
  95. 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
  96. 'mail_domain' => 'mx.nextcloud.com',
  97. 'mail_from_address' => 'no-reply@nextcloud.com',
  98. 'mail_smtpmode' => 'php',
  99. 'mail_smtpsecure' => true,
  100. 'mail_smtphost' => 'smtp.nextcloud.com',
  101. 'mail_smtpport' => 25,
  102. 'mail_smtpauthtype' => 'login',
  103. 'mail_smtpauth' => true,
  104. 'mail_smtpname' => 'smtp.sender.com',
  105. 'mail_smtppassword' => '********',
  106. ],
  107. ''
  108. );
  109. $this->assertEquals($expected, $this->admin->getForm());
  110. }
  111. public function testGetSection() {
  112. $this->assertSame('additional', $this->admin->getSection());
  113. }
  114. public function testGetPriority() {
  115. $this->assertSame(0, $this->admin->getPriority());
  116. }
  117. }