Merge pull request #1212 from nextcloud/fix_federatedfilesharingtests
Fix deprecated usages of getMock in federatedfilesharing
This commit is contained in:
commit
5fe25fa648
|
@ -43,8 +43,10 @@ class AddressHandlerTest extends \Test\TestCase {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->urlGenerator = $this->getMock('OCP\IURLGenerator');
|
$this->urlGenerator = $this->getMockBuilder('OCP\IURLGenerator')
|
||||||
$this->il10n = $this->getMock('OCP\IL10N');
|
->getMock();
|
||||||
|
$this->il10n = $this->getMockBuilder('OCP\IL10N')
|
||||||
|
->getMock();
|
||||||
|
|
||||||
$this->addressHandler = new AddressHandler($this->urlGenerator, $this->il10n);
|
$this->addressHandler = new AddressHandler($this->urlGenerator, $this->il10n);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,8 @@ class DiscoveryManagerTest extends \Test\TestCase {
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->cache = $this->getMock('\OCP\ICache');
|
$this->cache = $this->getMockBuilder('\OCP\ICache')
|
||||||
|
->getMock();
|
||||||
/** @var ICacheFactory $cacheFactory */
|
/** @var ICacheFactory $cacheFactory */
|
||||||
$cacheFactory = $this->getMockBuilder('\OCP\ICacheFactory')
|
$cacheFactory = $this->getMockBuilder('\OCP\ICacheFactory')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
|
@ -67,7 +68,8 @@ class DiscoveryManagerTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithMalformedFormattedEndpointCached() {
|
public function testWithMalformedFormattedEndpointCached() {
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->getMockBuilder('\OCP\Http\Client\IResponse')
|
||||||
|
->getMock();
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getStatusCode')
|
->method('getStatusCode')
|
||||||
|
@ -104,7 +106,8 @@ class DiscoveryManagerTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetWebDavEndpointWithValidFormattedEndpointAndNotCached() {
|
public function testGetWebDavEndpointWithValidFormattedEndpointAndNotCached() {
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->getMockBuilder('\OCP\Http\Client\IResponse')
|
||||||
|
->getMock();
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getStatusCode')
|
->method('getStatusCode')
|
||||||
|
@ -127,7 +130,8 @@ class DiscoveryManagerTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetWebDavEndpointWithValidFormattedEndpointWithoutDataAndNotCached() {
|
public function testGetWebDavEndpointWithValidFormattedEndpointWithoutDataAndNotCached() {
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->getMockBuilder('\OCP\Http\Client\IResponse')
|
||||||
|
->getMock();
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getStatusCode')
|
->method('getStatusCode')
|
||||||
|
@ -150,7 +154,8 @@ class DiscoveryManagerTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetShareEndpointWithValidFormattedEndpointAndNotCached() {
|
public function testGetShareEndpointWithValidFormattedEndpointAndNotCached() {
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->getMockBuilder('\OCP\Http\Client\IResponse')
|
||||||
|
->getMock();
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getStatusCode')
|
->method('getStatusCode')
|
||||||
|
@ -173,7 +178,8 @@ class DiscoveryManagerTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithMaliciousEndpointCached() {
|
public function testWithMaliciousEndpointCached() {
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->getMockBuilder('\OCP\Http\Client\IResponse')
|
||||||
|
->getMock();
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getStatusCode')
|
->method('getStatusCode')
|
||||||
|
|
|
@ -80,15 +80,15 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
$this->tokenHandler = $this->getMockBuilder('OCA\FederatedFileSharing\TokenHandler')
|
$this->tokenHandler = $this->getMockBuilder('OCA\FederatedFileSharing\TokenHandler')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$this->l = $this->getMock('OCP\IL10N');
|
$this->l = $this->getMockBuilder('OCP\IL10N')->getMock();
|
||||||
$this->l->method('t')
|
$this->l->method('t')
|
||||||
->will($this->returnCallback(function($text, $parameters = []) {
|
->will($this->returnCallback(function($text, $parameters = []) {
|
||||||
return vsprintf($text, $parameters);
|
return vsprintf($text, $parameters);
|
||||||
}));
|
}));
|
||||||
$this->logger = $this->getMock('OCP\ILogger');
|
$this->logger = $this->getMockBuilder('OCP\ILogger')->getMock();
|
||||||
$this->rootFolder = $this->getMock('OCP\Files\IRootFolder');
|
$this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock();
|
||||||
$this->config = $this->getMock('OCP\IConfig');
|
$this->config = $this->getMockBuilder('OCP\IConfig')->getMock();
|
||||||
$this->userManager = $this->getMock('OCP\IUserManager');
|
$this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock();
|
||||||
//$this->addressHandler = new AddressHandler(\OC::$server->getURLGenerator(), $this->l);
|
//$this->addressHandler = new AddressHandler(\OC::$server->getURLGenerator(), $this->l);
|
||||||
$this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler')->disableOriginalConstructor()->getMock();
|
$this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler')->disableOriginalConstructor()->getMock();
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
public function testCreate() {
|
public function testCreate() {
|
||||||
$share = $this->shareManager->newShare();
|
$share = $this->shareManager->newShare();
|
||||||
|
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->method('getId')->willReturn(42);
|
$node->method('getId')->willReturn(42);
|
||||||
$node->method('getName')->willReturn('myFile');
|
$node->method('getName')->willReturn('myFile');
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
public function testCreateCouldNotFindServer() {
|
public function testCreateCouldNotFindServer() {
|
||||||
$share = $this->shareManager->newShare();
|
$share = $this->shareManager->newShare();
|
||||||
|
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->method('getId')->willReturn(42);
|
$node->method('getId')->willReturn(42);
|
||||||
$node->method('getName')->willReturn('myFile');
|
$node->method('getName')->willReturn('myFile');
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
public function testCreateException() {
|
public function testCreateException() {
|
||||||
$share = $this->shareManager->newShare();
|
$share = $this->shareManager->newShare();
|
||||||
|
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->method('getId')->willReturn(42);
|
$node->method('getId')->willReturn(42);
|
||||||
$node->method('getName')->willReturn('myFile');
|
$node->method('getName')->willReturn('myFile');
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
public function testCreateShareWithSelf() {
|
public function testCreateShareWithSelf() {
|
||||||
$share = $this->shareManager->newShare();
|
$share = $this->shareManager->newShare();
|
||||||
|
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->method('getId')->willReturn(42);
|
$node->method('getId')->willReturn(42);
|
||||||
$node->method('getName')->willReturn('myFile');
|
$node->method('getName')->willReturn('myFile');
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
public function testCreateAlreadyShared() {
|
public function testCreateAlreadyShared() {
|
||||||
$share = $this->shareManager->newShare();
|
$share = $this->shareManager->newShare();
|
||||||
|
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->method('getId')->willReturn(42);
|
$node->method('getId')->willReturn(42);
|
||||||
$node->method('getName')->willReturn('myFile');
|
$node->method('getName')->willReturn('myFile');
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
|
|
||||||
$share = $this->shareManager->newShare();
|
$share = $this->shareManager->newShare();
|
||||||
|
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->method('getId')->willReturn(42);
|
$node->method('getId')->willReturn(42);
|
||||||
$node->method('getName')->willReturn('myFile');
|
$node->method('getName')->willReturn('myFile');
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSharedBy() {
|
public function testGetSharedBy() {
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->method('getId')->willReturn(42);
|
$node->method('getId')->willReturn(42);
|
||||||
$node->method('getName')->willReturn('myFile');
|
$node->method('getName')->willReturn('myFile');
|
||||||
|
|
||||||
|
@ -504,7 +504,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSharedByWithNode() {
|
public function testGetSharedByWithNode() {
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->method('getId')->willReturn(42);
|
$node->method('getId')->willReturn(42);
|
||||||
$node->method('getName')->willReturn('myFile');
|
$node->method('getName')->willReturn('myFile');
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
->setNode($node);
|
->setNode($node);
|
||||||
$this->provider->create($share);
|
$this->provider->create($share);
|
||||||
|
|
||||||
$node2 = $this->getMock('\OCP\Files\File');
|
$node2 = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node2->method('getId')->willReturn(43);
|
$node2->method('getId')->willReturn(43);
|
||||||
$node2->method('getName')->willReturn('myOtherFile');
|
$node2->method('getName')->willReturn('myOtherFile');
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSharedByWithReshares() {
|
public function testGetSharedByWithReshares() {
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->method('getId')->willReturn(42);
|
$node->method('getId')->willReturn(42);
|
||||||
$node->method('getName')->willReturn('myFile');
|
$node->method('getName')->willReturn('myFile');
|
||||||
|
|
||||||
|
@ -575,7 +575,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSharedByWithLimit() {
|
public function testGetSharedByWithLimit() {
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->method('getId')->willReturn(42);
|
$node->method('getId')->willReturn(42);
|
||||||
$node->method('getName')->willReturn('myFile');
|
$node->method('getName')->willReturn('myFile');
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,10 @@ class NotificationsTest extends \Test\TestCase {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->jobList = $this->getMock('OCP\BackgroundJob\IJobList');
|
$this->jobList = $this->getMockBuilder('OCP\BackgroundJob\IJobList')->getMock();
|
||||||
$this->discoveryManager = $this->getMockBuilder('OCA\FederatedFileSharing\DiscoveryManager')
|
$this->discoveryManager = $this->getMockBuilder('OCA\FederatedFileSharing\DiscoveryManager')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$this->httpClientService = $this->getMock('OCP\Http\Client\IClientService');
|
$this->httpClientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->getMock();
|
||||||
$this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler')
|
$this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TokenHandlerTest extends \Test\TestCase {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->secureRandom = $this->getMock('OCP\Security\ISecureRandom');
|
$this->secureRandom = $this->getMockBuilder('OCP\Security\ISecureRandom')->getMock();
|
||||||
|
|
||||||
$this->tokenHandler = new TokenHandler($this->secureRandom);
|
$this->tokenHandler = new TokenHandler($this->secureRandom);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue