Fix system tags DAV plugin tests
This commit is contained in:
parent
10fae3994a
commit
91d4249ed8
|
@ -27,6 +27,7 @@ use OC\SystemTag\SystemTag;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\SystemTag\TagAlreadyExistsException;
|
use OCP\SystemTag\TagAlreadyExistsException;
|
||||||
|
use OCP\IUser;
|
||||||
|
|
||||||
class SystemTagPlugin extends \Test\TestCase {
|
class SystemTagPlugin extends \Test\TestCase {
|
||||||
|
|
||||||
|
@ -60,6 +61,11 @@ class SystemTagPlugin extends \Test\TestCase {
|
||||||
*/
|
*/
|
||||||
private $userSession;
|
private $userSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var IUser
|
||||||
|
*/
|
||||||
|
private $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \OCA\DAV\SystemTag\SystemTagPlugin
|
* @var \OCA\DAV\SystemTag\SystemTagPlugin
|
||||||
*/
|
*/
|
||||||
|
@ -75,7 +81,16 @@ class SystemTagPlugin extends \Test\TestCase {
|
||||||
|
|
||||||
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
|
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
|
||||||
$this->groupManager = $this->getMock('\OCP\IGroupManager');
|
$this->groupManager = $this->getMock('\OCP\IGroupManager');
|
||||||
|
$this->user = $this->getMock('\OCP\IUser');
|
||||||
$this->userSession = $this->getMock('\OCP\IUserSession');
|
$this->userSession = $this->getMock('\OCP\IUserSession');
|
||||||
|
$this->userSession
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getUser')
|
||||||
|
->willReturn($this->user);
|
||||||
|
$this->userSession
|
||||||
|
->expects($this->any())
|
||||||
|
->method('isLoggedIn')
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
$this->plugin = new \OCA\DAV\SystemTag\SystemTagPlugin(
|
$this->plugin = new \OCA\DAV\SystemTag\SystemTagPlugin(
|
||||||
$this->tagManager,
|
$this->tagManager,
|
||||||
|
@ -178,18 +193,9 @@ class SystemTagPlugin extends \Test\TestCase {
|
||||||
* @expectedExceptionMessage Not sufficient permissions
|
* @expectedExceptionMessage Not sufficient permissions
|
||||||
*/
|
*/
|
||||||
public function testCreateNotAssignableTagAsRegularUser() {
|
public function testCreateNotAssignableTagAsRegularUser() {
|
||||||
$user = $this->getMock('\OCP\IUser');
|
$this->user->expects($this->once())
|
||||||
$user->expects($this->once())
|
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->willReturn('admin');
|
->willReturn('admin');
|
||||||
$this->userSession
|
|
||||||
->expects($this->once())
|
|
||||||
->method('isLoggedIn')
|
|
||||||
->willReturn(true);
|
|
||||||
$this->userSession
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getUser')
|
|
||||||
->willReturn($user);
|
|
||||||
$this->groupManager
|
$this->groupManager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('isAdmin')
|
->method('isAdmin')
|
||||||
|
@ -241,18 +247,9 @@ class SystemTagPlugin extends \Test\TestCase {
|
||||||
* @expectedExceptionMessage Not sufficient permissions
|
* @expectedExceptionMessage Not sufficient permissions
|
||||||
*/
|
*/
|
||||||
public function testCreateInvisibleTagAsRegularUser() {
|
public function testCreateInvisibleTagAsRegularUser() {
|
||||||
$user = $this->getMock('\OCP\IUser');
|
$this->user->expects($this->once())
|
||||||
$user->expects($this->once())
|
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->willReturn('admin');
|
->willReturn('admin');
|
||||||
$this->userSession
|
|
||||||
->expects($this->once())
|
|
||||||
->method('isLoggedIn')
|
|
||||||
->willReturn(true);
|
|
||||||
$this->userSession
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getUser')
|
|
||||||
->willReturn($user);
|
|
||||||
$this->groupManager
|
$this->groupManager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('isAdmin')
|
->method('isAdmin')
|
||||||
|
@ -353,18 +350,9 @@ class SystemTagPlugin extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateTagInByIdCollection() {
|
public function testCreateTagInByIdCollection() {
|
||||||
$user = $this->getMock('\OCP\IUser');
|
$this->user->expects($this->once())
|
||||||
$user->expects($this->once())
|
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->willReturn('admin');
|
->willReturn('admin');
|
||||||
$this->userSession
|
|
||||||
->expects($this->once())
|
|
||||||
->method('isLoggedIn')
|
|
||||||
->willReturn(true);
|
|
||||||
$this->userSession
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getUser')
|
|
||||||
->willReturn($user);
|
|
||||||
$this->groupManager
|
$this->groupManager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('isAdmin')
|
->method('isAdmin')
|
||||||
|
@ -431,18 +419,9 @@ class SystemTagPlugin extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateTagInMappingCollection() {
|
public function testCreateTagInMappingCollection() {
|
||||||
$user = $this->getMock('\OCP\IUser');
|
$this->user->expects($this->once())
|
||||||
$user->expects($this->once())
|
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->willReturn('admin');
|
->willReturn('admin');
|
||||||
$this->userSession
|
|
||||||
->expects($this->once())
|
|
||||||
->method('isLoggedIn')
|
|
||||||
->willReturn(true);
|
|
||||||
$this->userSession
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getUser')
|
|
||||||
->willReturn($user);
|
|
||||||
$this->groupManager
|
$this->groupManager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('isAdmin')
|
->method('isAdmin')
|
||||||
|
@ -545,18 +524,9 @@ class SystemTagPlugin extends \Test\TestCase {
|
||||||
* @expectedException \Sabre\DAV\Exception\Conflict
|
* @expectedException \Sabre\DAV\Exception\Conflict
|
||||||
*/
|
*/
|
||||||
public function testCreateTagConflict($nodeClass) {
|
public function testCreateTagConflict($nodeClass) {
|
||||||
$user = $this->getMock('\OCP\IUser');
|
$this->user->expects($this->once())
|
||||||
$user->expects($this->once())
|
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->willReturn('admin');
|
->willReturn('admin');
|
||||||
$this->userSession
|
|
||||||
->expects($this->once())
|
|
||||||
->method('isLoggedIn')
|
|
||||||
->willReturn(true);
|
|
||||||
$this->userSession
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getUser')
|
|
||||||
->willReturn($user);
|
|
||||||
$this->groupManager
|
$this->groupManager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('isAdmin')
|
->method('isAdmin')
|
||||||
|
|
Loading…
Reference in New Issue