Skip to content

Commit

Permalink
Fix usage of deprecated getMock
Browse files Browse the repository at this point in the history
This is deprecated in phpunit >= 5.4
This generates a whole lot of output. Which causes drone to kill the
tests
  • Loading branch information
rullzer committed Jul 8, 2016
1 parent e385d2b commit 4e55e3a
Show file tree
Hide file tree
Showing 88 changed files with 883 additions and 856 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BlockLegacyClientPluginTest extends TestCase {
public function setUp() {
parent::setUp();

$this->config = $this->getMock('\OCP\IConfig');
$this->config = $this->createMock('\OCP\IConfig');
$this->blockLegacyClientVersionPlugin = new BlockLegacyClientPlugin($this->config);
}

Expand All @@ -66,7 +66,7 @@ public function oldDesktopClientProvider() {
*/
public function testBeforeHandlerException($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMock('\Sabre\HTTP\RequestInterface');
$request = $this->createMock('\Sabre\HTTP\RequestInterface');
$request
->expects($this->once())
->method('getHeader')
Expand Down Expand Up @@ -101,7 +101,7 @@ public function newAndAlternateDesktopClientProvider() {
*/
public function testBeforeHandlerSuccess($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMock('\Sabre\HTTP\RequestInterface');
$request = $this->createMock('\Sabre\HTTP\RequestInterface');
$request
->expects($this->once())
->method('getHeader')
Expand All @@ -119,7 +119,7 @@ public function testBeforeHandlerSuccess($userAgent) {

public function testBeforeHandlerNoUserAgent() {
/** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMock('\Sabre\HTTP\RequestInterface');
$request = $this->createMock('\Sabre\HTTP\RequestInterface');
$request
->expects($this->once())
->method('getHeader')
Expand Down
6 changes: 3 additions & 3 deletions apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ public function setUp() {
$this->view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor()
->getMock();
$this->config = $this->getMock('\OCP\IConfig');
$this->config = $this->createMock('\OCP\IConfig');
$this->config->expects($this->any())->method('getSystemValue')
->with($this->equalTo('data-fingerprint'), $this->equalTo(''))
->willReturn('my_fingerprint');
$this->request = $this->getMock('\OCP\IRequest');
$this->request = $this->createMock('\OCP\IRequest');

$this->plugin = new FilesPlugin(
$this->tree,
Expand Down Expand Up @@ -275,7 +275,7 @@ public function testGetPublicPermissions() {
$this->tree,
$this->view,
$this->config,
$this->getMock('\OCP\IRequest'),
$this->createMock('\OCP\IRequest'),
true);
$this->plugin->initialize($this->server);

Expand Down
28 changes: 14 additions & 14 deletions apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ public function setUp() {
->disableOriginalConstructor()
->getMock();

$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
$this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->tagManager = $this->createMock('\OCP\SystemTag\ISystemTagManager');
$this->tagMapper = $this->createMock('\OCP\SystemTag\ISystemTagObjectMapper');
$this->userSession = $this->createMock('\OCP\IUserSession');

$user = $this->getMock('\OCP\IUser');
$user = $this->createMock('\OCP\IUser');
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('testuser'));
Expand Down Expand Up @@ -114,7 +114,7 @@ public function testOnReportInvalidNode() {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
->will($this->returnValue($this->createMock('\Sabre\DAV\INode')));

$this->server->expects($this->any())
->method('getRequestUri')
Expand All @@ -133,7 +133,7 @@ public function testOnReportInvalidReportName() {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
->will($this->returnValue($this->createMock('\Sabre\DAV\INode')));

$this->server->expects($this->any())
->method('getRequestUri')
Expand Down Expand Up @@ -337,14 +337,14 @@ public function testPrepareResponses() {
->method('getSize')
->will($this->returnValue(1024));

$config = $this->getMock('\OCP\IConfig');
$config = $this->createMock('\OCP\IConfig');

$this->server->addPlugin(
new \OCA\DAV\Connector\Sabre\FilesPlugin(
$this->tree,
$this->view,
$config,
$this->getMock('\OCP\IRequest')
$this->createMock('\OCP\IRequest')
)
);
$this->plugin->initialize($this->server);
Expand Down Expand Up @@ -494,15 +494,15 @@ public function testProcessFilterRulesInvisibleTagAsAdmin() {
->method('isAdmin')
->will($this->returnValue(true));

$tag1 = $this->getMock('\OCP\SystemTag\ISystemTag');
$tag1 = $this->createMock('\OCP\SystemTag\ISystemTag');
$tag1->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
$tag1->expects($this->any())
->method('isUserVisible')
->will($this->returnValue(true));

$tag2 = $this->getMock('\OCP\SystemTag\ISystemTag');
$tag2 = $this->createMock('\OCP\SystemTag\ISystemTag');
$tag2->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
Expand Down Expand Up @@ -539,15 +539,15 @@ public function testProcessFilterRulesInvisibleTagAsUser() {
->method('isAdmin')
->will($this->returnValue(false));

$tag1 = $this->getMock('\OCP\SystemTag\ISystemTag');
$tag1 = $this->createMock('\OCP\SystemTag\ISystemTag');
$tag1->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
$tag1->expects($this->any())
->method('isUserVisible')
->will($this->returnValue(true));

$tag2 = $this->getMock('\OCP\SystemTag\ISystemTag');
$tag2 = $this->createMock('\OCP\SystemTag\ISystemTag');
$tag2->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
Expand All @@ -573,15 +573,15 @@ public function testProcessFilterRulesVisibleTagAsUser() {
->method('isAdmin')
->will($this->returnValue(false));

$tag1 = $this->getMock('\OCP\SystemTag\ISystemTag');
$tag1 = $this->createMock('\OCP\SystemTag\ISystemTag');
$tag1->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
$tag1->expects($this->any())
->method('isUserVisible')
->will($this->returnValue(true));

$tag2 = $this->getMock('\OCP\SystemTag\ISystemTag');
$tag2 = $this->createMock('\OCP\SystemTag\ISystemTag');
$tag2->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
Expand Down
16 changes: 8 additions & 8 deletions apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ public function setUp() {
$this->tree = $this->getMockBuilder('\Sabre\DAV\Tree')
->disableOriginalConstructor()
->getMock();
$this->shareManager = $this->getMock('\OCP\Share\IManager');
$user = $this->getMock('\OCP\IUser');
$this->shareManager = $this->createMock('\OCP\Share\IManager');
$user = $this->createMock('\OCP\IUser');
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('user1'));
$userSession = $this->getMock('\OCP\IUserSession');
$userSession = $this->createMock('\OCP\IUserSession');
$userSession->expects($this->once())
->method('getUser')
->will($this->returnValue($user));

$this->userFolder = $this->getMock('\OCP\Files\Folder');
$this->userFolder = $this->createMock('\OCP\Files\Folder');

$this->plugin = new \OCA\DAV\Connector\Sabre\SharesPlugin(
$this->tree,
Expand All @@ -92,7 +92,7 @@ public function testGetProperties($shareTypes) {
->will($this->returnValue('/subdir'));

// node API nodes
$node = $this->getMock('\OCP\Files\Folder');
$node = $this->createMock('\OCP\Files\Folder');

$this->userFolder->expects($this->once())
->method('get')
Expand Down Expand Up @@ -168,15 +168,15 @@ public function testPreloadThenGetProperties($shareTypes) {
->will($this->returnValue('/subdir'));

// node API nodes
$node = $this->getMock('\OCP\Files\Folder');
$node = $this->createMock('\OCP\Files\Folder');
$node->expects($this->any())
->method('getId')
->will($this->returnValue(123));
$node1 = $this->getMock('\OCP\Files\File');
$node1 = $this->createMock('\OCP\Files\File');
$node1->expects($this->any())
->method('getId')
->will($this->returnValue(111));
$node2 = $this->getMock('\OCP\Files\File');
$node2 = $this->createMock('\OCP\Files\File');
$node2->expects($this->any())
->method('getId')
->will($this->returnValue(222));
Expand Down
10 changes: 5 additions & 5 deletions apps/encryption/tests/RecoveryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ protected function setUp() {

$this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')->disableOriginalConstructor()->getMock();
/** @var \OCP\Security\ISecureRandom $randomMock */
$randomMock = $this->getMock('OCP\Security\ISecureRandom');
$randomMock = $this->createMock('OCP\Security\ISecureRandom');
$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')->disableOriginalConstructor()->getMock();
$this->configMock = $this->getMock('OCP\IConfig');
$this->configMock = $this->createMock('OCP\IConfig');
/** @var \OCP\Encryption\Keys\IStorage $keyStorageMock */
$keyStorageMock = $this->getMock('OCP\Encryption\Keys\IStorage');
$this->fileMock = $this->getMock('OCP\Encryption\IFile');
$this->viewMock = $this->getMock('OC\Files\View');
$keyStorageMock = $this->createMock('OCP\Encryption\Keys\IStorage');
$this->fileMock = $this->createMock('OCP\Encryption\IFile');
$this->viewMock = $this->createMock('OC\Files\View');

$this->configMock->expects($this->any())
->method('setAppValue')
Expand Down
4 changes: 2 additions & 2 deletions apps/federatedfilesharing/tests/AddressHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class AddressHandlerTest extends \Test\TestCase {
public function setUp() {
parent::setUp();

$this->urlGenerator = $this->getMock('OCP\IURLGenerator');
$this->il10n = $this->getMock('OCP\IL10N');
$this->urlGenerator = $this->createMock('OCP\IURLGenerator');
$this->il10n = $this->createMock('OCP\IL10N');

$this->addressHandler = new AddressHandler($this->urlGenerator, $this->il10n);
}
Expand Down
12 changes: 6 additions & 6 deletions apps/federatedfilesharing/tests/DiscoveryManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DiscoveryManagerTest extends \Test\TestCase {

public function setUp() {
parent::setUp();
$this->cache = $this->getMock('\OCP\ICache');
$this->cache = $this->createMock('\OCP\ICache');
/** @var ICacheFactory $cacheFactory */
$cacheFactory = $this->getMockBuilder('\OCP\ICacheFactory')
->disableOriginalConstructor()->getMock();
Expand All @@ -65,7 +65,7 @@ public function setUp() {
}

public function testWithMalformedFormattedEndpointCached() {
$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock('\OCP\Http\Client\IResponse');
$response
->expects($this->once())
->method('getStatusCode')
Expand Down Expand Up @@ -102,7 +102,7 @@ public function testWithMalformedFormattedEndpointCached() {
}

public function testGetWebDavEndpointWithValidFormattedEndpointAndNotCached() {
$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock('\OCP\Http\Client\IResponse');
$response
->expects($this->once())
->method('getStatusCode')
Expand All @@ -125,7 +125,7 @@ public function testGetWebDavEndpointWithValidFormattedEndpointAndNotCached() {
}

public function testGetWebDavEndpointWithValidFormattedEndpointWithoutDataAndNotCached() {
$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock('\OCP\Http\Client\IResponse');
$response
->expects($this->once())
->method('getStatusCode')
Expand All @@ -148,7 +148,7 @@ public function testGetWebDavEndpointWithValidFormattedEndpointWithoutDataAndNot
}

public function testGetShareEndpointWithValidFormattedEndpointAndNotCached() {
$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock('\OCP\Http\Client\IResponse');
$response
->expects($this->once())
->method('getStatusCode')
Expand All @@ -171,7 +171,7 @@ public function testGetShareEndpointWithValidFormattedEndpointAndNotCached() {
}

public function testWithMaliciousEndpointCached() {
$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock('\OCP\Http\Client\IResponse');
$response
->expects($this->once())
->method('getStatusCode')
Expand Down
Loading

0 comments on commit 4e55e3a

Please sign in to comment.