Don't use deprecated getMock() anymore

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-04-20 12:27:32 +02:00
parent 24789ba0f4
commit a0ada9aab4
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
4 changed files with 22 additions and 19 deletions

View File

@ -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]));
}

View File

@ -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` '.

View File

@ -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);

View File

@ -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()));