aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/tests
diff options
context:
space:
mode:
authorJosh <josh.t.richards@gmail.com>2024-07-12 18:59:45 -0400
committerFerdinand Thiessen <opensource@fthiessen.de>2025-02-12 13:29:58 +0100
commit84293441e8875dec808de2b6c924a11ef9b47ca8 (patch)
tree3a70276931664a992b1be7737eb32e74981ac05f /apps/settings/tests
parentf2b25a49a908f62e7b540c99d231d1ce3160e8c3 (diff)
downloadnextcloud-server-chore/mailer-tests.tar.gz
nextcloud-server-chore/mailer-tests.zip
test(Mailer): Align tests for mailer with stable30chore/mailer-tests
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/settings/tests')
-rw-r--r--apps/settings/tests/Settings/Admin/MailTest.php31
1 files changed, 22 insertions, 9 deletions
diff --git a/apps/settings/tests/Settings/Admin/MailTest.php b/apps/settings/tests/Settings/Admin/MailTest.php
index f5c5b91aad7..560e4f8e997 100644
--- a/apps/settings/tests/Settings/Admin/MailTest.php
+++ b/apps/settings/tests/Settings/Admin/MailTest.php
@@ -10,16 +10,14 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\IBinaryFinder;
use OCP\IConfig;
use OCP\IL10N;
-use OCP\Server;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class MailTest extends TestCase {
- /** @var Mail */
- private $admin;
- /** @var IConfig */
- private $config;
- /** @var IL10N */
- private $l10n;
+
+ private Mail $admin;
+ private IConfig&MockObject $config;
+ private IL10N&MockObject $l10n;
protected function setUp(): void {
parent::setUp();
@@ -32,7 +30,22 @@ class MailTest extends TestCase {
);
}
- public function testGetForm(): void {
+ public static function dataGetForm(): array {
+ return [
+ [true],
+ [false],
+ ];
+ }
+
+ /** @dataProvider dataGetForm */
+ public function testGetForm(bool $sendmail) {
+ $finder = $this->createMock(IBinaryFinder::class);
+ $finder->expects(self::once())
+ ->method('findBinaryPath')
+ ->with('sendmail')
+ ->willReturn($sendmail ? '/usr/bin/sendmail': false);
+ $this->overwriteService(IBinaryFinder::class, $finder);
+
$this->config
->expects($this->any())
->method('getSystemValue')
@@ -53,7 +66,7 @@ class MailTest extends TestCase {
'settings',
'settings/admin/additional-mail',
[
- 'sendmail_is_available' => (bool)Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'),
+ 'sendmail_is_available' => $sendmail,
'mail_domain' => 'mx.nextcloud.com',
'mail_from_address' => 'no-reply@nextcloud.com',
'mail_smtpmode' => 'smtp',