diff options
-rw-r--r-- | appinfo/database.xml | 4 | ||||
-rw-r--r-- | appinfo/routes.php | 4 | ||||
-rw-r--r-- | js/circles.app.actions.js | 6 | ||||
-rw-r--r-- | js/circles.app.elements.js | 2 | ||||
-rw-r--r-- | js/circles.v1.js | 11 | ||||
-rw-r--r-- | lib/Api/v1/Circles.php | 19 | ||||
-rw-r--r-- | lib/Controller/MembersController.php | 10 | ||||
-rw-r--r-- | lib/Exceptions/MemberTypeCantEditLevelException.php | 32 | ||||
-rw-r--r-- | lib/Model/BaseCircle.php | 1 | ||||
-rw-r--r-- | lib/Model/Member.php | 13 | ||||
-rw-r--r-- | lib/Service/MembersService.php | 8 | ||||
-rw-r--r-- | tests/unit/lib/Api/CirclesTest.php | 112 |
12 files changed, 155 insertions, 67 deletions
diff --git a/appinfo/database.xml b/appinfo/database.xml index a74820a7..ca2ab451 100644 --- a/appinfo/database.xml +++ b/appinfo/database.xml @@ -149,9 +149,9 @@ <field> <name>user_id</name> </field> - <!--<field> + <field> <name>user_type</name> - </field>--> + </field> </index> </declaration> diff --git a/appinfo/routes.php b/appinfo/routes.php index f38c9433..ea0b7e06 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -85,11 +85,11 @@ return [ 'name' => 'Members#addEmailAddress', 'url' => '/v1/circles/{uniqueId}/email', 'verb' => 'PUT' ], [ - 'name' => 'Members#removeLocalMember', 'url' => '/v1/circles/{uniqueId}/member', + 'name' => 'Members#removeMember', 'url' => '/v1/circles/{uniqueId}/member', 'verb' => 'DELETE', ], [ - 'name' => 'Members#level', 'url' => '/v1/circles/{uniqueId}/level', 'verb' => 'POST' + 'name' => 'Members#levelMember', 'url' => '/v1/circles/{uniqueId}/level', 'verb' => 'POST' ], [ 'name' => 'Groups#add', 'url' => '/v1/circles/{uniqueId}/groups', 'verb' => 'PUT' diff --git a/js/circles.app.actions.js b/js/circles.app.actions.js index bb429983..5bbc9e61 100644 --- a/js/circles.app.actions.js +++ b/js/circles.app.actions.js @@ -48,7 +48,7 @@ var actions = { actions.changeMemberOwner(member); return; } - api.levelMember(curr.circle, member, level, resultMembers.levelMemberResult); + api.levelMember(curr.circle, member, define.typeUser, level, resultMembers.levelMemberResult); nav.circlesActionReturn(); }, @@ -70,7 +70,7 @@ var actions = { t('circles', 'This action is irreversible'), function (e) { if (e === true) { - api.levelMember(curr.circle, member, define.levelOwner, + api.levelMember(curr.circle, member, define.typeUser, define.levelOwner, resultMembers.levelMemberResult); nav.circlesActionReturn(); return; @@ -83,7 +83,7 @@ var actions = { changeMemberStatus: function (member, value) { if (value === 'remove_member' || value === 'dismiss_request') { - api.removeMember(curr.circle, member, resultMembers.removeMemberResult); + api.removeMember(curr.circle, member, define.typeUser, resultMembers.removeMemberResult); } if (value === 'accept_request') { api.addMember(curr.circle, member, resultMembers.addMemberResult); diff --git a/js/circles.app.elements.js b/js/circles.app.elements.js index bfbf5548..0086940a 100644 --- a/js/circles.app.elements.js +++ b/js/circles.app.elements.js @@ -436,7 +436,7 @@ var elements = { var tmpl = $('#tmpl_member').html(); tmpl = tmpl.replace(/%username%/g, escapeHTML(entry.user_id)); - tmpl = tmpl.replace(/%type%/g, escapeHTML(entry.type)); + tmpl = tmpl.replace(/%type%/g, escapeHTML(entry.user_type)); tmpl = tmpl.replace(/%displayname%/g, escapeHTML(entry.display_name)); tmpl = tmpl.replace(/%level%/g, escapeHTML(entry.level)); tmpl = tmpl.replace(/%levelString%/g, escapeHTML(entry.level_string)); diff --git a/js/circles.v1.js b/js/circles.v1.js index cfac5dbb..99b7d883 100644 --- a/js/circles.v1.js +++ b/js/circles.v1.js @@ -148,14 +148,14 @@ }; - - this.removeMember = function (circleId, userId, callback) { + this.removeMember = function (circleId, userId, userType, callback) { var result = {status: -1}; $.ajax({ method: 'DELETE', url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/member'), data: { - member: userId + member: userId, + type: userType } }).done(function (res) { self.onCallback(callback, res); @@ -165,13 +165,14 @@ }; - this.levelMember = function (circleId, member, level, callback) { + this.levelMember = function (circleId, userId, userType, level, callback) { var result = {status: -1}; $.ajax({ method: 'POST', url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/level'), data: { - member: member, + member: userId, + type: userType, level: level } }).done(function (res) { diff --git a/lib/Api/v1/Circles.php b/lib/Api/v1/Circles.php index 14267505..ff51c575 100644 --- a/lib/Api/v1/Circles.php +++ b/lib/Api/v1/Circles.php @@ -231,7 +231,7 @@ class Circles { /** - * Circles::addMember(); + * Circles::addLocalMember(); * * This function will add a user as member of the circle. Current user need at least to be * Moderator. @@ -241,7 +241,7 @@ class Circles { * * @return Member[] */ - public static function addMember($circleUniqueId, $userId) { + public static function addLocalMember($circleUniqueId, $userId) { $c = self::getContainer(); return $c->query('MembersService') @@ -257,14 +257,15 @@ class Circles { * * @param string $circleUniqueId * @param string $userId + * @param int $userType * * @return Member */ - public static function getLocalMember($circleUniqueId, $userId) { + public static function getMember($circleUniqueId, $userId, $userType) { $c = self::getContainer(); return $c->query('MembersService') - ->getMember($circleUniqueId, $userId, Member::TYPE_USER); + ->getMember($circleUniqueId, $userId, $userType); } @@ -276,14 +277,15 @@ class Circles { * * @param string $circleUniqueId * @param string $userId + * @param int $userType * * @return Member[] */ - public static function removeMember($circleUniqueId, $userId) { + public static function removeMember($circleUniqueId, $userId, $userType) { $c = self::getContainer(); return $c->query('MembersService') - ->removeMember($circleUniqueId, $userId); + ->removeMember($circleUniqueId, $userId, $userType); } @@ -297,15 +299,16 @@ class Circles { * * @param string $circleUniqueId * @param string $userId + * @param int $userType * @param int $level * * @return Member[] */ - public static function levelMember($circleUniqueId, $userId, $level) { + public static function levelMember($circleUniqueId, $userId, $userType, $level) { $c = self::getContainer(); return $c->query('MembersService') - ->levelMember($circleUniqueId, $userId, $level); + ->levelMember($circleUniqueId, $userId, $userType, $level); } diff --git a/lib/Controller/MembersController.php b/lib/Controller/MembersController.php index 0002fb9f..656d87df 100644 --- a/lib/Controller/MembersController.php +++ b/lib/Controller/MembersController.php @@ -143,14 +143,15 @@ class MembersController extends BaseController { * * @param string $uniqueId * @param string $member + * @param int $type * @param int $level * * @return DataResponse */ - public function level($uniqueId, $member, $level) { + public function levelMember($uniqueId, $member, $type, $level) { try { - $data = $this->membersService->levelLocalMember($uniqueId, $member, $level); + $data = $this->membersService->levelMember($uniqueId, $member, $type, $level); } catch (\Exception $e) { return $this->fail( @@ -182,13 +183,14 @@ class MembersController extends BaseController { * * @param string $uniqueId * @param string $member + * @param int $type * * @return DataResponse */ - public function removeLocalMember($uniqueId, $member) { + public function removeMember($uniqueId, $member, $type) { try { - $data = $this->membersService->removeMember($uniqueId, $member, Member::TYPE_USER); + $data = $this->membersService->removeMember($uniqueId, $member, $type); } catch (\Exception $e) { return $this->fail( diff --git a/lib/Exceptions/MemberTypeCantEditLevelException.php b/lib/Exceptions/MemberTypeCantEditLevelException.php new file mode 100644 index 00000000..6ba4664f --- /dev/null +++ b/lib/Exceptions/MemberTypeCantEditLevelException.php @@ -0,0 +1,32 @@ +<?php +/** + * Circles - Bring cloud-users closer together. + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@pontapreta.net> + * @copyright 2017 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Circles\Exceptions; + +class MemberTypeCantEditLevelException extends \Exception { + +} + diff --git a/lib/Model/BaseCircle.php b/lib/Model/BaseCircle.php index dac700f3..ecad20e1 100644 --- a/lib/Model/BaseCircle.php +++ b/lib/Model/BaseCircle.php @@ -138,6 +138,7 @@ class BaseCircle { public function generateUniqueId() { $uniqueId = bin2hex(openssl_random_pseudo_bytes(24)); $this->setUniqueId($uniqueId); + $this->setId($this->getUniqueId()); } public function setName($name) { diff --git a/lib/Model/Member.php b/lib/Model/Member.php index 36b62ba8..e15eb1cb 100644 --- a/lib/Model/Member.php +++ b/lib/Model/Member.php @@ -35,6 +35,7 @@ use OCA\Circles\Exceptions\MemberIsNotAdminException; use OCA\Circles\Exceptions\MemberIsNotModeratorException; use OCA\Circles\Exceptions\MemberIsNotOwnerException; use OCA\Circles\Exceptions\MemberIsOwnerException; +use OCA\Circles\Exceptions\MemberTypeCantEditLevelException; use OCA\Circles\Exceptions\ModeratorIsNotHighEnoughException; class Member extends BaseMember { @@ -220,6 +221,18 @@ class Member extends BaseMember { /** + * @throws MemberTypeCantEditLevelException + */ + public function levelHasToBeEditable() { + if ($this->getType() !== self::TYPE_USER) { + throw new MemberTypeCantEditLevelException( + $this->l10n->t('Level cannot be changed for that type of member') + ); + } + } + + + /** * @throws MemberAlreadyExistsException * @throws MemberIsBlockedException */ diff --git a/lib/Service/MembersService.php b/lib/Service/MembersService.php index 70d63f83..4c07c67e 100644 --- a/lib/Service/MembersService.php +++ b/lib/Service/MembersService.php @@ -264,12 +264,13 @@ class MembersService { /** * @param string $circleUniqueId * @param string $name + * @param int $type * @param int $level * * @return array * @throws \Exception */ - public function levelLocalMember($circleUniqueId, $name, $level) { + public function levelMember($circleUniqueId, $name, $type, $level) { $level = (int)$level; try { @@ -280,9 +281,8 @@ class MembersService { ); } - $member = $this->membersRequest->forceGetMember( - $circle->getUniqueId(), $name, Member::TYPE_USER - ); + $member = $this->membersRequest->forceGetMember($circle->getUniqueId(), $name, $type); + $member->levelHasToBeEditable(); if ($member->getLevel() !== $level) { if ($level === Member::LEVEL_OWNER) { $this->switchOwner($circle, $member); diff --git a/tests/unit/lib/Api/CirclesTest.php b/tests/unit/lib/Api/CirclesTest.php index ed024f69..68722445 100644 --- a/tests/unit/lib/Api/CirclesTest.php +++ b/tests/unit/lib/Api/CirclesTest.php @@ -73,7 +73,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { Circles::createCircle(Circle::CIRCLES_PUBLIC, self::NAME_PUBLIC_CIRCLE1), 'Secret' => Circles::createCircle(Circle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE1), - 'Closed' => + 'Closed' => Circles::createCircle(Circle::CIRCLES_CLOSED, self::NAME_CLOSED_CIRCLE1), 'Personal' => Circles::createCircle(Circle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1) @@ -161,7 +161,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { try { foreach ($circles AS $circle) { - Circles::addMember($circle->getId(), Env::ENV_TEST_ADMIN2); + Circles::addLocalMember($circle->getId(), Env::ENV_TEST_ADMIN2); if ($circle->getType() === Circle::CIRCLES_CLOSED) { // In closed circle, we need to confirm the invitation @@ -171,7 +171,8 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { } Circles::levelMember( - $circle->getId(), Env::ENV_TEST_ADMIN2, Member::LEVEL_MODERATOR + $circle->getId(), Env::ENV_TEST_ADMIN2, Member::TYPE_USER, + Member::LEVEL_MODERATOR ); } } catch (Exception $e) { @@ -187,7 +188,8 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { try { Circles::levelMember( - $circle->getId(), Env::ENV_TEST_ADMIN3, Member::LEVEL_MODERATOR + $circle->getId(), Env::ENV_TEST_ADMIN3, Member::TYPE_USER, + Member::LEVEL_MODERATOR ); $this->assertSame(true, false, 'should return an exception'); } catch (MemberDoesNotExistException $e) { @@ -199,7 +201,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { try { Circles::levelMember( - $circle->getId(), Env::ENV_TEST_ADMIN2, Member::LEVEL_ADMIN + $circle->getId(), Env::ENV_TEST_ADMIN2, Member::TYPE_USER, Member::LEVEL_ADMIN ); $this->assertSame(true, false, 'should return an exception'); } catch (ModeratorIsNotHighEnoughException $e) { @@ -211,7 +213,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { try { Circles::levelMember( - $circle->getId(), Env::ENV_TEST_ADMIN2, Member::LEVEL_OWNER + $circle->getId(), Env::ENV_TEST_ADMIN2, Member::TYPE_USER, Member::LEVEL_OWNER ); $this->assertSame(true, false, 'should return an exception'); } catch (MemberIsNotOwnerException $e) { @@ -230,7 +232,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { try { foreach ($circles AS $circle) { - Circles::addMember($circle->getId(), Env::ENV_TEST_MODERATOR2); + Circles::addLocalMember($circle->getId(), Env::ENV_TEST_MODERATOR2); if ($circle->getType() === Circle::CIRCLES_CLOSED) { // In closed circle, we need to confirm the invitation Env::setUser(Env::ENV_TEST_MODERATOR2); @@ -251,7 +253,8 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { foreach ($circles AS $circle) { try { Circles::levelMember( - $circle->getId(), Env::ENV_TEST_MODERATOR2, Member::LEVEL_MODERATOR + $circle->getId(), Env::ENV_TEST_MODERATOR2, Member::TYPE_USER, + Member::LEVEL_MODERATOR ); $this->assertSame(true, false, 'should return an exception'); } catch (ModeratorIsNotHighEnoughException $e) { @@ -262,7 +265,8 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { } try { Circles::levelMember( - $circle->getId(), Env::ENV_TEST_MODERATOR2, Member::LEVEL_ADMIN + $circle->getId(), Env::ENV_TEST_MODERATOR2, Member::TYPE_USER, + Member::LEVEL_ADMIN ); $this->assertSame(true, false, 'should return an exception'); } catch (ModeratorIsNotHighEnoughException $e) { @@ -273,7 +277,8 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { } try { Circles::levelMember( - $circle->getId(), Env::ENV_TEST_MODERATOR2, Member::LEVEL_OWNER + $circle->getId(), Env::ENV_TEST_MODERATOR2, Member::TYPE_USER, + Member::LEVEL_OWNER ); $this->assertSame(true, false, 'should return an exception'); } catch (MemberIsNotOwnerException $e) { @@ -292,7 +297,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { foreach ($circles AS $circle) { try { - Circles::addMember( + Circles::addLocalMember( $circle->getId(), Env::ENV_TEST_MEMBER2 ); $this->assertSame(true, false, 'should return an exception'); @@ -305,7 +310,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { try { Circles::levelMember( - $circle->getId(), Env::ENV_TEST_USER1, Member::LEVEL_MEMBER + $circle->getId(), Env::ENV_TEST_USER1, Member::TYPE_USER, Member::LEVEL_MEMBER ); $this->assertSame(true, false, 'should return an exception'); } catch (MemberDoesNotExistException $e) { @@ -317,7 +322,8 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { try { Circles::levelMember( - $circle->getId(), Env::ENV_TEST_MEMBER1, Member::LEVEL_MODERATOR + $circle->getId(), Env::ENV_TEST_MEMBER1, Member::TYPE_USER, + Member::LEVEL_MODERATOR ); $this->assertSame(true, false, 'should return an exception'); } catch (MemberIsNotModeratorException $e) { @@ -331,7 +337,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { try { Circles::levelMember( - $circle->getId(), Env::ENV_TEST_OWNER1, Member::LEVEL_MEMBER + $circle->getId(), Env::ENV_TEST_OWNER1, Member::TYPE_USER, Member::LEVEL_MEMBER ); $this->assertSame(true, false, 'should return an exception'); } catch (MemberIsNotModeratorException $e) { @@ -476,7 +482,9 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { foreach ($this->circles AS $circle) { try { - $member = Circles::getMember($circle->getId(), Env::ENV_TEST_MEMBER2); + $member = Circles::getMember( + $circle->getId(), Env::ENV_TEST_MEMBER2, Member::TYPE_USER + ); $this->assertEquals( [ Env::ENV_TEST_MEMBER2, Member::LEVEL_NONE, Member::STATUS_NONMEMBER, @@ -494,12 +502,14 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { try { - Circles::addMember($circle->getId(), Env::ENV_TEST_MEMBER2); + Circles::addLocalMember($circle->getId(), Env::ENV_TEST_MEMBER2); // If Closed, we check that the user is not a member before confirming // the invitation using member account if ($circle->getType() === Circle::CIRCLES_CLOSED) { - $member = Circles::getMember($circle->getId(), Env::ENV_TEST_MEMBER2); + $member = Circles::getMember( + $circle->getId(), Env::ENV_TEST_MEMBER2, Member::TYPE_USER + ); $this->assertEquals( [ Env::ENV_TEST_MEMBER2, Member::LEVEL_NONE, Member::STATUS_INVITED, @@ -516,7 +526,9 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { Env::setUser(Env::ENV_TEST_OWNER1); } - $member = Circles::getMember($circle->getId(), Env::ENV_TEST_MEMBER2); + $member = Circles::getMember( + $circle->getId(), Env::ENV_TEST_MEMBER2, Member::TYPE_USER + ); $this->assertEquals( [ Env::ENV_TEST_MEMBER2, Member::LEVEL_MEMBER, Member::STATUS_MEMBER, @@ -529,8 +541,12 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { ); - Circles::removeMember($circle->getId(), Env::ENV_TEST_MEMBER2); - $member = Circles::getMember($circle->getId(), Env::ENV_TEST_MEMBER2); + Circles::removeMember( + $circle->getId(), Env::ENV_TEST_MEMBER2, Member::TYPE_USER + ); + $member = Circles::getMember( + $circle->getId(), Env::ENV_TEST_MEMBER2, Member::TYPE_USER + ); $this->assertEquals( [ Env::ENV_TEST_MEMBER2, Member::LEVEL_NONE, Member::STATUS_NONMEMBER, @@ -565,7 +581,9 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { foreach ($this->circles AS $circle) { try { - $member = Circles::getMember($circle->getId(), Env::ENV_TEST_MEMBER3); + $member = Circles::getMember( + $circle->getId(), Env::ENV_TEST_MEMBER3, Member::TYPE_USER + ); $this->assertEquals( [ Env::ENV_TEST_MEMBER3, Member::LEVEL_NONE, Member::STATUS_NONMEMBER, @@ -611,7 +629,9 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { // the request using a moderator account if ($circle->getType() === Circle::CIRCLES_CLOSED) { Env::setUser(Env::ENV_TEST_OWNER1); - $member = Circles::getMember($circle->getId(), Env::ENV_TEST_MEMBER3); + $member = Circles::getMember( + $circle->getId(), Env::ENV_TEST_MEMBER3, Member::TYPE_USER + ); $this->assertEquals( [ Env::ENV_TEST_MEMBER3, Member::LEVEL_NONE, @@ -624,11 +644,13 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { ] ); - Circles::addMember($circle->getId(), Env::ENV_TEST_MEMBER3); + Circles::addLocalMember($circle->getId(), Env::ENV_TEST_MEMBER3); Env::setUser(Env::ENV_TEST_MEMBER3); } - $member = Circles::getMember($circle->getId(), Env::ENV_TEST_MEMBER3); + $member = Circles::getMember( + $circle->getId(), Env::ENV_TEST_MEMBER3, Member::TYPE_USER + ); $this->assertEquals( [ Env::ENV_TEST_MEMBER3, Member::LEVEL_MEMBER, Member::STATUS_MEMBER, @@ -648,7 +670,9 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { // We check the member have no access to the circle try { - Circles::getMember($circle->getId(), Env::ENV_TEST_MEMBER3); + Circles::getMember( + $circle->getId(), Env::ENV_TEST_MEMBER3, Member::TYPE_USER + ); $this->assertSame( true, false, 'should return an exception' ); @@ -662,7 +686,9 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { // We check that the user is not a member from the owner PoV Env::setUser(Env::ENV_TEST_OWNER1); try { - $member = Circles::getMember($circle->getId(), Env::ENV_TEST_MEMBER3); + $member = Circles::getMember( + $circle->getId(), Env::ENV_TEST_MEMBER3, Member::TYPE_USER + ); $this->assertEquals( [ Env::ENV_TEST_MEMBER3, Member::LEVEL_NONE, Member::STATUS_NONMEMBER, @@ -702,7 +728,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { array_push($result, $circle->getName()); } - $this->assertEquals($result, [self::NAME_CLOSED_CIRCLE1, self::NAME_PUBLIC_CIRCLE1]); + $this->assertEquals($result, [self::NAME_PUBLIC_CIRCLE1, self::NAME_CLOSED_CIRCLE1]); // Let's add user to all circle @@ -728,9 +754,10 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( $result, [ - self::NAME_SECRET_CIRCLE1, self::NAME_PERSONAL_CIRCLE1, + self::NAME_PUBLIC_CIRCLE1, + self::NAME_SECRET_CIRCLE1, self::NAME_CLOSED_CIRCLE1, - self::NAME_PUBLIC_CIRCLE1 + self::NAME_PERSONAL_CIRCLE1 ] ); @@ -748,8 +775,9 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( $result, [ - self::NAME_SECRET_CIRCLE1, self::NAME_CLOSED_CIRCLE1, - self::NAME_PUBLIC_CIRCLE1 + self::NAME_PUBLIC_CIRCLE1, + self::NAME_SECRET_CIRCLE1, + self::NAME_CLOSED_CIRCLE1 ] ); @@ -768,7 +796,9 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { // removing member from Circle Env::setUser(Env::ENV_TEST_OWNER1); - Circles::removeMember($this->circles['Secret']->getId(), Env::ENV_TEST_MEMBER1); + Circles::removeMember( + $this->circles['Secret']->getId(), Env::ENV_TEST_MEMBER1, Member::TYPE_USER + ); // member with a search on secret Env::setUser(Env::ENV_TEST_MEMBER1); @@ -832,30 +862,36 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { $curr = Env::currentUser(); - Circles::addMember($circleId, Env::ENV_TEST_ADMIN1); + Circles::addLocalMember($circleId, Env::ENV_TEST_ADMIN1); if ($isClosed) { Env::setUser(Env::ENV_TEST_ADMIN1); Circles::joinCircle($circleId); Env::setUser($curr); } - Circles::levelMember($circleId, Env::ENV_TEST_ADMIN1, Member::LEVEL_ADMIN); + Circles::levelMember( + $circleId, Env::ENV_TEST_ADMIN1, Member::TYPE_USER, Member::LEVEL_ADMIN + ); - Circles::addMember($circleId, Env::ENV_TEST_MODERATOR1); + Circles::addLocalMember($circleId, Env::ENV_TEST_MODERATOR1); if ($isClosed) { Env::setUser(Env::ENV_TEST_MODERATOR1); Circles::joinCircle($circleId); Env::setUser($curr); } - Circles::levelMember($circleId, Env::ENV_TEST_MODERATOR1, Member::LEVEL_MODERATOR); + Circles::levelMember( + $circleId, Env::ENV_TEST_MODERATOR1, Member::TYPE_USER, Member::LEVEL_MODERATOR + ); - Circles::addMember($circleId, Env::ENV_TEST_MEMBER1); + Circles::addLocalMember($circleId, Env::ENV_TEST_MEMBER1); if ($isClosed) { Env::setUser(Env::ENV_TEST_MEMBER1); Circles::joinCircle($circleId); Env::setUser($curr); } - Circles::levelMember($circleId, Env::ENV_TEST_MEMBER1, Member::LEVEL_MEMBER); + Circles::levelMember( + $circleId, Env::ENV_TEST_MEMBER1, Member::TYPE_USER, Member::LEVEL_MEMBER + ); } } |