From ea10c6a141ae7dcd813bc17f81a3f934e9ba32b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Pe=C3=B1a=20Segarra?= Date: Sun, 11 Nov 2018 00:55:41 +0100 Subject: [PATCH 1/3] Fix the warning appearing check setup when mail_smtpmode is not configured. Closes #11107 --- settings/Controller/CheckSetupController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php index fa4ed57ab9530..cc9cb17388ec3 100644 --- a/settings/Controller/CheckSetupController.php +++ b/settings/Controller/CheckSetupController.php @@ -530,7 +530,7 @@ protected function getCronErrors() { } protected function isPhpMailerUsed(): bool { - return $this->config->getSystemValue('mail_smtpmode', 'php') === 'php'; + return $this->config->getSystemValue('mail_smtpmode') === 'php'; } protected function hasOpcacheLoaded(): bool { From 9561a7a1e2cacca3a1d2a775a2492d411fe02636 Mon Sep 17 00:00:00 2001 From: Kyle Fazzari Date: Wed, 14 Nov 2018 08:41:38 -0800 Subject: [PATCH 2/3] Verify that isPhpMailerUsed uses config as expected Signed-off-by: Kyle Fazzari --- .../Controller/CheckSetupControllerTest.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php index 34c7d19bd8dfc..617685d6196a9 100644 --- a/tests/Settings/Controller/CheckSetupControllerTest.php +++ b/tests/Settings/Controller/CheckSetupControllerTest.php @@ -520,6 +520,40 @@ public function testCheck() { $this->assertEquals($expected, $this->checkSetupController->check()); } + public function testIsPhpMailerUsed() { + $checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController') + ->setConstructorArgs([ + 'settings', + $this->request, + $this->config, + $this->clientService, + $this->urlGenerator, + $this->util, + $this->l10n, + $this->checker, + $this->logger, + $this->dispatcher, + $this->db, + $this->lockingProvider, + $this->dateTimeFormatter, + $this->memoryInfo, + $this->secureRandom, + ]) + ->setMethods(null)->getMock(); + + $this->config->expects($this->at(0)) + ->method('getSystemValue') + ->with('mail_smtpmode', null) + ->will($this->returnValue('php')); + $this->config->expects($this->at(1)) + ->method('getSystemValue') + ->with('mail_smtpmode', null) + ->will($this->returnValue('not-php')); + + $this->assertTrue($this->invokePrivate($checkSetupController, 'isPhpMailerUsed')); + $this->assertFalse($this->invokePrivate($checkSetupController, 'isPhpMailerUsed')); + } + public function testGetCurlVersion() { $checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController') ->setConstructorArgs([ From 8e4f0f9d1734f15b28f10ce4b612b52b7621a3bc Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 19 Nov 2018 10:57:51 +0100 Subject: [PATCH 3/3] Use the proper default values Signed-off-by: Morris Jobke --- settings/Controller/CheckSetupController.php | 2 +- tests/Settings/Controller/CheckSetupControllerTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php index cc9cb17388ec3..ba56c72dccf67 100644 --- a/settings/Controller/CheckSetupController.php +++ b/settings/Controller/CheckSetupController.php @@ -530,7 +530,7 @@ protected function getCronErrors() { } protected function isPhpMailerUsed(): bool { - return $this->config->getSystemValue('mail_smtpmode') === 'php'; + return $this->config->getSystemValue('mail_smtpmode', 'smtp') === 'php'; } protected function hasOpcacheLoaded(): bool { diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php index 617685d6196a9..ff565f3734bd0 100644 --- a/tests/Settings/Controller/CheckSetupControllerTest.php +++ b/tests/Settings/Controller/CheckSetupControllerTest.php @@ -543,11 +543,11 @@ public function testIsPhpMailerUsed() { $this->config->expects($this->at(0)) ->method('getSystemValue') - ->with('mail_smtpmode', null) + ->with('mail_smtpmode', 'smtp') ->will($this->returnValue('php')); $this->config->expects($this->at(1)) ->method('getSystemValue') - ->with('mail_smtpmode', null) + ->with('mail_smtpmode', 'smtp') ->will($this->returnValue('not-php')); $this->assertTrue($this->invokePrivate($checkSetupController, 'isPhpMailerUsed'));