Merge pull request #4406 from nextcloud/fix-unit-test-problems
Fix unit test problems
This commit is contained in:
commit
e9b00f84b8
|
@ -225,8 +225,8 @@ class CalendarTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider providesConfidentialClassificationData
|
||||
* @param $expectedChildren
|
||||
* @param $isShared
|
||||
* @param int $expectedChildren
|
||||
* @param bool $isShared
|
||||
*/
|
||||
public function testPrivateClassification($expectedChildren, $isShared) {
|
||||
|
||||
|
@ -268,8 +268,8 @@ class CalendarTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider providesConfidentialClassificationData
|
||||
* @param $expectedChildren
|
||||
* @param $isShared
|
||||
* @param int $expectedChildren
|
||||
* @param bool $isShared
|
||||
*/
|
||||
public function testConfidentialClassification($expectedChildren, $isShared) {
|
||||
$start = '20160609';
|
||||
|
|
|
@ -28,7 +28,12 @@ use Sabre\VObject\Reader;
|
|||
|
||||
class PublicCalendarTest extends CalendarTest {
|
||||
|
||||
public function testPrivateClassification() {
|
||||
/**
|
||||
* @dataProvider providesConfidentialClassificationData
|
||||
* @param int $expectedChildren
|
||||
* @param bool $isShared
|
||||
*/
|
||||
public function testPrivateClassification($expectedChildren, $isShared) {
|
||||
|
||||
$calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC];
|
||||
$calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL];
|
||||
|
@ -63,7 +68,12 @@ class PublicCalendarTest extends CalendarTest {
|
|||
$this->assertFalse($c->childExists('event-2'));
|
||||
}
|
||||
|
||||
public function testConfidentialClassification() {
|
||||
/**
|
||||
* @dataProvider providesConfidentialClassificationData
|
||||
* @param int $expectedChildren
|
||||
* @param bool $isShared
|
||||
*/
|
||||
public function testConfidentialClassification($expectedChildren, $isShared) {
|
||||
$start = '20160609';
|
||||
$end = '20160610';
|
||||
|
||||
|
@ -150,4 +160,4 @@ EOD;
|
|||
$this->assertArrayNotHasKey('DESCRIPTION', $event->VEVENT);
|
||||
$this->assertArrayNotHasKey('ORGANIZER', $event->VEVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ use OCP\Lock\LockedException;
|
|||
use OCP\Share\IManager;
|
||||
use OCP\Share;
|
||||
use Test\TestCase;
|
||||
use OCP\Share\IShare;
|
||||
|
||||
/**
|
||||
* Class ShareAPIControllerTest
|
||||
|
@ -549,18 +550,18 @@ class ShareAPIControllerTest extends TestCase {
|
|||
]));
|
||||
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
|
||||
|
||||
$share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
|
||||
$share = $this->createMock(IShare::class);
|
||||
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
|
||||
$share->method('getSharedWith')->willReturn('group2');
|
||||
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
|
||||
|
||||
// null group
|
||||
$share = $this->getMock('OCP\Share\IShare');
|
||||
$share = $this->createMock(IShare::class);
|
||||
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
|
||||
$share->method('getSharedWith')->willReturn('groupnull');
|
||||
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
|
||||
|
||||
$share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
|
||||
$share = $this->createMock(IShare::class);
|
||||
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
|
||||
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
|
||||
}
|
||||
|
|
|
@ -24,19 +24,19 @@ namespace OCA\Theming\Controller;
|
|||
|
||||
use OCA\Theming\IconBuilder;
|
||||
use OCA\Theming\ImageManager;
|
||||
use OCA\Theming\ThemingDefaults;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\NotFoundResponse;
|
||||
use OCP\AppFramework\Http\FileDisplayResponse;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Defaults;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\IRequest;
|
||||
use OCA\Theming\Util;
|
||||
use OCP\IConfig;
|
||||
|
||||
class IconController extends Controller {
|
||||
/** @var Defaults */
|
||||
/** @var ThemingDefaults */
|
||||
private $themingDefaults;
|
||||
/** @var Util */
|
||||
private $util;
|
||||
|
@ -54,7 +54,7 @@ class IconController extends Controller {
|
|||
*
|
||||
* @param string $appName
|
||||
* @param IRequest $request
|
||||
* @param Defaults $themingDefaults
|
||||
* @param ThemingDefaults $themingDefaults
|
||||
* @param Util $util
|
||||
* @param ITimeFactory $timeFactory
|
||||
* @param IConfig $config
|
||||
|
@ -64,7 +64,7 @@ class IconController extends Controller {
|
|||
public function __construct(
|
||||
$appName,
|
||||
IRequest $request,
|
||||
Defaults $themingDefaults,
|
||||
ThemingDefaults $themingDefaults,
|
||||
Util $util,
|
||||
ITimeFactory $timeFactory,
|
||||
IConfig $config,
|
||||
|
|
|
@ -24,11 +24,11 @@ namespace OCA\Theming\Tests\Controller;
|
|||
|
||||
|
||||
use OC\Files\SimpleFS\SimpleFile;
|
||||
use OCA\Theming\IconBuilder;
|
||||
use OCA\Theming\ImageManager;
|
||||
use OCA\Theming\ThemingDefaults;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\NotFoundResponse;
|
||||
use OCP\Defaults;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
|
@ -41,7 +41,7 @@ use OCP\AppFramework\Http\FileDisplayResponse;
|
|||
class IconControllerTest extends TestCase {
|
||||
/** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $request;
|
||||
/** @var Defaults|\PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var ThemingDefaults|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $themingDefaults;
|
||||
/** @var Util */
|
||||
private $util;
|
||||
|
@ -51,14 +51,14 @@ class IconControllerTest extends TestCase {
|
|||
private $iconController;
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
/** @var IRootFolder|\PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var IconBuilder|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $iconBuilder;
|
||||
/** @var ImageManager */
|
||||
private $imageManager;
|
||||
|
||||
public function setUp() {
|
||||
$this->request = $this->getMockBuilder('OCP\IRequest')->getMock();
|
||||
$this->themingDefaults = $this->getMockBuilder('OCP\Defaults')
|
||||
$this->themingDefaults = $this->getMockBuilder('OCA\Theming\ThemingDefaults')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$this->util = $this->getMockBuilder('\OCA\Theming\Util')->disableOriginalConstructor()
|
||||
->setMethods(['getAppImage', 'getAppIcon', 'elementColor'])->getMock();
|
||||
|
@ -109,7 +109,7 @@ class IconControllerTest extends TestCase {
|
|||
$expires->add(new \DateInterval('PT24H'));
|
||||
$expected->addHeader('Expires', $expires->format(\DateTime::RFC2822));
|
||||
$expected->addHeader('Pragma', 'cache');
|
||||
@$this->assertEquals($expected, $this->iconController->getThemedIcon('core', 'filetypes/folder.svg'));
|
||||
$this->assertEquals($expected, $this->iconController->getThemedIcon('core', 'filetypes/folder.svg'));
|
||||
}
|
||||
|
||||
public function testGetFaviconDefault() {
|
||||
|
|
|
@ -358,7 +358,7 @@ function execute_tests {
|
|||
fi
|
||||
|
||||
if [ -d "$2" ]; then
|
||||
for f in $(find "$2" -name '*.php'); do
|
||||
for f in $(find "$2" -name '*Test.php'); do
|
||||
echo "${PHPUNIT[@]}" --configuration phpunit-autotest.xml $GROUP $COVER --log-junit "autotest-results-$DB.xml" "$2" / "$f" "$3"
|
||||
"${PHPUNIT[@]}" --configuration phpunit-autotest.xml $GROUP $COVER --log-junit "autotest-results-$DB.xml" "$f" "$3"
|
||||
RESULT=$?
|
||||
|
|
|
@ -808,7 +808,6 @@ return array(
|
|||
'OC\\Share20\\ShareHelper' => $baseDir . '/lib/private/Share20/ShareHelper.php',
|
||||
'OC\\Share\\Constants' => $baseDir . '/lib/private/Share/Constants.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\\Share' => $baseDir . '/lib/private/Share/Share.php',
|
||||
'OC\\Streamer' => $baseDir . '/lib/private/Streamer.php',
|
||||
|
|
|
@ -838,7 +838,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OC\\Share20\\ShareHelper' => __DIR__ . '/../../..' . '/lib/private/Share20/ShareHelper.php',
|
||||
'OC\\Share\\Constants' => __DIR__ . '/../../..' . '/lib/private/Share/Constants.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\\Share' => __DIR__ . '/../../..' . '/lib/private/Share/Share.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();
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ class Defaults {
|
|||
* actual defaults
|
||||
* @since 6.0.0
|
||||
*/
|
||||
function __construct(\OC_Defaults $defaults = null) {
|
||||
public function __construct(\OC_Defaults $defaults = null) {
|
||||
if ($defaults === null) {
|
||||
$defaults = \OC::$server->getThemingDefaults();
|
||||
}
|
||||
|
|
|
@ -373,7 +373,7 @@ Raw output
|
|||
* Checks whether a PHP opcache is properly set up
|
||||
* @return bool
|
||||
*/
|
||||
private function isOpcacheProperlySetup() {
|
||||
protected function isOpcacheProperlySetup() {
|
||||
$iniWrapper = new IniGetWrapper();
|
||||
|
||||
$isOpcacheProperlySetUp = true;
|
||||
|
|
|
@ -68,8 +68,6 @@ class CheckSetupControllerTest extends TestCase {
|
|||
->disableOriginalConstructor()->getMock();
|
||||
$this->config = $this->getMockBuilder('\OCP\IConfig')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$this->config = $this->getMockBuilder('\OCP\IConfig')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$this->clientService = $this->getMockBuilder('\OCP\Http\Client\IClientService')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$this->util = $this->getMockBuilder('\OC_Util')
|
||||
|
@ -98,7 +96,7 @@ class CheckSetupControllerTest extends TestCase {
|
|||
$this->checker,
|
||||
$this->logger
|
||||
])
|
||||
->setMethods(['getCurlVersion', 'isPhpOutdated'])->getMock();
|
||||
->setMethods(['getCurlVersion', 'isPhpOutdated', 'isOpcacheProperlySetup'])->getMock();
|
||||
}
|
||||
|
||||
public function testIsInternetConnectionWorkingDisabledViaConfig() {
|
||||
|
@ -307,6 +305,10 @@ class CheckSetupControllerTest extends TestCase {
|
|||
->expects($this->once())
|
||||
->method('isPhpOutdated')
|
||||
->willReturn(true);
|
||||
$this->checkSetupController
|
||||
->expects($this->once())
|
||||
->method('isOpcacheProperlySetup')
|
||||
->willReturn(false);
|
||||
$this->urlGenerator->expects($this->at(2))
|
||||
->method('linkToDocs')
|
||||
->with('admin-reverse-proxy')
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace Tests\Settings\Controller;
|
|||
|
||||
use OC\Accounts\AccountManager;
|
||||
use OC\Group\Manager;
|
||||
use OC\Mail\IEMailTemplate;
|
||||
use OC\Settings\Controller\UsersController;
|
||||
use OC\Settings\Mailer\NewUserMailHelper;
|
||||
use OCP\App\IAppManager;
|
||||
|
@ -31,9 +30,12 @@ use OCP\IURLGenerator;
|
|||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Mail\IEMailTemplate;
|
||||
use OCP\Mail\IMailer;
|
||||
use OCP\Security\ICrypto;
|
||||
use OCP\Security\ISecureRandom;
|
||||
use OC\User\User;
|
||||
use Test\Util\User\Dummy;
|
||||
|
||||
/**
|
||||
* @group DB
|
||||
|
@ -164,8 +166,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testIndexAdmin() {
|
||||
$controller = $this->getController(true);
|
||||
|
||||
$foo = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$foo = $this->createMock(User::class);
|
||||
$foo
|
||||
->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
|
@ -192,8 +193,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->expects($this->once())
|
||||
->method('getBackendClassName')
|
||||
->will($this->returnValue('OC_User_Database'));
|
||||
$admin = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$admin = $this->createMock(User::class);
|
||||
$admin
|
||||
->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
|
@ -221,9 +221,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$admin
|
||||
->expects($this->once())
|
||||
->method('getBackendClassName')
|
||||
->will($this->returnValue('\Test\Util\User\Dummy'));
|
||||
$bar = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
->willReturn(Dummy::class);
|
||||
$bar = $this->createMock(User::class);
|
||||
$bar
|
||||
->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
|
@ -249,7 +248,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$bar
|
||||
->expects($this->once())
|
||||
->method('getBackendClassName')
|
||||
->will($this->returnValue('\Test\Util\User\Dummy'));
|
||||
->willReturn(Dummy::class);
|
||||
|
||||
$this->groupManager
|
||||
->expects($this->once())
|
||||
|
@ -322,7 +321,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'quota' => 404,
|
||||
'storageLocation' => '/home/admin',
|
||||
'lastLogin' => 12000,
|
||||
'backend' => '\Test\Util\User\Dummy',
|
||||
'backend' => Dummy::class,
|
||||
'email' => 'admin@bar.com',
|
||||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => false,
|
||||
|
@ -335,7 +334,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'quota' => 2323,
|
||||
'storageLocation' => '/home/bar',
|
||||
'lastLogin' => 3999000,
|
||||
'backend' => '\Test\Util\User\Dummy',
|
||||
'backend' => Dummy::class,
|
||||
'email' => 'bar@dummy.com',
|
||||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
|
@ -349,15 +348,13 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testIndexSubAdmin() {
|
||||
$controller = $this->getController(false);
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$this->userSession
|
||||
->expects($this->once())
|
||||
->method('getUser')
|
||||
->will($this->returnValue($user));
|
||||
|
||||
$foo = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$foo = $this->createMock(User::class);
|
||||
$foo
|
||||
->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
|
@ -384,8 +381,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->expects($this->once())
|
||||
->method('getBackendClassName')
|
||||
->will($this->returnValue('OC_User_Database'));
|
||||
$admin = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$admin = $this->createMock(User::class);
|
||||
$admin
|
||||
->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
|
@ -413,9 +409,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$admin
|
||||
->expects($this->once())
|
||||
->method('getBackendClassName')
|
||||
->will($this->returnValue('\Test\Util\User\Dummy'));
|
||||
$bar = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
->willReturn(Dummy::class);
|
||||
$bar = $this->createMock(User::class);
|
||||
$bar
|
||||
->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
|
@ -441,7 +436,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$bar
|
||||
->expects($this->once())
|
||||
->method('getBackendClassName')
|
||||
->will($this->returnValue('\Test\Util\User\Dummy'));
|
||||
->willReturn(Dummy::class);
|
||||
|
||||
$this->groupManager
|
||||
->expects($this->at(2))
|
||||
|
@ -515,7 +510,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'quota' => 2323,
|
||||
'storageLocation' => '/home/bar',
|
||||
'lastLogin' => 3999000,
|
||||
'backend' => '\Test\Util\User\Dummy',
|
||||
'backend' => Dummy::class,
|
||||
'email' => 'bar@dummy.com',
|
||||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
|
@ -541,7 +536,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'quota' => 404,
|
||||
'storageLocation' => '/home/admin',
|
||||
'lastLogin' => 12000,
|
||||
'backend' => '\Test\Util\User\Dummy',
|
||||
'backend' => Dummy::class,
|
||||
'email' => 'admin@bar.com',
|
||||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => false,
|
||||
|
@ -560,8 +555,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testIndexWithSearch() {
|
||||
$controller = $this->getController(true);
|
||||
|
||||
$foo = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$foo = $this->createMock(User::class);
|
||||
$foo
|
||||
->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
|
@ -588,8 +582,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->expects($this->once())
|
||||
->method('getBackendClassName')
|
||||
->will($this->returnValue('OC_User_Database'));
|
||||
$admin = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$admin = $this->createMock(User::class);
|
||||
$admin
|
||||
->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
|
@ -617,9 +610,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$admin
|
||||
->expects($this->once())
|
||||
->method('getBackendClassName')
|
||||
->will($this->returnValue('\Test\Util\User\Dummy'));
|
||||
$bar = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
->willReturn(Dummy::class);
|
||||
$bar = $this->createMock(User::class);
|
||||
$bar
|
||||
->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
|
@ -645,7 +637,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$bar
|
||||
->expects($this->once())
|
||||
->method('getBackendClassName')
|
||||
->will($this->returnValue('\Test\Util\User\Dummy'));
|
||||
->willReturn(Dummy::class);
|
||||
|
||||
$this->userManager
|
||||
->expects($this->once())
|
||||
|
@ -691,7 +683,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'quota' => 404,
|
||||
'storageLocation' => '/home/admin',
|
||||
'lastLogin' => 12000,
|
||||
'backend' => '\Test\Util\User\Dummy',
|
||||
'backend' => Dummy::class,
|
||||
'email' => 'admin@bar.com',
|
||||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => false,
|
||||
|
@ -704,7 +696,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'quota' => 2323,
|
||||
'storageLocation' => '/home/bar',
|
||||
'lastLogin' => 3999000,
|
||||
'backend' => '\Test\Util\User\Dummy',
|
||||
'backend' => Dummy::class,
|
||||
'email' => 'bar@dummy.com',
|
||||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
|
@ -718,8 +710,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testIndexWithBackend() {
|
||||
$controller = $this->getController(true);
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
|
@ -749,7 +740,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$this->userManager
|
||||
->expects($this->once())
|
||||
->method('getBackends')
|
||||
->will($this->returnValue([new \Test\Util\User\Dummy(), new \OC\User\Database()]));
|
||||
->will($this->returnValue([new Dummy(), new \OC\User\Database()]));
|
||||
$this->userManager
|
||||
->expects($this->once())
|
||||
->method('clearBackends');
|
||||
|
@ -787,7 +778,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
)
|
||||
)
|
||||
);
|
||||
$response = $controller->index(0, 10, '','', '\Test\Util\User\Dummy');
|
||||
$response = $controller->index(0, 10, '','', Dummy::class);
|
||||
$this->assertEquals($expectedResponse, $response);
|
||||
}
|
||||
|
||||
|
@ -797,7 +788,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$this->userManager
|
||||
->expects($this->once())
|
||||
->method('getBackends')
|
||||
->will($this->returnValue([new \Test\Util\User\Dummy(), new \OC\User\Database()]));
|
||||
->will($this->returnValue([new Dummy(), new \OC\User\Database()]));
|
||||
$this->userManager
|
||||
->expects($this->once())
|
||||
->method('search')
|
||||
|
@ -805,15 +796,14 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->will($this->returnValue([]));
|
||||
|
||||
$expectedResponse = new DataResponse([]);
|
||||
$response = $controller->index(0, 10, '','', '\Test\Util\User\Dummy');
|
||||
$response = $controller->index(0, 10, '','', Dummy::class);
|
||||
$this->assertEquals($expectedResponse, $response);
|
||||
}
|
||||
|
||||
public function testCreateSuccessfulWithoutGroupAdmin() {
|
||||
$controller = $this->getController(true);
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->method('getHome')
|
||||
->will($this->returnValue('/home/user'));
|
||||
|
@ -866,8 +856,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testCreateSuccessfulWithGroupAdmin() {
|
||||
$controller = $this->getController(true);
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->method('getHome')
|
||||
->will($this->returnValue('/home/user'));
|
||||
|
@ -1120,8 +1109,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testDestroySelfAdmin() {
|
||||
$controller = $this->getController(true);
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->expects($this->once())
|
||||
->method('getUID')
|
||||
|
@ -1146,8 +1134,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testDestroySelfSubadmin() {
|
||||
$controller = $this->getController(false);
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->expects($this->once())
|
||||
->method('getUID')
|
||||
|
@ -1172,14 +1159,12 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testDestroyAdmin() {
|
||||
$controller = $this->getController(true);
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->expects($this->once())
|
||||
->method('getUID')
|
||||
->will($this->returnValue('Admin'));
|
||||
$toDeleteUser = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$toDeleteUser = $this->createMock(User::class);
|
||||
$toDeleteUser
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
|
@ -1207,8 +1192,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
|
||||
public function testDestroySubAdmin() {
|
||||
$controller = $this->getController(false);
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->expects($this->once())
|
||||
->method('getUID')
|
||||
|
@ -1217,10 +1201,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getUser')
|
||||
->will($this->returnValue($user));
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$toDeleteUser = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$toDeleteUser = $this->createMock(User::class);
|
||||
$toDeleteUser
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
|
@ -1261,14 +1243,12 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testDestroyUnsuccessfulAdmin() {
|
||||
$controller = $this->getController(true);
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->expects($this->once())
|
||||
->method('getUID')
|
||||
->will($this->returnValue('Admin'));
|
||||
$toDeleteUser = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$toDeleteUser = $this->createMock(User::class);
|
||||
$toDeleteUser
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
|
@ -1296,8 +1276,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
|
||||
public function testDestroyUnsuccessfulSubAdmin() {
|
||||
$controller = $this->getController(false);
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->expects($this->once())
|
||||
->method('getUID')
|
||||
|
@ -1306,8 +1285,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getUser')
|
||||
->will($this->returnValue($user));
|
||||
|
||||
$toDeleteUser = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$toDeleteUser = $this->createMock(User::class);
|
||||
$toDeleteUser
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
|
@ -1348,8 +1326,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testDestroyNotAccessibleToSubAdmin() {
|
||||
$controller = $this->getController(false);
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->expects($this->once())
|
||||
->method('getUID')
|
||||
|
@ -1358,8 +1335,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getUser')
|
||||
->will($this->returnValue($user));
|
||||
|
||||
$toDeleteUser = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$toDeleteUser = $this->createMock(User::class);
|
||||
$this->userSession
|
||||
->method('getUser')
|
||||
->will($this->returnValue($user));
|
||||
|
@ -1419,8 +1395,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->with('validMail@Adre.ss')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->method('getHome')
|
||||
->will($this->returnValue('/home/user'));
|
||||
|
@ -1471,8 +1446,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
|
||||
private function mockUser($userId = 'foo', $displayName = 'M. Foo',
|
||||
$lastLogin = 500, $home = '/home/foo', $backend = 'OC_User_Database') {
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->expects($this->any())
|
||||
->method('getUID')
|
||||
|
@ -1707,8 +1681,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
public function testStatsSubAdmin() {
|
||||
$controller = $this->getController(false);
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
|
||||
$this->userSession
|
||||
->expects($this->once())
|
||||
|
@ -2002,7 +1975,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$user->method('canChangeDisplayName')->willReturn(true);
|
||||
|
||||
if ($data[AccountManager::PROPERTY_EMAIL]['value'] === $oldEmailAddress ||
|
||||
$oldEmailAddress === null && $data[AccountManager::PROPERTY_EMAIL]['value'] === '') {
|
||||
($oldEmailAddress === null && $data[AccountManager::PROPERTY_EMAIL]['value'] === '')) {
|
||||
$user->expects($this->never())->method('setEMailAddress');
|
||||
} else {
|
||||
$user->expects($this->once())->method('setEMailAddress')
|
||||
|
@ -2011,7 +1984,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
if ($data[AccountManager::PROPERTY_DISPLAYNAME]['value'] === $oldDisplayName ||
|
||||
$oldDisplayName === null && $data[AccountManager::PROPERTY_DISPLAYNAME]['value'] === '') {
|
||||
($oldDisplayName === null && $data[AccountManager::PROPERTY_DISPLAYNAME]['value'] === '')) {
|
||||
$user->expects($this->never())->method('setDisplayName');
|
||||
} else {
|
||||
$user->expects($this->once())->method('setDisplayName')
|
||||
|
@ -2170,8 +2143,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
*
|
||||
*/
|
||||
public function testSetEMailAddress($mailAddress, $isValid, $expectsUpdate, $canChangeDisplayName, $responseCode) {
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->expects($this->any())
|
||||
->method('getUID')
|
||||
|
@ -2223,8 +2195,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
|
||||
|
||||
public function testCreateSuccessfulWithoutPasswordAndWithEmail() {
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$user
|
||||
->method('getHome')
|
||||
->willReturn('/home/user');
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace Test;
|
|||
*
|
||||
* @package Test
|
||||
*/
|
||||
use OCP\IDBConnection;
|
||||
|
||||
class AllConfigTest extends \Test\TestCase {
|
||||
|
||||
/** @var \OCP\IDBConnection */
|
||||
|
@ -189,7 +191,7 @@ class AllConfigTest extends \Test\TestCase {
|
|||
->method('fetchColumn')
|
||||
->will($this->returnValue('valueSetUnchanged'));
|
||||
|
||||
$connectionMock = $this->getMock('\OCP\IDBConnection');
|
||||
$connectionMock = $this->createMock(IDBConnection::class);
|
||||
$connectionMock->expects($this->once())
|
||||
->method('executeQuery')
|
||||
->with($this->equalTo('SELECT `configvalue` FROM `*PREFIX*preferences` '.
|
||||
|
|
|
@ -274,7 +274,7 @@ class DefaultTokenProviderTest extends TestCase {
|
|||
public function testRenewSessionTokenWithoutPassword() {
|
||||
$token = $this->getMockBuilder(DefaultToken::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getUID', 'getLoginName', 'getPassword', 'getName'])
|
||||
->setMethods(['getUID', 'getLoginName', 'getPassword', 'getName', 'getRemember'])
|
||||
->getMock();
|
||||
$token
|
||||
->expects($this->at(0))
|
||||
|
@ -293,7 +293,7 @@ class DefaultTokenProviderTest extends TestCase {
|
|||
->method('getName')
|
||||
->willReturn('MyTokenName');
|
||||
$token
|
||||
->expects($this->at(3))
|
||||
->expects($this->at(4))
|
||||
->method('getRemember')
|
||||
->willReturn(IToken::DO_NOT_REMEMBER);
|
||||
$this->config
|
||||
|
@ -325,7 +325,7 @@ class DefaultTokenProviderTest extends TestCase {
|
|||
public function testRenewSessionTokenWithPassword() {
|
||||
$token = $this->getMockBuilder(DefaultToken::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getUID', 'getLoginName', 'getPassword', 'getName'])
|
||||
->setMethods(['getUID', 'getLoginName', 'getPassword', 'getName', 'getRemember'])
|
||||
->getMock();
|
||||
$token
|
||||
->expects($this->at(0))
|
||||
|
@ -348,7 +348,7 @@ class DefaultTokenProviderTest extends TestCase {
|
|||
->method('getName')
|
||||
->willReturn('MyTokenName');
|
||||
$token
|
||||
->expects($this->at(3))
|
||||
->expects($this->at(5))
|
||||
->method('getRemember')
|
||||
->willReturn(IToken::REMEMBER);
|
||||
$this->crypto
|
||||
|
|
|
@ -17,22 +17,22 @@ class ManagerTest extends TestCase {
|
|||
/** @var Manager */
|
||||
private $manager;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $logger;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $l10n;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var View|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $view;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var Util|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $util;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject | \OC\Memcache\ArrayCache */
|
||||
/** @var ArrayCache|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $arrayCache;
|
||||
|
||||
public function setUp() {
|
||||
|
@ -188,9 +188,9 @@ class ManagerTest extends TestCase {
|
|||
// * @expectedExceptionMessage Id "0" already used by encryption module "TestDummyModule0"
|
||||
// */
|
||||
// public function testModuleRegistration() {
|
||||
// $config = $this->getMock('\OCP\IConfig');
|
||||
// $config = $this->createMock(IConfig::class);
|
||||
// $config->expects($this->any())->method('getSystemValue')->willReturn(true);
|
||||
// $em = $this->getMock('\OCP\Encryption\IEncryptionModule');
|
||||
// $em = $this->createMock(IEncryptionModule::class);
|
||||
// $em->expects($this->any())->method('getId')->willReturn(0);
|
||||
// $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
|
||||
// $m = new Manager($config);
|
||||
|
@ -200,9 +200,9 @@ class ManagerTest extends TestCase {
|
|||
// }
|
||||
//
|
||||
// public function testModuleUnRegistration() {
|
||||
// $config = $this->getMock('\OCP\IConfig');
|
||||
// $config = $this->createMock(IConfig::class);
|
||||
// $config->expects($this->any())->method('getSystemValue')->willReturn(true);
|
||||
// $em = $this->getMock('\OCP\Encryption\IEncryptionModule');
|
||||
// $em = $this->createMock(IEncryptionModule::class);
|
||||
// $em->expects($this->any())->method('getId')->willReturn(0);
|
||||
// $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
|
||||
// $m = new Manager($config);
|
||||
|
@ -217,9 +217,9 @@ class ManagerTest extends TestCase {
|
|||
// * @expectedExceptionMessage Module with ID: unknown does not exist.
|
||||
// */
|
||||
// public function testGetEncryptionModuleUnknown() {
|
||||
// $config = $this->getMock('\OCP\IConfig');
|
||||
// $config = $this->createMock(IConfig::class);
|
||||
// $config->expects($this->any())->method('getSystemValue')->willReturn(true);
|
||||
// $em = $this->getMock('\OCP\Encryption\IEncryptionModule');
|
||||
// $em = $this->createMock(IEncryptionModule::class);
|
||||
// $em->expects($this->any())->method('getId')->willReturn(0);
|
||||
// $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
|
||||
// $m = new Manager($config);
|
||||
|
@ -229,9 +229,9 @@ class ManagerTest extends TestCase {
|
|||
// }
|
||||
//
|
||||
// public function testGetEncryptionModule() {
|
||||
// $config = $this->getMock('\OCP\IConfig');
|
||||
// $config = $this->createMock(IConfig::class);
|
||||
// $config->expects($this->any())->method('getSystemValue')->willReturn(true);
|
||||
// $em = $this->getMock('\OCP\Encryption\IEncryptionModule');
|
||||
// $em = $this->createMock(IEncryptionModule::class);
|
||||
// $em->expects($this->any())->method('getId')->willReturn(0);
|
||||
// $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
|
||||
// $m = new Manager($config);
|
||||
|
|
|
@ -943,7 +943,7 @@ class EncryptionTest extends Storage {
|
|||
* @dataProvider dataTestShouldEncrypt
|
||||
*
|
||||
* @param bool $encryptMountPoint
|
||||
* @param \PHPUnit_Framework_MockObject_MockObject | IEncryptionModule $encryptionModule
|
||||
* @param mixed $encryptionModule
|
||||
* @param bool $encryptionModuleShouldEncrypt
|
||||
* @param bool $expected
|
||||
*/
|
||||
|
@ -985,8 +985,15 @@ class EncryptionTest extends Storage {
|
|||
->setMethods(['getFullPath', 'getEncryptionModule'])
|
||||
->getMock();
|
||||
|
||||
if ($encryptionModule === true) {
|
||||
/** @var IEncryptionModule|\PHPUnit_Framework_MockObject_MockObject $encryptionModule */
|
||||
$encryptionModule = $this->createMock(IEncryptionModule::class);
|
||||
}
|
||||
|
||||
$wrapper->method('getFullPath')->with($path)->willReturn($fullPath);
|
||||
$wrapper->method('getEncryptionModule')->with($fullPath)
|
||||
$wrapper->expects($encryptMountPoint ? $this->once() : $this->never())
|
||||
->method('getEncryptionModule')
|
||||
->with($fullPath)
|
||||
->willReturnCallback(
|
||||
function() use ($encryptionModule) {
|
||||
if ($encryptionModule === false) {
|
||||
|
@ -999,12 +1006,15 @@ class EncryptionTest extends Storage {
|
|||
->willReturn($encryptMountPoint);
|
||||
|
||||
if ($encryptionModule !== null && $encryptionModule !== false) {
|
||||
$encryptionModule->method('shouldEncrypt')->with($fullPath)
|
||||
$encryptionModule
|
||||
->method('shouldEncrypt')
|
||||
->with($fullPath)
|
||||
->willReturn($encryptionModuleShouldEncrypt);
|
||||
}
|
||||
|
||||
if ($encryptionModule === null) {
|
||||
$encryptionManager->expects($this->once())->method('getEncryptionModule')
|
||||
$encryptionManager->expects($this->once())
|
||||
->method('getEncryptionModule')
|
||||
->willReturn($defaultEncryptionModule);
|
||||
}
|
||||
$defaultEncryptionModule->method('shouldEncrypt')->willReturn(true);
|
||||
|
@ -1015,12 +1025,11 @@ class EncryptionTest extends Storage {
|
|||
}
|
||||
|
||||
public function dataTestShouldEncrypt() {
|
||||
$encryptionModule = $this->createMock(IEncryptionModule::class);
|
||||
return [
|
||||
[false, false, false, false],
|
||||
[true, false, false, false],
|
||||
[true, $encryptionModule, false, false],
|
||||
[true, $encryptionModule, true, true],
|
||||
[true, true, false, false],
|
||||
[true, true, true, true],
|
||||
[true, null, false, true],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class FileTest extends TestCase
|
|||
if (isset($this->restore_logdateformat)) {
|
||||
$config->getSystemValue("logdateformat", $this->restore_logdateformat);
|
||||
} else {
|
||||
$config->deleteSystemValue("restore_logdateformat");
|
||||
$config->deleteSystemValue("logdateformat");
|
||||
}
|
||||
File::init();
|
||||
parent::tearDown();
|
||||
|
|
|
@ -17,15 +17,22 @@ class RedisTest extends Cache {
|
|||
self::markTestSkipped('The redis extension is not available.');
|
||||
}
|
||||
|
||||
$errorOccurred = false;
|
||||
set_error_handler(
|
||||
function($errno, $errstr) {
|
||||
restore_error_handler();
|
||||
self::markTestSkipped($errstr);
|
||||
throw new \RuntimeException($errstr, 123456789);
|
||||
},
|
||||
E_WARNING
|
||||
);
|
||||
$instance = new \OC\Memcache\Redis(self::getUniqueID());
|
||||
try {
|
||||
$instance = new \OC\Memcache\Redis(self::getUniqueID());
|
||||
} catch (\RuntimeException $e) {
|
||||
$errorOccurred = $e->getCode() === 123456789 ? $e->getMessage() : false;
|
||||
}
|
||||
restore_error_handler();
|
||||
if ($errorOccurred !== false) {
|
||||
self::markTestSkipped($errorOccurred);
|
||||
}
|
||||
|
||||
if ($instance->set(self::getUniqueID(), self::getUniqueID()) === false) {
|
||||
self::markTestSkipped('redis server seems to be down.');
|
||||
|
|
|
@ -87,7 +87,7 @@ class RepairTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testRunRepairStepsWithException() {
|
||||
$mock = $this->getMock('\Test\TestRepairStep');
|
||||
$mock = $this->createMock(TestRepairStep::class);
|
||||
$mock->expects($this->any())
|
||||
->method('run')
|
||||
->will($this->throwException(new \Exception()));
|
||||
|
|
|
@ -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')));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -204,12 +204,12 @@ class UserTest extends TestCase {
|
|||
/**
|
||||
* @var Backend | \PHPUnit_Framework_MockObject_MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(Dummy::class);
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
|
||||
$backend->expects($this->at(0))
|
||||
->method('implementsActions')
|
||||
->will($this->returnCallback(function ($actions) {
|
||||
if ($actions === Backend::GET_HOME) {
|
||||
if ($actions === \OC\User\Backend::GET_HOME) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue