Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix getMock OCSClient
  • Loading branch information
rullzer committed Sep 7, 2016
commit b8b9fc2b1cc507ea491eb439a5088884cf1279b8
54 changes: 28 additions & 26 deletions tests/lib/OCSClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
namespace Test;

use OC\OCSClient;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\IConfig;
use OCP\ILogger;

Expand All @@ -44,8 +46,8 @@ public function setUp() {

$this->config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock();
$this->clientService = $this->getMock('\OCP\Http\Client\IClientService');
$this->logger = $this->getMock('\OCP\ILogger');
$this->clientService = $this->createMock(IClientService::class);
$this->logger = $this->createMock(ILogger::class);

$this->ocsClient = new OCSClient(
$this->clientService,
Expand Down Expand Up @@ -102,7 +104,7 @@ public function testGetCategoriesExceptionClient() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -145,13 +147,13 @@ public function testGetCategoriesParseError() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock(IResponse::class);
$response
->expects($this->once())
->method('getBody')
->will($this->returnValue('MyInvalidXml'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -194,7 +196,7 @@ public function testGetCategoriesSuccessful() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock(IResponse::class);
$response
->expects($this->once())
->method('getBody')
Expand Down Expand Up @@ -235,7 +237,7 @@ public function testGetCategoriesSuccessful() {
</ocs>
'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -285,7 +287,7 @@ public function testGetApplicationsExceptionClient() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -336,13 +338,13 @@ public function testGetApplicationsParseError() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock(IResponse::class);
$response
->expects($this->once())
->method('getBody')
->will($this->returnValue('MyInvalidXml'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -393,7 +395,7 @@ public function testGetApplicationsSuccessful() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock(IResponse::class);
$response
->expects($this->once())
->method('getBody')
Expand Down Expand Up @@ -478,7 +480,7 @@ public function testGetApplicationsSuccessful() {
</data>
</ocs> '));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -568,7 +570,7 @@ public function testGetApplicationExceptionClient() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -611,13 +613,13 @@ public function testGetApplicationParseError() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock(IResponse::class);
$response
->expects($this->once())
->method('getBody')
->will($this->returnValue('MyInvalidXml'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -660,7 +662,7 @@ public function testGetApplicationSuccessful() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock(IResponse::class);
$response
->expects($this->once())
->method('getBody')
Expand Down Expand Up @@ -745,7 +747,7 @@ public function testGetApplicationSuccessful() {
</ocs>
'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -796,7 +798,7 @@ public function testGetApplicationSuccessfulWithOldId() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock(IResponse::class);
$response
->expects($this->once())
->method('getBody')
Expand Down Expand Up @@ -881,7 +883,7 @@ public function testGetApplicationSuccessfulWithOldId() {
</ocs>
'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -932,7 +934,7 @@ public function testGetApplicationEmptyXml() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock(IResponse::class);
$response
->expects($this->once())
->method('getBody')
Expand All @@ -946,7 +948,7 @@ public function testGetApplicationEmptyXml() {
</ocs>
'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -988,7 +990,7 @@ public function testGetApplicationDownloadExceptionClient() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -1031,13 +1033,13 @@ public function testGetApplicationDownloadParseError() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock(IResponse::class);
$response
->expects($this->once())
->method('getBody')
->will($this->returnValue('MyInvalidXml'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down Expand Up @@ -1080,7 +1082,7 @@ public function testGetApplicationDownloadUrlSuccessful() {
->with('appstoreurl', 'https://api.owncloud.com/v1')
->will($this->returnValue('https://api.owncloud.com/v1'));

$response = $this->getMock('\OCP\Http\Client\IResponse');
$response = $this->createMock(IResponse::class);
$response
->expects($this->once())
->method('getBody')
Expand All @@ -1104,7 +1106,7 @@ public function testGetApplicationDownloadUrlSuccessful() {
</ocs>
'));

$client = $this->getMock('\OCP\Http\Client\IClient');
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
Expand Down