Skip to content
Snippets Groups Projects
Unverified Commit 56d37e27 authored by Roeland Jago Douma's avatar Roeland Jago Douma Committed by Morris Jobke
Browse files

Fix tests

parent fb52b1af
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,8 @@
namespace OCA\Files_Sharing\Tests\API;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\Files\Folder;
use OCP\IL10N;
use OCA\Files_Sharing\API\Share20OCS;
use OCP\Files\NotFoundException;
......@@ -108,8 +110,11 @@ class Share20OCSTest extends \Test\TestCase {
);
}
/**
* @return Share20OCS|\PHPUnit_Framework_MockObject_MockObject
*/
private function mockFormatShare() {
return $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS')
return $this->getMockBuilder(Share20OCS::class)
->setConstructorArgs([
$this->appName,
$this->request,
......@@ -1572,9 +1577,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateShareCannotIncreasePermissions() {
$ocs = $this->mockFormatShare();
$date = new \DateTime('2000-01-01');
$folder = $this->getMock('\OCP\Files\Folder');
$folder = $this->createMock(Folder::class);
$share = \OC::$server->getShareManager()->newShare();
$share
......@@ -1615,19 +1618,18 @@ class Share20OCSTest extends \Test\TestCase {
$this->shareManager->expects($this->never())->method('updateShare');
$expected = new \OC_OCS_Result(null, 404, 'Cannot increase permissions');
$result = $ocs->updateShare(42);
$this->assertEquals($expected->getMeta(), $result->getMeta());
$this->assertEquals($expected->getData(), $result->getData());
try {
$ocs->updateShare(42, 31);
$this->fail();
} catch (OCSNotFoundException $e) {
$this->assertEquals('Cannot increase permissions', $e->getMessage());
}
}
public function testUpdateShareCanIncreasePermissionsIfOwner() {
$ocs = $this->mockFormatShare();
$date = new \DateTime('2000-01-01');
$folder = $this->getMock('\OCP\Files\Folder');
$folder = $this->createMock(Folder::class);
$share = \OC::$server->getShareManager()->newShare();
$share
......@@ -1651,12 +1653,6 @@ class Share20OCSTest extends \Test\TestCase {
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($folder);
$this->request
->method('getParam')
->will($this->returnValueMap([
['permissions', null, '31'],
]));
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->shareManager->expects($this->any(0))
......@@ -1671,12 +1667,10 @@ class Share20OCSTest extends \Test\TestCase {
->with($share)
->willReturn($share);
$expected = new \OC_OCS_Result();
$result = $ocs->updateShare(42);
$this->assertEquals($expected->getMeta(), $result->getMeta());
$this->assertEquals($expected->getData(), $result->getData());
$result = $ocs->updateShare(42, 31);
$this->assertInstanceOf(DataResponse::class, $result);
}
public function dataFormatShare() {
$file = $this->getMockBuilder('\OCP\Files\File')->getMock();
$folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment