Kill dead code
> No tests found in class "Test\Share\MailNotificationsTest". Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
d2d9f74707
commit
9871e4eaee
4 changed files with 0 additions and 216 deletions
|
@ -808,7 +808,6 @@ return array(
|
||||||
'OC\\Share20\\ShareHelper' => $baseDir . '/lib/private/Share20/ShareHelper.php',
|
'OC\\Share20\\ShareHelper' => $baseDir . '/lib/private/Share20/ShareHelper.php',
|
||||||
'OC\\Share\\Constants' => $baseDir . '/lib/private/Share/Constants.php',
|
'OC\\Share\\Constants' => $baseDir . '/lib/private/Share/Constants.php',
|
||||||
'OC\\Share\\Helper' => $baseDir . '/lib/private/Share/Helper.php',
|
'OC\\Share\\Helper' => $baseDir . '/lib/private/Share/Helper.php',
|
||||||
'OC\\Share\\MailNotifications' => $baseDir . '/lib/private/Share/MailNotifications.php',
|
|
||||||
'OC\\Share\\SearchResultSorter' => $baseDir . '/lib/private/Share/SearchResultSorter.php',
|
'OC\\Share\\SearchResultSorter' => $baseDir . '/lib/private/Share/SearchResultSorter.php',
|
||||||
'OC\\Share\\Share' => $baseDir . '/lib/private/Share/Share.php',
|
'OC\\Share\\Share' => $baseDir . '/lib/private/Share/Share.php',
|
||||||
'OC\\Streamer' => $baseDir . '/lib/private/Streamer.php',
|
'OC\\Streamer' => $baseDir . '/lib/private/Streamer.php',
|
||||||
|
|
|
@ -838,7 +838,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
||||||
'OC\\Share20\\ShareHelper' => __DIR__ . '/../../..' . '/lib/private/Share20/ShareHelper.php',
|
'OC\\Share20\\ShareHelper' => __DIR__ . '/../../..' . '/lib/private/Share20/ShareHelper.php',
|
||||||
'OC\\Share\\Constants' => __DIR__ . '/../../..' . '/lib/private/Share/Constants.php',
|
'OC\\Share\\Constants' => __DIR__ . '/../../..' . '/lib/private/Share/Constants.php',
|
||||||
'OC\\Share\\Helper' => __DIR__ . '/../../..' . '/lib/private/Share/Helper.php',
|
'OC\\Share\\Helper' => __DIR__ . '/../../..' . '/lib/private/Share/Helper.php',
|
||||||
'OC\\Share\\MailNotifications' => __DIR__ . '/../../..' . '/lib/private/Share/MailNotifications.php',
|
|
||||||
'OC\\Share\\SearchResultSorter' => __DIR__ . '/../../..' . '/lib/private/Share/SearchResultSorter.php',
|
'OC\\Share\\SearchResultSorter' => __DIR__ . '/../../..' . '/lib/private/Share/SearchResultSorter.php',
|
||||||
'OC\\Share\\Share' => __DIR__ . '/../../..' . '/lib/private/Share/Share.php',
|
'OC\\Share\\Share' => __DIR__ . '/../../..' . '/lib/private/Share/Share.php',
|
||||||
'OC\\Streamer' => __DIR__ . '/../../..' . '/lib/private/Streamer.php',
|
'OC\\Streamer' => __DIR__ . '/../../..' . '/lib/private/Streamer.php',
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
||||||
*
|
|
||||||
* @author Björn Schießle <bjoern@schiessle.org>
|
|
||||||
* @author Joas Schilling <coding@schilljs.com>
|
|
||||||
* @author Lukas Reschke <lukas@statuscode.ch>
|
|
||||||
* @author Morris Jobke <hey@morrisjobke.de>
|
|
||||||
* @author Robin McCorkell <robin@mccorkell.me.uk>
|
|
||||||
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
|
||||||
* @author scolebrook <scolebrook@mac.com>
|
|
||||||
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
||||||
* @author Vincent Petry <pvince81@owncloud.com>
|
|
||||||
*
|
|
||||||
* @license AGPL-3.0
|
|
||||||
*
|
|
||||||
* 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 OC\Share;
|
|
||||||
|
|
||||||
use OCP\IL10N;
|
|
||||||
use OCP\IURLGenerator;
|
|
||||||
use OCP\IUser;
|
|
||||||
use OCP\Mail\IMailer;
|
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\Defaults;
|
|
||||||
use OCP\Util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class MailNotifications
|
|
||||||
*
|
|
||||||
* @package OC\Share
|
|
||||||
*/
|
|
||||||
class MailNotifications {
|
|
||||||
|
|
||||||
/** @var IUser sender userId */
|
|
||||||
private $user;
|
|
||||||
/** @var string sender email address */
|
|
||||||
private $replyTo;
|
|
||||||
/** @var string */
|
|
||||||
private $senderDisplayName;
|
|
||||||
/** @var IL10N */
|
|
||||||
private $l;
|
|
||||||
/** @var IMailer */
|
|
||||||
private $mailer;
|
|
||||||
/** @var Defaults */
|
|
||||||
private $defaults;
|
|
||||||
/** @var ILogger */
|
|
||||||
private $logger;
|
|
||||||
/** @var IURLGenerator */
|
|
||||||
private $urlGenerator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param IUser $user
|
|
||||||
* @param IL10N $l10n
|
|
||||||
* @param IMailer $mailer
|
|
||||||
* @param ILogger $logger
|
|
||||||
* @param Defaults $defaults
|
|
||||||
* @param IURLGenerator $urlGenerator
|
|
||||||
*/
|
|
||||||
public function __construct(IUser $user,
|
|
||||||
IL10N $l10n,
|
|
||||||
IMailer $mailer,
|
|
||||||
ILogger $logger,
|
|
||||||
Defaults $defaults,
|
|
||||||
IURLGenerator $urlGenerator) {
|
|
||||||
$this->l = $l10n;
|
|
||||||
$this->user = $user;
|
|
||||||
$this->mailer = $mailer;
|
|
||||||
$this->logger = $logger;
|
|
||||||
$this->defaults = $defaults;
|
|
||||||
$this->urlGenerator = $urlGenerator;
|
|
||||||
|
|
||||||
$this->replyTo = $this->user->getEMailAddress();
|
|
||||||
$this->senderDisplayName = $this->user->getDisplayName();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,125 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @author Lukas Reschke <lukas@owncloud.com>
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
|
||||||
* @license AGPL-3.0
|
|
||||||
*
|
|
||||||
* 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 Test\Share;
|
|
||||||
|
|
||||||
use OC\Share\MailNotifications;
|
|
||||||
use OCP\IL10N;
|
|
||||||
use OCP\IUser;
|
|
||||||
use OCP\Mail\IMailer;
|
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\Defaults;
|
|
||||||
use OCP\IURLGenerator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class MailNotificationsTest
|
|
||||||
*/
|
|
||||||
class MailNotificationsTest extends \Test\TestCase {
|
|
||||||
/** @var IL10N */
|
|
||||||
private $l10n;
|
|
||||||
/** @var IMailer | \PHPUnit_Framework_MockObject_MockObject */
|
|
||||||
private $mailer;
|
|
||||||
/** @var ILogger */
|
|
||||||
private $logger;
|
|
||||||
/** @var Defaults | \PHPUnit_Framework_MockObject_MockObject */
|
|
||||||
private $defaults;
|
|
||||||
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject */
|
|
||||||
private $user;
|
|
||||||
/** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject */
|
|
||||||
private $urlGenerator;
|
|
||||||
|
|
||||||
|
|
||||||
public function setUp() {
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->l10n = $this->getMockBuilder('\OCP\IL10N')
|
|
||||||
->disableOriginalConstructor()->getMock();
|
|
||||||
$this->mailer = $this->getMockBuilder('\OCP\Mail\IMailer')
|
|
||||||
->disableOriginalConstructor()->getMock();
|
|
||||||
$this->logger = $this->getMockBuilder('\OCP\ILogger')
|
|
||||||
->disableOriginalConstructor()->getMock();
|
|
||||||
$this->defaults = $this->getMockBuilder('\OCP\Defaults')
|
|
||||||
->disableOriginalConstructor()->getMock();
|
|
||||||
$this->user = $this->getMockBuilder('\OCP\IUser')
|
|
||||||
->disableOriginalConstructor()->getMock();
|
|
||||||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
|
||||||
|
|
||||||
$this->l10n->expects($this->any())
|
|
||||||
->method('t')
|
|
||||||
->will($this->returnCallback(function($text, $parameters = array()) {
|
|
||||||
return vsprintf($text, $parameters);
|
|
||||||
}));
|
|
||||||
|
|
||||||
$this->defaults
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getName')
|
|
||||||
->will($this->returnValue('UnitTestCloud'));
|
|
||||||
|
|
||||||
$this->user
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getEMailAddress')
|
|
||||||
->willReturn('sharer@owncloud.com');
|
|
||||||
$this->user
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getDisplayName')
|
|
||||||
->willReturn('TestUser');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $subject
|
|
||||||
*/
|
|
||||||
protected function setupMailerMock($subject, $to, $exceptionOnSend = true) {
|
|
||||||
$message = $this->getMockBuilder('\OC\Mail\Message')
|
|
||||||
->disableOriginalConstructor()->getMock();
|
|
||||||
|
|
||||||
$message
|
|
||||||
->expects($this->once())
|
|
||||||
->method('setSubject')
|
|
||||||
->with($subject);
|
|
||||||
$message
|
|
||||||
->expects($this->once())
|
|
||||||
->method('setTo')
|
|
||||||
->with($to);
|
|
||||||
$message
|
|
||||||
->expects($this->once())
|
|
||||||
->method('setHtmlBody');
|
|
||||||
$message
|
|
||||||
->expects($this->once())
|
|
||||||
->method('setPlainBody');
|
|
||||||
$message
|
|
||||||
->expects($this->once())
|
|
||||||
->method('setFrom')
|
|
||||||
->with([\OCP\Util::getDefaultEmailAddress('sharing-noreply') => 'TestUser via UnitTestCloud']);
|
|
||||||
|
|
||||||
$this->mailer
|
|
||||||
->expects($this->once())
|
|
||||||
->method('createMessage')
|
|
||||||
->will($this->returnValue($message));
|
|
||||||
if ($exceptionOnSend) {
|
|
||||||
$this->mailer
|
|
||||||
->expects($this->once())
|
|
||||||
->method('send')
|
|
||||||
->with($message)
|
|
||||||
->will($this->throwException(new \Exception('Some Exception Message')));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue