From dba617ada32ed85eb151f42d38da07ead38b8739 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 2a1401a8a9dc8..57766f2672496 100644 --- a/settings/Controller/CheckSetupController.php +++ b/settings/Controller/CheckSetupController.php @@ -529,7 +529,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 5ba33b757455ba8e63bffda0e95e4f819f9b0347 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 | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php index cc1ed6555c3cd..8da90b91bfd24 100644 --- a/tests/Settings/Controller/CheckSetupControllerTest.php +++ b/tests/Settings/Controller/CheckSetupControllerTest.php @@ -511,6 +511,39 @@ 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, + ]) + ->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 511eade1d4e4f71d79b71c2e08c6087811816c95 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 57766f2672496..224c0cb30d3ab 100644 --- a/settings/Controller/CheckSetupController.php +++ b/settings/Controller/CheckSetupController.php @@ -529,7 +529,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 8da90b91bfd24..20184251d206d 100644 --- a/tests/Settings/Controller/CheckSetupControllerTest.php +++ b/tests/Settings/Controller/CheckSetupControllerTest.php @@ -533,11 +533,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'));