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 | |
parent | bb73652970182353512d0a44e320ae4e54797c62 (diff) |
Use DI logger instead of custom one.
Fixes #1072.
Signed-off-by: Pierre Gordon pierregordon@protonmaiil.com
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Controller/AccountsControllerTest.php | 6 | ||||
-rw-r--r-- | tests/Controller/MessagesControllerTest.php | 4 | ||||
-rw-r--r-- | tests/Http/Middleware/ErrorMiddlewareTest.php | 6 | ||||
-rw-r--r-- | tests/Integration/Service/MailTransmissionIntegrationTest.php | 4 | ||||
-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 |
15 files changed, 36 insertions, 99 deletions
diff --git a/tests/Controller/AccountsControllerTest.php b/tests/Controller/AccountsControllerTest.php index b9073ccc4..518b61fb5 100644 --- a/tests/Controller/AccountsControllerTest.php +++ b/tests/Controller/AccountsControllerTest.php @@ -35,12 +35,12 @@ use OCA\Mail\Model\RepliedMessageData; use OCA\Mail\Service\AccountService; use OCA\Mail\Service\AliasesService; use OCA\Mail\Service\AutoConfig\AutoConfig; -use OCA\Mail\Service\Logger; use OCA\Mail\Service\SetupService; use OCA\Mail\Service\GroupsIntegration; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http; use OCP\IL10N; +use OCP\ILogger; use OCP\IRequest; use OCP\Security\ICrypto; use PHPUnit_Framework_MockObject_MockObject; @@ -65,7 +65,7 @@ class AccountsControllerTest extends TestCase { /** @var AutoConfig|PHPUnit_Framework_MockObject_MockObject */ private $autoConfig; - /** @var Logger|PHPUnit_Framework_MockObject_MockObject */ + /** @var ILogger|PHPUnit_Framework_MockObject_MockObject */ private $logger; /** @var IL10N|PHPUnit_Framework_MockObject_MockObject */ @@ -104,7 +104,7 @@ class AccountsControllerTest extends TestCase { ->will($this->returnArgument(0)); $this->userId = 'manfred'; $this->autoConfig = $this->createMock(AutoConfig::class); - $this->logger = $this->createMock(Logger::class); + $this->logger = $this->createMock(ILogger::class); $this->l10n = $this->createMock(IL10N::class); $this->crypto = $this->createMock(ICrypto::class); $this->aliasesService = $this->createMock(AliasesService::class); diff --git a/tests/Controller/MessagesControllerTest.php b/tests/Controller/MessagesControllerTest.php index 36eac5779..9efd630f4 100644 --- a/tests/Controller/MessagesControllerTest.php +++ b/tests/Controller/MessagesControllerTest.php @@ -33,7 +33,6 @@ use OCA\Mail\Http\HtmlResponse; use OCA\Mail\Mailbox; use OCA\Mail\Model\IMAPMessage; use OCA\Mail\Service\AccountService; -use OCA\Mail\Service\Logger; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\JSONResponse; @@ -41,6 +40,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\Folder; use OCP\Files\IMimeTypeDetector; use OCP\IL10N; +use OCP\ILogger; use OCP\IRequest; use OCP\IURLGenerator; @@ -73,7 +73,7 @@ class MessagesControllerTest extends TestCase { $this->userId = 'john'; $this->userFolder = $this->createMock(Folder::class); $this->request = $this->createMock(Request::class); - $this->logger = $this->createMock(Logger::class); + $this->logger = $this->createMock(ILogger::class); $this->l10n = $this->createMock(IL10N::class); $this->mimeTypeDetector = $this->createMock(IMimeTypeDetector::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); diff --git a/tests/Http/Middleware/ErrorMiddlewareTest.php b/tests/Http/Middleware/ErrorMiddlewareTest.php index 1331fe6e7..8f4a68d59 100644 --- a/tests/Http/Middleware/ErrorMiddlewareTest.php +++ b/tests/Http/Middleware/ErrorMiddlewareTest.php @@ -29,12 +29,12 @@ use OCA\Mail\Exception\NotImplemented; use OCA\Mail\Exception\ServiceException; use OCA\Mail\Http\JSONResponse; use OCA\Mail\Http\Middleware\ErrorMiddleware; -use OCA\Mail\Service\Logger; use OCP\AppFramework\Controller; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http; use OCP\AppFramework\Utility\IControllerMethodReflector; use OCP\IConfig; +use OCP\ILogger; use PHPUnit_Framework_MockObject_MockObject; class ErrorMiddlewareTest extends TestCase { @@ -42,7 +42,7 @@ class ErrorMiddlewareTest extends TestCase { /** @var IConfig|PHPUnit_Framework_MockObject_MockObject */ private $config; - /** @var Logger|PHPUnit_Framework_MockObject_MockObject */ + /** @var ILogger|PHPUnit_Framework_MockObject_MockObject */ private $logger; /** @var IControllerMethodReflector|PHPUnit_Framework_MockObject_MockObject */ @@ -55,7 +55,7 @@ class ErrorMiddlewareTest extends TestCase { parent::setUp(); $this->config = $this->createMock(IConfig::class); - $this->logger = $this->createMock(Logger::class); + $this->logger = $this->createMock(ILogger::class); $this->reflector = $this->createMock(IControllerMethodReflector::class); $this->middleware = new ErrorMiddleware($this->config, $this->logger, diff --git a/tests/Integration/Service/MailTransmissionIntegrationTest.php b/tests/Integration/Service/MailTransmissionIntegrationTest.php index 655f38506..5deafe547 100644 --- a/tests/Integration/Service/MailTransmissionIntegrationTest.php +++ b/tests/Integration/Service/MailTransmissionIntegrationTest.php @@ -31,11 +31,11 @@ use OCA\Mail\Model\NewMessageData; use OCA\Mail\Model\RepliedMessageData; use OCA\Mail\Service\Attachment\UploadedFile; use OCA\Mail\Service\AutoCompletion\AddressCollector; -use OCA\Mail\Service\Logger; use OCA\Mail\Service\MailTransmission; use OCA\Mail\SMTP\SmtpClientFactory; use OCA\Mail\Tests\Integration\Framework\ImapTest; use OCA\Mail\Tests\Integration\TestCase; +use OCP\ILogger; use OCP\IUser; class MailTransmissionIntegrationTest extends TestCase { @@ -75,7 +75,7 @@ class MailTransmissionIntegrationTest extends TestCase { $this->attachmentService = OC::$server->query(IAttachmentService::class); $this->user = $this->createTestUser(); $userFolder = OC::$server->getUserFolder($this->user->getUID()); - $this->transmission = new MailTransmission(OC::$server->query(AddressCollector::class), $userFolder, $this->attachmentService, OC::$server->query(SmtpClientFactory::class), OC::$server->query(Logger::class)); + $this->transmission = new MailTransmission(OC::$server->query(AddressCollector::class), $userFolder, $this->attachmentService, OC::$server->query(SmtpClientFactory::class), OC::$server->query(ILogger::class)); } public function testSendMail() { 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); } |