diff options
Diffstat (limited to 'apps/settings/tests/Settings/Admin/MailTest.php')
-rw-r--r-- | apps/settings/tests/Settings/Admin/MailTest.php | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/apps/settings/tests/Settings/Admin/MailTest.php b/apps/settings/tests/Settings/Admin/MailTest.php index f5c5b91aad7..992c7d43dba 100644 --- a/apps/settings/tests/Settings/Admin/MailTest.php +++ b/apps/settings/tests/Settings/Admin/MailTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -10,21 +11,19 @@ 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(); - $this->config = $this->getMockBuilder(IConfig::class)->getMock(); - $this->l10n = $this->getMockBuilder(IL10N::class)->getMock(); + $this->config = $this->createMock(IConfig::class); + $this->l10n = $this->createMock(IL10N::class); $this->admin = new Mail( $this->config, @@ -32,7 +31,22 @@ class MailTest extends TestCase { ); } - public function testGetForm(): void { + public static function dataGetForm(): array { + return [ + [true], + [false], + ]; + } + + #[\PHPUnit\Framework\Attributes\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 +67,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', |