public function testAddGroupWithSpecialChar() { $this->request->method('getParam')->with('groupid')->willReturn('Iñtërnâtiônàlizætiøn'); $this->groupManager->method('groupExists')->with('Iñtërnâtiônàlizætiøn')->willReturn(false); $this->groupManager->expects($this->once())->method('createGroup')->with('Iñtërnâtiônàlizætiøn'); $result = $this->api->addGroup([]); $this->assertInstanceOf('OC_OCS_Result', $result); $this->assertTrue($result->succeeded()); }
public function testCreateShareGroup() { $share = $this->getMock('\\OC\\Share20\\IShare'); $this->shareManager->method('newShare')->willReturn($share); $ocs = $this->getMockBuilder('OCA\\Files_Sharing\\API\\Share20OCS')->setConstructorArgs([$this->shareManager, $this->groupManager, $this->userManager, $this->request, $this->rootFolder, $this->urlGenerator, $this->currentUser])->setMethods(['formatShare'])->getMock(); $this->request->method('getParam')->will($this->returnValueMap([['path', null, 'valid-path'], ['permissions', null, \OCP\Constants::PERMISSION_ALL], ['shareType', '-1', \OCP\Share::SHARE_TYPE_GROUP], ['shareWith', null, 'validGroup']])); $userFolder = $this->getMock('\\OCP\\Files\\Folder'); $this->rootFolder->expects($this->once())->method('getUserFolder')->with('currentUser')->willReturn($userFolder); $path = $this->getMock('\\OCP\\Files\\Folder'); $userFolder->expects($this->once())->method('get')->with('valid-path')->willReturn($path); $group = $this->getMock('\\OCP\\IGroup'); $this->groupManager->method('groupExists')->with('validGroup')->willReturn(true); $this->groupManager->method('get')->with('validGroup')->willReturn($group); $share->method('setPath')->with($path); $share->method('setPermissions')->with(\OCP\Constants::PERMISSION_ALL); $share->method('setShareType')->with(\OCP\Share::SHARE_TYPE_GROUP); $share->method('setSharedWith')->with($group); $share->method('setSharedBy')->with($this->currentUser); $expected = new \OC_OCS_Result(); $result = $ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); $this->assertEquals($expected->getData(), $result->getData()); }