summaryrefslogtreecommitdiffstats
path: root/tests/lib/Group/GroupTest.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2019-02-22 13:07:26 +0100
committerJulius Härtl <jus@bitgrid.net>2019-03-01 20:56:59 +0100
commit01b4db62fbc4230cff953a2385d305b149744b86 (patch)
tree788b5edf5acba069bd6996466ab9b1b30a6804d4 /tests/lib/Group/GroupTest.php
parent55ae7fa2a48ce38e2807a40632f282740c0e8117 (diff)
downloadnextcloud-server-01b4db62fbc4230cff953a2385d305b149744b86.tar.gz
nextcloud-server-01b4db62fbc4230cff953a2385d305b149744b86.zip
Add dispatcher events to User and Group objects
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/Group/GroupTest.php')
-rw-r--r--tests/lib/Group/GroupTest.php58
1 files changed, 34 insertions, 24 deletions
diff --git a/tests/lib/Group/GroupTest.php b/tests/lib/Group/GroupTest.php
index a0b77bbe4d7..5ab7a645081 100644
--- a/tests/lib/Group/GroupTest.php
+++ b/tests/lib/Group/GroupTest.php
@@ -12,8 +12,19 @@ namespace Test\Group;
use OC\User\User;
use OCP\IConfig;
use OCP\IURLGenerator;
+use OCP\IUser;
+use PHPUnit\Framework\MockObject\MockObject;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class GroupTest extends \Test\TestCase {
+
+ /** @var EventDispatcherInterface|MockObject */
+ protected $dispatcher;
+
+ public function setUp() {
+ parent::setUp();
+ $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
+ }
/**
* @param string $uid
@@ -21,14 +32,13 @@ class GroupTest extends \Test\TestCase {
* @return User
*/
private function newUser($uid, \OC\User\Backend $backend) {
- $config = $this->getMockBuilder(IConfig::class)
- ->disableOriginalConstructor()
- ->getMock();
- $urlgenerator = $this->getMockBuilder(IURLGenerator::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')
+ ->willReturn($uid);
+ $user->method('getBackend')
+ ->willReturn($backend);
- return new User($uid, $backend, null, $config, $urlgenerator);
+ return $user;
}
/**
@@ -59,7 +69,7 @@ class GroupTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$userManager = $this->getUserManager();
- $group = new \OC\Group\Group('group1', array($backend), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager);
$backend->expects($this->once())
->method('usersInGroup')
@@ -83,7 +93,7 @@ class GroupTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$userManager = $this->getUserManager();
- $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager);
$backend1->expects($this->once())
->method('usersInGroup')
@@ -114,7 +124,7 @@ class GroupTest extends \Test\TestCase {
$userBackend = $this->getMockBuilder('\OC\User\Backend')
->disableOriginalConstructor()
->getMock();
- $group = new \OC\Group\Group('group1', array($backend), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager);
$backend->expects($this->once())
->method('inGroup')
@@ -135,7 +145,7 @@ class GroupTest extends \Test\TestCase {
$userBackend = $this->getMockBuilder(\OC\User\Backend::class)
->disableOriginalConstructor()
->getMock();
- $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager);
$backend1->expects($this->once())
->method('inGroup')
@@ -158,7 +168,7 @@ class GroupTest extends \Test\TestCase {
$userBackend = $this->getMockBuilder('\OC\User\Backend')
->disableOriginalConstructor()
->getMock();
- $group = new \OC\Group\Group('group1', array($backend), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager);
$backend->expects($this->once())
->method('inGroup')
@@ -183,7 +193,7 @@ class GroupTest extends \Test\TestCase {
$userBackend = $this->getMockBuilder('\OC\User\Backend')
->disableOriginalConstructor()
->getMock();
- $group = new \OC\Group\Group('group1', array($backend), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager);
$backend->expects($this->once())
->method('inGroup')
@@ -207,7 +217,7 @@ class GroupTest extends \Test\TestCase {
$userBackend = $this->getMockBuilder('\OC\User\Backend')
->disableOriginalConstructor()
->getMock();
- $group = new \OC\Group\Group('group1', array($backend), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager);
$backend->expects($this->once())
->method('inGroup')
@@ -232,7 +242,7 @@ class GroupTest extends \Test\TestCase {
$userBackend = $this->getMockBuilder(\OC\User\Backend::class)
->disableOriginalConstructor()
->getMock();
- $group = new \OC\Group\Group('group1', array($backend), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager);
$backend->expects($this->once())
->method('inGroup')
@@ -259,7 +269,7 @@ class GroupTest extends \Test\TestCase {
$userBackend = $this->getMockBuilder('\OC\User\Backend')
->disableOriginalConstructor()
->getMock();
- $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager);
$backend1->expects($this->once())
->method('inGroup')
@@ -293,7 +303,7 @@ class GroupTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$userManager = $this->getUserManager();
- $group = new \OC\Group\Group('group1', array($backend), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager);
$backend->expects($this->once())
->method('usersInGroup')
@@ -315,7 +325,7 @@ class GroupTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$userManager = $this->getUserManager();
- $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager);
$backend1->expects($this->once())
->method('usersInGroup')
@@ -338,7 +348,7 @@ class GroupTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$userManager = $this->getUserManager();
- $group = new \OC\Group\Group('group1', array($backend), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager);
$backend->expects($this->once())
->method('usersInGroup')
@@ -360,7 +370,7 @@ class GroupTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$userManager = $this->getUserManager();
- $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager);
$backend1->expects($this->once())
->method('usersInGroup')
@@ -385,7 +395,7 @@ class GroupTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$userManager = $this->getUserManager();
- $group = new \OC\Group\Group('group1', array($backend1), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend1), $this->dispatcher, $userManager);
$backend1->expects($this->once())
->method('countUsersInGroup')
@@ -409,7 +419,7 @@ class GroupTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$userManager = $this->getUserManager();
- $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager);
$backend1->expects($this->once())
->method('countUsersInGroup')
@@ -437,7 +447,7 @@ class GroupTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$userManager = $this->getUserManager();
- $group = new \OC\Group\Group('group1', array($backend1), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend1), $this->dispatcher, $userManager);
$backend1->expects($this->never())
->method('countUsersInGroup');
@@ -455,7 +465,7 @@ class GroupTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$userManager = $this->getUserManager();
- $group = new \OC\Group\Group('group1', array($backend), $userManager);
+ $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager);
$backend->expects($this->once())
->method('deleteGroup')