diff options
author | Pierre Gordon <pierregordon@protonmail.com> | 2018-12-28 06:55:23 +0300 |
---|---|---|
committer | Pierre Gordon <pierregordon@protonmail.com> | 2018-12-28 06:55:23 +0300 |
commit | 792ca06adf4fb0ae0e563be62eabbd845e44ad81 (patch) | |
tree | 4c7276022da5f0ca13289c736612730ab975473a /tests/Service | |
parent | bb73652970182353512d0a44e320ae4e54797c62 (diff) |
Use DI logger instead of custom one.
Fixes #1072.
Signed-off-by: Pierre Gordon pierregordon@protonmaiil.com
Diffstat (limited to 'tests/Service')
-rw-r--r-- | tests/Service/Autocompletion/AddressCollectorTest.php | 3 | ||||
-rw-r--r-- | tests/Service/Autoconfig/ConnectivityTesterTest.php | 6 | ||||
-rw-r--r-- | tests/Service/Autoconfig/ImapConnectivityTesterTest.php | 4 | ||||
-rw-r--r-- | tests/Service/Autoconfig/ImapConnectorTest.php | 6 | ||||
-rw-r--r-- | tests/Service/Autoconfig/IspDbTest.php | 3 | ||||
-rw-r--r-- | tests/Service/Autoconfig/MxRecordTest.php | 4 | ||||
-rw-r--r-- | tests/Service/Autoconfig/SmtpConnectivityTesterTest.php | 6 | ||||
-rw-r--r-- | tests/Service/DefaultAccount/ManagerTest.php | 6 | ||||
-rw-r--r-- | tests/Service/LoggerTest.php | 65 | ||||
-rw-r--r-- | tests/Service/MailTransmissionTest.php | 6 | ||||
-rw-r--r-- | tests/Service/SetupServiceTest.php | 6 |
11 files changed, 26 insertions, 89 deletions
diff --git a/tests/Service/Autocompletion/AddressCollectorTest.php b/tests/Service/Autocompletion/AddressCollectorTest.php index fcebaf883..8f420a983 100644 --- a/tests/Service/Autocompletion/AddressCollectorTest.php +++ b/tests/Service/Autocompletion/AddressCollectorTest.php @@ -25,6 +25,7 @@ use ChristophWurst\Nextcloud\Testing\TestCase; use OCA\Mail\AddressList; use OCA\Mail\Db\CollectedAddress; use OCA\Mail\Service\AutoCompletion\AddressCollector; +use OCP\ILogger; class AddressCollectorTest extends TestCase { @@ -39,7 +40,7 @@ class AddressCollectorTest extends TestCase { $this->mapper = $this->getMockBuilder('\OCA\Mail\Db\CollectedAddressMapper') ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->getMockBuilder('\OCA\Mail\Service\Logger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Service/Autoconfig/ConnectivityTesterTest.php b/tests/Service/Autoconfig/ConnectivityTesterTest.php index d18444638..9729463c3 100644 --- a/tests/Service/Autoconfig/ConnectivityTesterTest.php +++ b/tests/Service/Autoconfig/ConnectivityTesterTest.php @@ -23,12 +23,12 @@ namespace OCA\Mail\Tests\Service\Autoconfig; use ChristophWurst\Nextcloud\Testing\TestCase; use OCA\Mail\Service\AutoConfig\ConnectivityTester; -use OCA\Mail\Service\Logger; +use OCP\ILogger; use PHPUnit_Framework_MockObject_MockObject; class ConnectivityTesterTest extends TestCase { - /** @var Logger|PHPUnit_Framework_MockObject_MockObject */ + /** @var ILogger|PHPUnit_Framework_MockObject_MockObject */ private $logger; /** @var ConnectivityTester */ @@ -37,7 +37,7 @@ class ConnectivityTesterTest extends TestCase { protected function setUp() { parent::setUp(); - $this->logger = $this->createMock(Logger::class); + $this->logger = $this->createMock(ILogger::class); $this->tester = new ConnectivityTester($this->logger); } diff --git a/tests/Service/Autoconfig/ImapConnectivityTesterTest.php b/tests/Service/Autoconfig/ImapConnectivityTesterTest.php index f4d4d3813..39d4cebdd 100644 --- a/tests/Service/Autoconfig/ImapConnectivityTesterTest.php +++ b/tests/Service/Autoconfig/ImapConnectivityTesterTest.php @@ -26,7 +26,7 @@ use Horde_Imap_Client_Exception; use OCA\Mail\Service\AutoConfig\ConnectivityTester; use OCA\Mail\Service\AutoConfig\ImapConnectivityTester; use OCA\Mail\Service\AutoConfig\ImapConnector; -use OCA\Mail\Service\Logger; +use OCP\ILogger; use OpenCloud\Common\Log\Logger as Logger2; use PHPUnit_Framework_MockObject_MockObject; @@ -49,7 +49,7 @@ class ImapConnectivityTesterTest extends TestCase { $this->imapConnector = $this->createMock(ImapConnector::class); $this->connectivityTester = $this->createMock(ConnectivityTester::class); - $this->logger = $this->createMock(Logger::class); + $this->logger = $this->createMock(ILogger::class); $this->tester = new ImapConnectivityTester($this->imapConnector, $this->connectivityTester, 'dave', $this->logger); } diff --git a/tests/Service/Autoconfig/ImapConnectorTest.php b/tests/Service/Autoconfig/ImapConnectorTest.php index f4ebab547..a3fea541a 100644 --- a/tests/Service/Autoconfig/ImapConnectorTest.php +++ b/tests/Service/Autoconfig/ImapConnectorTest.php @@ -26,7 +26,7 @@ use Horde_Imap_Client_Exception; use OC; use OCA\Mail\Db\MailAccount; use OCA\Mail\Service\AutoConfig\ImapConnector; -use OCA\Mail\Service\Logger; +use OCP\ILogger; use OCP\Security\ICrypto; use PHPUnit_Framework_MockObject_MockObject; @@ -35,7 +35,7 @@ class ImapConnectorTest extends TestCase { /** @var ICrypto */ private $crypto; - /** @var Logger|PHPUnit_Framework_MockObject_MockObject */ + /** @var ILogger|PHPUnit_Framework_MockObject_MockObject */ private $logger; /** @var ImapConnector */ @@ -45,7 +45,7 @@ class ImapConnectorTest extends TestCase { parent::setUp(); $this->crypto = OC::$server->getCrypto(); - $this->logger = $this->createMock(Logger::class); + $this->logger = $this->createMock(ILogger::class); $this->connector = new ImapConnector($this->crypto, $this->logger, 'christopher'); } diff --git a/tests/Service/Autoconfig/IspDbTest.php b/tests/Service/Autoconfig/IspDbTest.php index 80924be6f..cca8f9c56 100644 --- a/tests/Service/Autoconfig/IspDbTest.php +++ b/tests/Service/Autoconfig/IspDbTest.php @@ -24,6 +24,7 @@ namespace OCA\Mail\Tests\Service\Autoconfig; use ChristophWurst\Nextcloud\Testing\TestCase; use OCA\Mail\Service\AutoConfig\IspDb; +use OCP\ILogger; class IspDbtest extends TestCase { @@ -32,7 +33,7 @@ class IspDbtest extends TestCase { protected function setUp() { parent::setUp(); - $this->logger = $this->getMockBuilder('\OCA\Mail\Service\Logger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/tests/Service/Autoconfig/MxRecordTest.php b/tests/Service/Autoconfig/MxRecordTest.php index 9f83f918d..536016f29 100644 --- a/tests/Service/Autoconfig/MxRecordTest.php +++ b/tests/Service/Autoconfig/MxRecordTest.php @@ -23,7 +23,7 @@ namespace OCA\Mail\Tests\Service\Autoconfig; use ChristophWurst\Nextcloud\Testing\TestCase; use OCA\Mail\Service\AutoConfig\MxRecord; -use OCA\Mail\Service\Logger; +use OCP\ILogger; class MxRecordTest extends TestCase { @@ -33,7 +33,7 @@ class MxRecordTest extends TestCase { protected function setUp() { parent::setUp(); - $logger = $this->createMock(Logger::class); + $logger = $this->createMock(ILogger::class); $this->record = new MxRecord($logger); } diff --git a/tests/Service/Autoconfig/SmtpConnectivityTesterTest.php b/tests/Service/Autoconfig/SmtpConnectivityTesterTest.php index 41fa8bb54..676f59cae 100644 --- a/tests/Service/Autoconfig/SmtpConnectivityTesterTest.php +++ b/tests/Service/Autoconfig/SmtpConnectivityTesterTest.php @@ -27,8 +27,8 @@ use Horde_Mail_Transport_Smtphorde; use OCA\Mail\Db\MailAccount; use OCA\Mail\Service\AutoConfig\ConnectivityTester; use OCA\Mail\Service\AutoConfig\SmtpConnectivityTester; -use OCA\Mail\Service\Logger; use OCA\Mail\SMTP\SmtpClientFactory; +use OCP\ILogger; use OCP\Security\ICrypto; use PHPUnit_Framework_MockObject_MockObject; @@ -43,7 +43,7 @@ class SmtpConnectivityTesterTest extends TestCase { /** @var SmtpClientFactory|PHPUnit_Framework_MockObject_MockObject */ private $clientFactory; - /** @var Logger|PHPUnit_Framework_MockObject_MockObject */ + /** @var ILogger|PHPUnit_Framework_MockObject_MockObject */ private $logger; /** @var SmtpConnectivityTester */ @@ -55,7 +55,7 @@ class SmtpConnectivityTesterTest extends TestCase { $this->connectivityTester = $this->createMock(ConnectivityTester::class); $this->crypto = $this->createMock(ICrypto::class); $this->clientFactory = $this->createMock(SmtpClientFactory::class); - $this->logger = $this->createMock(Logger::class); + $this->logger = $this->createMock(ILogger::class); $this->tester = new SmtpConnectivityTester($this->connectivityTester, $this->crypto, $this->clientFactory, $this->logger, 'dave'); } diff --git a/tests/Service/DefaultAccount/ManagerTest.php b/tests/Service/DefaultAccount/ManagerTest.php index b8ecb9c92..96fd15c0b 100644 --- a/tests/Service/DefaultAccount/ManagerTest.php +++ b/tests/Service/DefaultAccount/ManagerTest.php @@ -24,11 +24,11 @@ namespace OCA\Mail\Tests\Service\DefaultAccount; use ChristophWurst\Nextcloud\Testing\TestCase; use OCA\Mail\Db\MailAccount; use OCA\Mail\Service\DefaultAccount\Manager; -use OCA\Mail\Service\Logger; use OCP\Authentication\Exceptions\CredentialsUnavailableException; use OCP\Authentication\LoginCredentials\ICredentials; use OCP\Authentication\LoginCredentials\IStore; use OCP\IConfig; +use OCP\ILogger; use OCP\IUser; use OCP\IUserSession; use OCP\Security\ICrypto; @@ -42,7 +42,7 @@ class ManagerTest extends TestCase { /** @var IStore|PHPUnit_Framework_MockObject_MockObject */ private $credentialStore; - /** @var Logger|PHPUnit_Framework_MockObject_MockObject */ + /** @var ILogger|PHPUnit_Framework_MockObject_MockObject */ private $logger; /** @var IUserSession|PHPUnit_Framework_MockObject_MockObject */ @@ -59,7 +59,7 @@ class ManagerTest extends TestCase { $this->config = $this->createMock(IConfig::class); $this->credentialStore = $this->createMock(IStore::class); - $this->logger = $this->createMock(Logger::class); + $this->logger = $this->createMock(ILogger::class); $this->userSession = $this->createMock(IUserSession::class); $this->crypto = $this->createMock(ICrypto::class); diff --git a/tests/Service/LoggerTest.php b/tests/Service/LoggerTest.php deleted file mode 100644 index 6f882c0f3..000000000 --- a/tests/Service/LoggerTest.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -/** - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * Mail - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCA\Mail\Tests\Service; - -use ChristophWurst\Nextcloud\Testing\TestCase; -use Exception; -use OCA\Mail\Service\Logger; -use OCP\ILogger; - -class LoggerTest extends TestCase { - - /** - * @dataProvider providesLoggerMethods - * @param $method - */ - public function testLoggerMethod($method, $param = '1') { - - $baseLogger = $this->getMockBuilder(ILogger::class)->getMock(); - $baseLogger->expects($this->once()) - ->method($method) - ->with( - $this->equalTo($param), $this->equalTo([ - 'app' => 'mail', - 'key' => 'value', - ])); - - $logger = new Logger('mail', $baseLogger); - $logger->$method($param, ['key' => 'value']); - } - - public function providesLoggerMethods() { - return [ - ['alert'], - ['warning'], - ['emergency'], - ['critical'], - ['error'], - ['notice'], - ['info'], - ['debug'], - ['logException', new Exception()], - ]; - } - -} diff --git a/tests/Service/MailTransmissionTest.php b/tests/Service/MailTransmissionTest.php index 3179bac83..5e9e46be1 100644 --- a/tests/Service/MailTransmissionTest.php +++ b/tests/Service/MailTransmissionTest.php @@ -36,10 +36,10 @@ use OCA\Mail\Model\NewMessageData; use OCA\Mail\Model\RepliedMessageData; use OCA\Mail\Model\ReplyMessage; use OCA\Mail\Service\AutoCompletion\AddressCollector; -use OCA\Mail\Service\Logger; use OCA\Mail\Service\MailTransmission; use OCA\Mail\SMTP\SmtpClientFactory; use OCP\Files\Folder; +use OCP\ILogger; use PHPUnit_Framework_MockObject_MockObject; class MailTransmissionTest extends TestCase { @@ -56,7 +56,7 @@ class MailTransmissionTest extends TestCase { /** @var SmtpClientFactory|PHPUnit_Framework_MockObject_MockObject */ private $clientFactory; - /** @var Logger|PHPUnit_Framework_MockObject_MockObject */ + /** @var ILogger|PHPUnit_Framework_MockObject_MockObject */ private $logger; /** @var MailTransmission */ @@ -69,7 +69,7 @@ class MailTransmissionTest extends TestCase { $this->userFolder = $this->createMock(Folder::class); $this->attachmentService = $this->createMock(IAttachmentService::class); $this->clientFactory = $this->createMock(SmtpClientFactory::class); - $this->logger = $this->createMock(Logger::class); + $this->logger = $this->createMock(ILogger::class); $this->transmission = new MailTransmission($this->addressCollector, $this->userFolder, $this->attachmentService, $this->clientFactory, $this->logger); } diff --git a/tests/Service/SetupServiceTest.php b/tests/Service/SetupServiceTest.php index 342ac62dd..ed609ca5c 100644 --- a/tests/Service/SetupServiceTest.php +++ b/tests/Service/SetupServiceTest.php @@ -28,10 +28,10 @@ use OCA\Mail\Account; use OCA\Mail\Db\MailAccount; use OCA\Mail\Service\AccountService; use OCA\Mail\Service\AutoConfig\AutoConfig; -use OCA\Mail\Service\Logger; use OCA\Mail\Service\SetupService; use OCA\Mail\SMTP\SmtpClientFactory; use ChristophWurst\Nextcloud\Testing\TestCase; +use OCP\ILogger; use OCP\Security\ICrypto; use PHPUnit_Framework_MockObject_MockObject; @@ -49,7 +49,7 @@ class SetupServiceTest extends TestCase { /** @var SmtpClientFactory|PHPUnit_Framework_MockObject_MockObject */ private $smtpClientFactory; - /** @var Logger|PHPUnit_Framework_MockObject_MockObject */ + /** @var ILogger|PHPUnit_Framework_MockObject_MockObject */ private $logger; /** @var SetupService */ @@ -62,7 +62,7 @@ class SetupServiceTest extends TestCase { $this->accountService = $this->createMock(AccountService::class); $this->crypto = $this->createMock(ICrypto::class); $this->smtpClientFactory = $this->createMock(SmtpClientFactory::class); - $this->logger = $this->createMock(Logger::class); + $this->logger = $this->createMock(ILogger::class); $this->service = new SetupService($this->autoConfig, $this->accountService, $this->crypto, $this->smtpClientFactory, $this->logger); } |