diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml
index c2542d762..a48067f31 100644
--- a/.github/workflows/phpunit.yml
+++ b/.github/workflows/phpunit.yml
@@ -200,3 +200,64 @@ jobs:
# - name: PHPUnit integration
# working-directory: apps/${{ env.APP_NAME }}
# run: ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml
+
+ oci:
+ runs-on: ubuntu-latest
+
+ strategy:
+ # do not stop on another job's failure
+ fail-fast: false
+ matrix:
+ php-versions: ['7.4']
+ databases: ['oci']
+
+ name: php${{ matrix.php-versions }}-${{ matrix.databases }}
+
+ services:
+ oracle:
+ image: deepdiver/docker-oracle-xe-11g # "wnameless/oracle-xe-11g-r2"
+ ports:
+ - "1521:1521"
+
+ steps:
+ - name: Checkout server
+ uses: actions/checkout@v2
+ with:
+ repository: nextcloud/server
+ ref: ${{ env.GITHUB_BASE_REF }}
+
+ - name: Checkout submodules
+ shell: bash
+ run: |
+ auth_header="$(git config --local --get http.https://github.com/.extraheader)"
+ git submodule sync --recursive
+ git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
+
+ - name: Checkout app
+ uses: actions/checkout@v2
+ with:
+ path: apps/${{ env.APP_NAME }}
+
+ - name: Set up php ${{ matrix.php-versions }}
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: "${{ matrix.php-versions }}"
+ extensions: mbstring, iconv, fileinfo, intl, oci8
+ tools: phpunit:8.5.2
+ coverage: none
+
+ - name: Set up PHPUnit
+ working-directory: apps/${{ env.APP_NAME }}
+ run: composer i
+
+ - name: Set up Nextcloud
+ run: |
+ mkdir data
+ ./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin
+ php -f index.php
+ ./occ app:enable --force ${{ env.APP_NAME }}
+ php -S localhost:8080 &
+
+ - name: PHPUnit
+ working-directory: apps/${{ env.APP_NAME }}/tests
+ run: ../vendor/phpunit/phpunit/phpunit -c phpunit.xml
diff --git a/lib/Db/CircleRequestBuilder.php b/lib/Db/CircleRequestBuilder.php
index ea0fbd987..dbeb8ab2c 100644
--- a/lib/Db/CircleRequestBuilder.php
+++ b/lib/Db/CircleRequestBuilder.php
@@ -112,6 +112,8 @@ public function getItemFromRequest(CoreQueryBuilder $qb): Circle {
$circle = $qb->asItem(Circle::class);
} catch (RowNotFoundException $e) {
throw new CircleNotFoundException('Circle not found');
+ } catch (\Exception $e) {
+ throw new \Exception($qb->getSQL());
}
return $circle;
diff --git a/lib/Db/CoreQueryBuilder.php b/lib/Db/CoreQueryBuilder.php
index 5f1992e7b..532d6e023 100644
--- a/lib/Db/CoreQueryBuilder.php
+++ b/lib/Db/CoreQueryBuilder.php
@@ -56,30 +56,29 @@ class CoreQueryBuilder extends ExtendedQueryBuilder {
use TArrayTools;
- public const SINGLE = 'single';
- public const CIRCLE = 'circle';
- public const MEMBER = 'member';
- public const MEMBER_COUNT = 'membercount';
- public const OWNER = 'owner';
- public const FEDERATED_EVENT = 'federatedevent';
- public const REMOTE = 'remote';
- public const BASED_ON = 'basedon';
- public const INITIATOR = 'initiator';
- public const DIRECT_INITIATOR = 'initiatordirect';
- public const MEMBERSHIPS = 'memberships';
- public const CONFIG = 'config';
- public const UPSTREAM_MEMBERSHIPS = 'upstreammemberships';
- public const INHERITANCE_FROM = 'inheritancefrom';
- public const INHERITED_BY = 'inheritedby';
- public const INVITED_BY = 'invitedby';
- public const MOUNT = 'mount';
- public const MOUNTPOINT = 'mountpoint';
- public const SHARE = 'share';
- public const FILE_CACHE = 'filecache';
- public const STORAGES = 'storages';
- public const TOKEN = 'token';
- public const OPTIONS = 'options';
- public const HELPER = 'circleshelper';
+ public const SINGLE = 'cs';
+ public const CIRCLE = 'cc';
+ public const MEMBER = 'mm';
+ public const OWNER = 'wn';
+ public const FEDERATED_EVENT = 'ev';
+ public const REMOTE = 'rm';
+ public const BASED_ON = 'on';
+ public const INITIATOR = 'in';
+ public const DIRECT_INITIATOR = 'di';
+ public const MEMBERSHIPS = 'ms';
+ public const CONFIG = 'cf';
+ public const UPSTREAM_MEMBERSHIPS = 'up';
+ public const INHERITANCE_FROM = 'ih';
+ public const INHERITED_BY = 'by';
+ public const INVITED_BY = 'nv';
+ public const MOUNT = 'mo';
+ public const MOUNTPOINT = 'mp';
+ public const SHARE = 'sh';
+ public const FILE_CACHE = 'fc';
+ public const STORAGES = 'st';
+ public const TOKEN = 'tk';
+ public const OPTIONS = 'pt';
+ public const HELPER = 'hp';
public static $SQL_PATH = [
@@ -90,7 +89,6 @@ class CoreQueryBuilder extends ExtendedQueryBuilder {
self::OPTIONS => [
],
self::MEMBER,
- self::MEMBER_COUNT,
self::OWNER => [
self::BASED_ON
],
diff --git a/lib/Migration/Version0023Date20211216113101.php b/lib/Migration/Version0023Date20211216113101.php
index 8318f3481..08de3b3c7 100644
--- a/lib/Migration/Version0023Date20211216113101.php
+++ b/lib/Migration/Version0023Date20211216113101.php
@@ -47,5 +47,4 @@ class Version0023Date20211216113101 extends SimpleMigrationStep {
*/
public function __construct(IDBConnection $connection) {
}
-
}
diff --git a/lib/Migration/Version0024Date20220203123901.php b/lib/Migration/Version0024Date20220203123901.php
index e52d36b06..8ee892e8a 100644
--- a/lib/Migration/Version0024Date20220203123901.php
+++ b/lib/Migration/Version0024Date20220203123901.php
@@ -69,8 +69,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table = $schema->getTable('circles_token');
$table->changeColumn(
'password', [
- 'length' => 127
- ]
+ 'length' => 127
+ ]
);
}
@@ -105,5 +105,4 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
return $schema;
}
-
}
diff --git a/lib/Migration/Version0024Date20220203123902.php b/lib/Migration/Version0024Date20220203123902.php
index ee3fa5cf5..38e100470 100644
--- a/lib/Migration/Version0024Date20220203123902.php
+++ b/lib/Migration/Version0024Date20220203123902.php
@@ -64,61 +64,61 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table = $schema->createTable('circles_event');
$table->addColumn(
'token', 'string', [
- 'notnull' => false,
- 'length' => 63,
- ]
+ 'notnull' => false,
+ 'length' => 63,
+ ]
);
$table->addColumn(
'event', 'text', [
- 'notnull' => false
- ]
+ 'notnull' => false
+ ]
);
$table->addColumn(
'result', 'text', [
- 'notnull' => false
- ]
+ 'notnull' => false
+ ]
);
$table->addColumn(
'instance', 'string', [
- 'length' => 255,
- 'notnull' => false
- ]
+ 'length' => 255,
+ 'notnull' => false
+ ]
);
$table->addColumn(
'interface', 'integer', [
- 'notnull' => true,
- 'length' => 1,
- 'default' => 0
- ]
+ 'notnull' => true,
+ 'length' => 1,
+ 'default' => 0
+ ]
);
$table->addColumn(
'severity', 'integer', [
- 'length' => 3,
- 'notnull' => false
- ]
+ 'length' => 3,
+ 'notnull' => false
+ ]
);
$table->addColumn(
'retry', 'integer', [
- 'length' => 3,
- 'notnull' => false
- ]
+ 'length' => 3,
+ 'notnull' => false
+ ]
);
$table->addColumn(
'status', 'integer', [
- 'length' => 3,
- 'notnull' => false
- ]
+ 'length' => 3,
+ 'notnull' => false
+ ]
);
$table->addColumn(
'updated', 'datetime', [
- 'notnull' => false,
- ]
+ 'notnull' => false,
+ ]
);
$table->addColumn(
'creation', 'bigint', [
- 'length' => 14,
- 'notnull' => false
- ]
+ 'length' => 14,
+ 'notnull' => false
+ ]
);
$table->setPrimaryKey(['token', 'instance']);
@@ -126,5 +126,4 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
return $schema;
}
-
}
diff --git a/lib/Migration/Version0024Date20220317190331.php b/lib/Migration/Version0024Date20220317190331.php
new file mode 100644
index 000000000..0590a689f
--- /dev/null
+++ b/lib/Migration/Version0024Date20220317190331.php
@@ -0,0 +1,70 @@
+
+ * @copyright 2022
+ * @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 .
+ *
+ */
+
+
+namespace OCA\Circles\Migration;
+
+use Closure;
+use Doctrine\DBAL\Schema\SchemaException;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version0024Date20220317190331 extends SimpleMigrationStep {
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ *
+ * @return null|ISchemaWrapper
+ * @throws SchemaException
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if ($schema->hasTable('circles_membership')) {
+ $table = $schema->getTable('circles_membership');
+ if (!$table->hasPrimaryKey()) {
+ $indexes = $table->getIndexes();
+ // conflict in Oracle with existing unique index, duplicate of primaryKey.
+ foreach ($indexes as $index) {
+ if ($index->isUnique()) {
+ $table->dropIndex($index->getName());
+ }
+ }
+ $table->setPrimaryKey(['single_id', 'circle_id']);
+ }
+ }
+
+ return $schema;
+ }
+}
diff --git a/tests/TestSuiteListener.php b/tests/TestSuiteListener.php
index 01bab5445..a6c873ad0 100644
--- a/tests/TestSuiteListener.php
+++ b/tests/TestSuiteListener.php
@@ -28,8 +28,14 @@
namespace OCA\Circles\Tests;
use OCA\Circles\Model\DeprecatedCircle;
-
-class Env implements \PHPUnit_Framework_TestListener {
+use PHPUnit\Framework\TestListener;
+use PHPUnit\Framework\Test;
+use PHPUnit\Framework\TestSuite;
+use PHPUnit\Framework\AssertionFailedError;
+use PHPUnit\Framework\Warning;
+use Throwable;
+
+class Env implements TestListener {
public const ENV_TEST_OWNER1 = '_test_circles_owner1';
public const ENV_TEST_OWNER2 = '_test_circles_owner2';
public const ENV_TEST_OWNER3 = '_test_circles_owner3';
@@ -54,31 +60,31 @@ class Env implements \PHPUnit_Framework_TestListener {
/** @var array */
private $users;
- public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) {
+ public function addError(Test $test, Throwable $e, float $time): void {
}
public function addFailure(
- \PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time
- ) {
+ Test $test, AssertionFailedError $e, float $time
+ ): void {
}
- public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) {
+ public function addIncompleteTest(Test $test, Throwable $e, float $time): void {
}
- public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) {
+ public function addRiskyTest(Test $test, Throwable $e, float $time): void {
}
- public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) {
+ public function addSkippedTest(Test $test, Throwable $e, float $time): void {
}
- public function startTest(\PHPUnit_Framework_Test $test) {
+ public function startTest(Test $test): void {
}
- public function endTest(\PHPUnit_Framework_Test $test, $time) {
+ public function endTest(Test $test, float $time): void {
}
- public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) {
- if ($suite->getName() !== '.') {
+ public function startTestSuite(TestSuite $suite): void {
+ if ($suite->getName() !== 'OCA\Circles\Tests\Api\CirclesTest') {
return;
}
@@ -92,7 +98,7 @@ public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) {
}
}
- public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) {
+ public function endTestSuite(TestSuite $suite): void {
if ($suite->getName() !== '.') {
return;
}
@@ -106,8 +112,8 @@ public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) {
}
}
- public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time
- ) {
+ public function addWarning(Test $test, Warning $e, float $time
+ ): void {
}
public static function setUser($which) {
@@ -117,8 +123,7 @@ public static function setUser($which) {
->get($which)
);
- return $userSession->getUser()
- ->getUID();
+ return $userSession->getUser()->getUID();
}
public static function currentUser() {
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 4d16b4deb..9a4ec2494 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -1,8 +1,12 @@
addValidRoot(OC::$SERVERROOT . '/tests');
+\OC::$composerAutoloader->addPsr4('Tests\\', OC::$SERVERROOT . '/tests/unit/', true);
+
\OC_App::loadApp('circles');
+
+OC_Hook::clear();
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
index bc72f90f8..2dd3715ac 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -17,4 +17,4 @@
-
\ No newline at end of file
+
diff --git a/tests/unit/lib/Api/CirclesTest.php b/tests/unit/lib/Api/CirclesTest.php
index c38aa1cf2..4b9a9ea6a 100644
--- a/tests/unit/lib/Api/CirclesTest.php
+++ b/tests/unit/lib/Api/CirclesTest.php
@@ -40,7 +40,9 @@
use OCA\Circles\Tests\Env;
use OCP\AppFramework\QueryException;
-class CirclesTest extends \PHPUnit_Framework_TestCase {
+use Test\TestCase;
+
+class CirclesTest extends TestCase {
public const NAME_PUBLIC_CIRCLE1 = '_circleNamePublic1';
public const NAME_SECRET_CIRCLE1 = '_circleNameSecret1';
public const NAME_CLOSED_CIRCLE1 = '_circleNameClosed1';
@@ -62,830 +64,830 @@ class CirclesTest extends \PHPUnit_Framework_TestCase {
*
* @throws Exception
*/
- protected function setUp() {
- Env::setUser(Env::ENV_TEST_OWNER1);
-
- $this->circles = [];
- try {
- $this->circles = [
- 'Public' =>
- Circles::createCircle(DeprecatedCircle::CIRCLES_PUBLIC, self::NAME_PUBLIC_CIRCLE1),
- 'Secret' =>
- Circles::createCircle(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE1),
- 'Closed' =>
- Circles::createCircle(DeprecatedCircle::CIRCLES_CLOSED, self::NAME_CLOSED_CIRCLE1),
- 'Personal' =>
- Circles::createCircle(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1)
- ];
- } catch (Exception $e) {
- throw $e;
- }
-
- Env::logout();
- }
-
-
- /**
- * tearDown() is initiated after each test.
- *
- * Function will destroy the circles created in setUp()
- *
- * @throws Exception
- */
- protected function tearDown() {
- Env::setUser(Env::ENV_TEST_OWNER1);
- try {
- foreach ($this->circles as $circle) {
- Circles::destroyCircle($circle->getId());
- }
- } catch (Exception $e) {
- throw $e;
- }
-
- Env::logout();
- }
-
-
- /**
- * Testing Circles::version()
- */
- public function testVersion() {
- $this->assertSame(Circles::version(), Circles::API_VERSION);
- }
-
-
- /**
- * Testing the tools to switch users
- */
- public function testUserSession() {
- Env::setUser(Env::ENV_TEST_ADMIN1);
- $this->assertEquals(Env::currentUser(), Env::ENV_TEST_ADMIN1);
- Env::setUser(Env::ENV_TEST_OWNER3);
- try {
- $this->assertEquals(Env::currentUser(), Env::ENV_TEST_ADMIN1);
- $this->assertSame(true, false, 'should return an exception');
- } catch (Exception $e) {
- }
- Env::setUser(Env::ENV_TEST_OWNER1);
- $this->assertEquals(Env::currentUser(), Env::ENV_TEST_OWNER1);
- }
-
- /**
- * Testing Leveling Members. (not in Personal Circle)
- *
- * @throws Exception
- */
- public function testLevelMemberInCircles() {
- Env::setUser(Env::ENV_TEST_OWNER1);
-
- $circles = [$this->circles['Public'], $this->circles['Closed'], $this->circles['Secret']];
-
- // OWNER1 Should be able to add/level anyone to Admin Level at least
- try {
- foreach ($circles as $circle) {
- $this->generateSimpleCircleWithAllLevel(
- $circle->getId(), ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED)
- );
- }
- } catch (Exception $e) {
- throw $e;
- }
-
- Env::logout();
-
-
- // ADMIN1 should be able to add/level anyone to Moderator level
- Env::setUser(Env::ENV_TEST_ADMIN1);
-
- try {
- foreach ($circles as $circle) {
- Circles::addMember($circle->getId(), Env::ENV_TEST_ADMIN2, DeprecatedMember::TYPE_USER);
-
- if ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED) {
- // In closed circle, we need to confirm the invitation
- Env::setUser(Env::ENV_TEST_ADMIN2);
- Circles::joinCircle($circle->getId());
- Env::setUser(Env::ENV_TEST_ADMIN1);
- }
-
- Circles::levelMember(
- $circle->getId(), Env::ENV_TEST_ADMIN2, DeprecatedMember::TYPE_USER,
- DeprecatedMember::LEVEL_MODERATOR
- );
- }
- } catch (Exception $e) {
- throw $e;
- }
- Env::logout();
-
-
- // ADMIN1 should not be able to level anyone to Admin Level
- Env::setUser(Env::ENV_TEST_ADMIN1);
-
- foreach ($circles as $circle) {
- try {
- Circles::levelMember(
- $circle->getId(), Env::ENV_TEST_ADMIN3, DeprecatedMember::TYPE_USER,
- DeprecatedMember::LEVEL_MODERATOR
- );
- $this->assertSame(true, false, 'should return an exception');
- } catch (MemberDoesNotExistException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a MemberDoesNotExistException'
- );
- }
-
- try {
- Circles::levelMember(
- $circle->getId(), Env::ENV_TEST_ADMIN2, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_ADMIN
- );
- $this->assertSame(true, false, 'should return an exception');
- } catch (ModeratorIsNotHighEnoughException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a ModeratorIsNotHighEnoughException'
- );
- }
-
- try {
- Circles::levelMember(
- $circle->getId(), Env::ENV_TEST_ADMIN2, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_OWNER
- );
- $this->assertSame(true, false, 'should return an exception');
- } catch (MemberIsNotOwnerException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a MemberIsNotOwnerException'
- );
- }
- }
-
- Env::logout();
-
-
- // MODERATOR1 should be able to add anyone
- Env::setUser(Env::ENV_TEST_MODERATOR1);
-
- try {
- foreach ($circles as $circle) {
- Circles::addMember($circle->getId(), Env::ENV_TEST_MODERATOR2, DeprecatedMember::TYPE_USER);
- if ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED) {
- // In closed circle, we need to confirm the invitation
- Env::setUser(Env::ENV_TEST_MODERATOR2);
- Circles::joinCircle($circle->getId());
- Env::setUser(Env::ENV_TEST_MODERATOR1);
- }
- }
- } catch (Exception $e) {
- throw $e;
- }
-
- Env::logout();
-
-
- // MODERATOR1 should not be able to add/level anyone to Moderator/Admin Level
- Env::setUser(Env::ENV_TEST_MODERATOR1);
-
- foreach ($circles as $circle) {
- try {
- Circles::levelMember(
- $circle->getId(), Env::ENV_TEST_MODERATOR2, DeprecatedMember::TYPE_USER,
- DeprecatedMember::LEVEL_MODERATOR
- );
- $this->assertSame(true, false, 'should return an exception');
- } catch (ModeratorIsNotHighEnoughException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a ModeratorIsNotHighEnoughException'
- );
- }
- try {
- Circles::levelMember(
- $circle->getId(), Env::ENV_TEST_MODERATOR2, DeprecatedMember::TYPE_USER,
- DeprecatedMember::LEVEL_ADMIN
- );
- $this->assertSame(true, false, 'should return an exception');
- } catch (ModeratorIsNotHighEnoughException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a ModeratorIsNotHighEnoughException'
- );
- }
- try {
- Circles::levelMember(
- $circle->getId(), Env::ENV_TEST_MODERATOR2, DeprecatedMember::TYPE_USER,
- DeprecatedMember::LEVEL_OWNER
- );
- $this->assertSame(true, false, 'should return an exception');
- } catch (MemberIsNotOwnerException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a MemberIsNotOwnerException'
- );
- }
- }
-
- Env::logout();
-
-
- // MEMBER1 should not be able to add/level anyone to any level
- Env::setUser(Env::ENV_TEST_MEMBER1);
-
- foreach ($circles as $circle) {
- try {
- Circles::addMember(
- $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
- );
- $this->assertSame(true, false, 'should return an exception');
- } catch (MemberIsNotModeratorException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a MemberIsNotModeratorException'
- );
- }
-
- try {
- Circles::levelMember(
- $circle->getId(), Env::ENV_TEST_USER1, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_MEMBER
- );
- $this->assertSame(true, false, 'should return an exception');
- } catch (MemberDoesNotExistException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a MemberDoesNotExistException'
- );
- }
-
- try {
- Circles::levelMember(
- $circle->getId(), Env::ENV_TEST_MEMBER1, DeprecatedMember::TYPE_USER,
- DeprecatedMember::LEVEL_MODERATOR
- );
- $this->assertSame(true, false, 'should return an exception');
- } catch (MemberIsNotModeratorException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false,
- 'should have returned a MemberIsNotModeratorException - ' . $e->getMessage()
- );
- }
-
-
- try {
- Circles::levelMember(
- $circle->getId(), Env::ENV_TEST_OWNER1, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_MEMBER
- );
- $this->assertSame(true, false, 'should return an exception');
- } catch (MemberIsNotModeratorException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false,
- 'should have returned a MemberIsNotModeratorException - ' . $e->getMessage()
- );
- }
- }
-
- Env::logout();
- }
-
-
- /**
- * Testing Leveling Members in Personal Circle.
- *
- * @throws Exception
- */
- public function testLevelMemberInPersonalCircle() {
- Env::setUser(Env::ENV_TEST_OWNER1);
-
- try {
- $this->generateSimpleCircleWithAllLevel($this->circles['Personal']->getId());
- $this->assertSame(true, false, 'should return an exception');
- } catch (CircleTypeNotValidException $e) {
- } catch (Exception $e) {
- $this->assertSame(true, false, 'should have returned a CircleTypeNotValid');
- }
-
- Env::logout();
- }
-
-
- /**
- * Testing creation of a circle with duplicate name as the owner.
- */
- public function testCreateCircleWithDuplicate() {
- Env::setUser(Env::ENV_TEST_OWNER1);
-
- $circleNames = [
- self::NAME_PUBLIC_CIRCLE1,
- self::NAME_SECRET_CIRCLE1,
- self::NAME_CLOSED_CIRCLE1
- ];
-
- for ($i = 0; $i < sizeof(Env::listCircleTypes()); $i++) {
- if (Env::listCircleTypes()[$i] === DeprecatedCircle::CIRCLES_PERSONAL) {
- try {
- Circles::createCircle(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1);
- $this->assertSame(true, false, 'should return an exception');
- } catch (CircleAlreadyExistsException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a CircleAlreadyExistsException'
- );
- }
- } else {
- for ($j = 0; $j < sizeof($circleNames); $j++) {
- try {
- Circles::createCircle(Env::listCircleTypes()[$i], $circleNames[$j]);
- $this->assertSame(true, false, 'should return an exception');
- } catch (CircleAlreadyExistsException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a CircleAlreadyExistsException'
- );
- }
- }
- }
- }
-
- Env::logout();
- }
-
-
- /**
- * Testing creation of a circle with duplicate name as a new owner.
- */
- public function testCreateCircleWithDuplicateFromOthers() {
- Env::setUser(Env::ENV_TEST_OWNER2);
-
- $circleNames = [
- self::NAME_PUBLIC_CIRCLE1,
- self::NAME_SECRET_CIRCLE1,
- self::NAME_CLOSED_CIRCLE1,
- ];
-
- $circles = [];
- array_push(
- $circles, Circles::createCircle(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1)
- );
-
- for ($i = 0; $i < sizeof(Env::listCircleTypes()); $i++) {
- for ($j = 0; $j < sizeof($circleNames); $j++) {
- if (Env::listCircleTypes()[$i] === DeprecatedCircle::CIRCLES_PERSONAL) {
- try {
- array_push(
- $circles, Circles::createCircle(
- Env::listCircleTypes()[$i], $circleNames[$j]
- )
- );
- } catch (Exception $e) {
- throw $e;
- }
- } else {
- try {
- Circles::createCircle(Env::listCircleTypes()[$i], $circleNames[$j]);
- $this->assertSame(
- true, false, 'should return an exception'
- );
- } catch (CircleAlreadyExistsException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false,
- 'should have returned a CircleAlreadyExistsException'
- );
- }
- }
- }
- }
-
- foreach ($circles as $circle) {
- Circles::destroyCircle($circle->getId());
- }
-
- Env::logout();
- }
-
-
- /**
- * In this test, we will add user to circle, check their level and rights and remove them
- * before checking their rights again.
- */
- public function testAddAndRemoveUser() {
- Env::setUser(Env::ENV_TEST_OWNER1);
-
- for ($i = 0; $i < 3; $i++) {
- foreach ($this->circles as $circle) {
- try {
- $member = Circles::getMember(
- $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
- );
- $this->assertEquals(
- [
- Env::ENV_TEST_MEMBER2, DeprecatedMember::LEVEL_NONE, DeprecatedMember::STATUS_NONMEMBER,
- $circle->getId()
- ]
- , [
- $member->getUserId(), $member->getLevel(), $member->getStatus(),
- $member->getCircleId()
- ]
- );
- } catch (MemberDoesNotExistException $e) {
- } catch (Exception $e) {
- throw $e;
- }
-
-
- try {
- Circles::addMember($circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER);
-
- // If Closed, we check that the user is not a member before confirming
- // the invitation using member account
- if ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED) {
- $member = Circles::getMember(
- $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
- );
- $this->assertEquals(
- [
- Env::ENV_TEST_MEMBER2, DeprecatedMember::LEVEL_NONE, DeprecatedMember::STATUS_INVITED,
- $circle->getId()
- ]
- , [
- $member->getUserId(), $member->getLevel(), $member->getStatus(),
- $member->getCircleId()
- ]
- );
-
- Env::setUser(Env::ENV_TEST_MEMBER2);
- Circles::joinCircle($circle->getId());
- Env::setUser(Env::ENV_TEST_OWNER1);
- }
-
- $member = Circles::getMember(
- $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
- );
- $this->assertEquals(
- [
- Env::ENV_TEST_MEMBER2, DeprecatedMember::LEVEL_MEMBER, DeprecatedMember::STATUS_MEMBER,
- $circle->getId()
- ]
- , [
- $member->getUserId(), $member->getLevel(), $member->getStatus(),
- $member->getCircleId()
- ]
- );
-
-
- Circles::removeMember(
- $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
- );
-
- try {
- $member = Circles::getMember(
- $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
- );
- $this->assertEquals(
- [
- Env::ENV_TEST_MEMBER2, DeprecatedMember::LEVEL_NONE, DeprecatedMember::STATUS_NONMEMBER,
- $circle->getId()
- ]
- , [
- $member->getUserId(), $member->getLevel(), $member->getStatus(),
- $member->getCircleId()
- ]
- );
- } catch (MemberDoesNotExistException $e) {
- }
- } catch (Exception $e) {
- throw $e;
- }
- }
- }
-
- Env::logout();
- }
-
-
- /**
- * We check the join/leave and the rights of a member during the process.
- *
- * @throws Exception
- */
- public function testJoinCircleAndLeave() {
- Env::setUser(Env::ENV_TEST_MEMBER3);
-
- for ($i = 0; $i < 3; $i++) {
- foreach ($this->circles as $circle) {
- try {
- $member = Circles::getMember(
- $circle->getId(), Env::ENV_TEST_MEMBER3, DeprecatedMember::TYPE_USER
- );
- $this->assertEquals(
- [
- Env::ENV_TEST_MEMBER3, DeprecatedMember::LEVEL_NONE, DeprecatedMember::STATUS_NONMEMBER,
- $circle->getId()
- ]
- , [
- $member->getUserId(), $member->getLevel(), $member->getStatus(),
- $member->getCircleId()
- ]
- );
- } catch (MemberDoesNotExistException $e) {
- if ($circle->getType() === DeprecatedCircle::CIRCLES_PERSONAL) {
- throw $e;
- }
- } catch (CircleDoesNotExistException $f) {
- if ($circle->getType() !== DeprecatedCircle::CIRCLES_PERSONAL) {
- throw $f;
- }
- } catch (Exception $e) {
- throw $e;
- }
-
-
- if ($circle->getType() === DeprecatedCircle::CIRCLES_PERSONAL) {
- try {
- Circles::joinCircle($circle->getId());
- $this->assertSame(
- true, false, 'should return an exception'
- );
- } catch (CircleDoesNotExistException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a CircleDoesNotExistException'
- );
- }
- } else {
- Circles::joinCircle($circle->getId());
-
-
- try {
-
- // If Closed, we check that the user is not a member before accepting
- // the request using a moderator account
- if ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED) {
- Env::setUser(Env::ENV_TEST_OWNER1);
- $member = Circles::getMember(
- $circle->getId(), Env::ENV_TEST_MEMBER3, DeprecatedMember::TYPE_USER
- );
- $this->assertEquals(
- [
- Env::ENV_TEST_MEMBER3, DeprecatedMember::LEVEL_NONE,
- DeprecatedMember::STATUS_REQUEST,
- $circle->getId()
- ]
- , [
- $member->getUserId(), $member->getLevel(), $member->getStatus(),
- $member->getCircleId()
- ]
- );
-
- Circles::addMember($circle->getId(), Env::ENV_TEST_MEMBER3, DeprecatedMember::TYPE_USER);
- Env::setUser(Env::ENV_TEST_MEMBER3);
- }
-
- $member = Circles::getMember(
- $circle->getId(), Env::ENV_TEST_MEMBER3, DeprecatedMember::TYPE_USER
- );
- $this->assertEquals(
- [
- Env::ENV_TEST_MEMBER3, DeprecatedMember::LEVEL_MEMBER, DeprecatedMember::STATUS_MEMBER,
- $circle->getId()
- ]
- , [
- $member->getUserId(), $member->getLevel(), $member->getStatus(),
- $member->getCircleId()
- ]
- );
- } catch (Exception $e) {
- throw $e;
- }
-
- Circles::leaveCircle($circle->getId());
-
- // We check the member have no access to the circle
- try {
- Circles::getMember(
- $circle->getId(), Env::ENV_TEST_MEMBER3, DeprecatedMember::TYPE_USER
- );
- $this->assertSame(
- true, false, 'should return an exception'
- );
- } catch (MemberDoesNotExistException $e) {
- } catch (Exception $e) {
- $this->assertSame(
- true, false, 'should have returned a MemberDoesNotExistException'
- );
- }
-
- // 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, DeprecatedMember::TYPE_USER
- );
- $this->assertEquals(
- [
- Env::ENV_TEST_MEMBER3, DeprecatedMember::LEVEL_NONE, DeprecatedMember::STATUS_NONMEMBER,
- $circle->getId()
- ]
- , [
- $member->getUserId(), $member->getLevel(), $member->getStatus(),
- $member->getCircleId()
- ]
- );
- } catch (MemberDoesNotExistException $e) {
- } catch (Exception $e) {
- throw $e;
- }
- Env::setUser(Env::ENV_TEST_MEMBER3);
- }
- }
- }
-
- Env::logout();
- }
-
-
- /**
- * Listing Circles, as a non-member and as a member
- */
- public function testListCircles() {
-
- // First, we check from an outside PoV, user is not in any circles right now.
- Env::setUser(Env::ENV_TEST_MEMBER1);
-
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_ALL);
- $this->assertCount(2, $listing);
-
- $result = [];
- foreach ($listing as $circle) {
- array_push($result, $circle->getName());
- }
-
- $this->assertEquals($result, [self::NAME_PUBLIC_CIRCLE1, self::NAME_CLOSED_CIRCLE1]);
-
-
- // Let's add user to all circle
- Env::setUser(Env::ENV_TEST_OWNER1);
- $circles = [$this->circles['Public'], $this->circles['Closed'], $this->circles['Secret']];
- foreach ($circles as $circle) {
- $this->generateSimpleCircleWithAllLevel(
- $circle->getId(), ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED)
- );
- }
-
-
- // Let's check from an owner PoV
- Env::setUser(Env::ENV_TEST_OWNER1);
-
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_ALL);
- $this->assertCount(4, $listing);
-
- $result = [];
- foreach ($listing as $circle) {
- array_push($result, $circle->getName());
- }
-
- $this->assertEquals(
- $result, [
- self::NAME_PUBLIC_CIRCLE1,
- self::NAME_SECRET_CIRCLE1,
- self::NAME_CLOSED_CIRCLE1,
- self::NAME_PERSONAL_CIRCLE1
- ]
- );
-
-
- // check from a member PoV
- Env::setUser(Env::ENV_TEST_MEMBER1);
-
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_ALL);
- $this->assertCount(3, $listing);
-
- $result = [];
- foreach ($listing as $circle) {
- array_push($result, $circle->getName());
- }
-
- $this->assertEquals(
- $result, [
- self::NAME_PUBLIC_CIRCLE1,
- self::NAME_SECRET_CIRCLE1,
- self::NAME_CLOSED_CIRCLE1
- ]
- );
-
-
- // member with a dedicated search on secret
- Env::setUser(Env::ENV_TEST_MEMBER1);
-
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE1);
- $this->assertCount(1, $listing);
-
- // member with a search on secret
- Env::setUser(Env::ENV_TEST_MEMBER1);
-
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, '');
- $this->assertCount(1, $listing);
-
- // removing member from Circle
- Env::setUser(Env::ENV_TEST_OWNER1);
- Circles::removeMember(
- $this->circles['Secret']->getId(), Env::ENV_TEST_MEMBER1, DeprecatedMember::TYPE_USER
- );
-
- // member with a search on secret
- Env::setUser(Env::ENV_TEST_MEMBER1);
-
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, '');
- $this->assertCount(0, $listing);
-
- // non-member with a dedicated search on secret
- Env::setUser(Env::ENV_TEST_MEMBER2);
-
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE1);
- $this->assertCount(1, $listing);
-
- // member with a dedicated search on personal
- Env::setUser(Env::ENV_TEST_MEMBER1);
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1);
- $this->assertCount(0, $listing);
-
- // non-member with a dedicated search on personal
- Env::setUser(Env::ENV_TEST_MEMBER2);
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1);
- $this->assertCount(0, $listing);
-
- // few request as another Owner on secret
- Env::SetUser(Env::ENV_TEST_OWNER2);
- $circle = Circles::createCircle(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE2);
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, '');
- $this->assertCount(1, $listing);
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE1);
- $this->assertCount(1, $listing);
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE2);
- $this->assertCount(1, $listing);
- Circles::destroyCircle($circle->getId());
-
- // few request as another Owner on personal
- Env::SetUser(Env::ENV_TEST_OWNER2);
- $circle = Circles::createCircle(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE2);
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_PERSONAL, '');
- $this->assertCount(1, $listing);
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1);
- $this->assertCount(0, $listing);
- $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE2);
- $this->assertCount(1, $listing);
- Circles::destroyCircle($circle->getId());
-
- Env::logout();
- }
-
-
- public function testDetailsCircle() {
- }
-
-
- /**
- * function to generate admin/moderator/member and assigning them their level.
- *
- * @param $circleId
- * @param bool $isClosed
- *
- * @throws QueryException
- */
- protected function generateSimpleCircleWithAllLevel($circleId, $isClosed = false) {
- $curr = Env::currentUser();
-
- Circles::addMember($circleId, Env::ENV_TEST_ADMIN1, DeprecatedMember::TYPE_USER);
- if ($isClosed) {
- Env::setUser(Env::ENV_TEST_ADMIN1);
- Circles::joinCircle($circleId);
- Env::setUser($curr);
- }
- Circles::levelMember(
- $circleId, Env::ENV_TEST_ADMIN1, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_ADMIN
- );
-
-
- Circles::addMember($circleId, Env::ENV_TEST_MODERATOR1, DeprecatedMember::TYPE_USER);
- if ($isClosed) {
- Env::setUser(Env::ENV_TEST_MODERATOR1);
- Circles::joinCircle($circleId);
- Env::setUser($curr);
- }
- Circles::levelMember(
- $circleId, Env::ENV_TEST_MODERATOR1, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_MODERATOR
- );
-
- Circles::addMember($circleId, Env::ENV_TEST_MEMBER1, DeprecatedMember::TYPE_USER);
- if ($isClosed) {
- Env::setUser(Env::ENV_TEST_MEMBER1);
- Circles::joinCircle($circleId);
- Env::setUser($curr);
- }
- Circles::levelMember(
- $circleId, Env::ENV_TEST_MEMBER1, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_MEMBER
- );
- }
+// protected function setUp(): void {
+// Env::setUser(Env::ENV_TEST_OWNER1);
+//
+// $this->circles = [];
+// try {
+// $this->circles = [
+// 'Public' =>
+// Circles::createCircle(DeprecatedCircle::CIRCLES_PUBLIC, self::NAME_PUBLIC_CIRCLE1),
+// 'Secret' =>
+// Circles::createCircle(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE1),
+// 'Closed' =>
+// Circles::createCircle(DeprecatedCircle::CIRCLES_CLOSED, self::NAME_CLOSED_CIRCLE1),
+// 'Personal' =>
+// Circles::createCircle(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1)
+// ];
+// } catch (Exception $e) {
+// throw $e;
+// }
+//
+// Env::logout();
+// }
+//
+//
+// /**
+// * tearDown() is initiated after each test.
+// *
+// * Function will destroy the circles created in setUp()
+// *
+// * @throws Exception
+// */
+// protected function tearDown(): void {
+// Env::setUser(Env::ENV_TEST_OWNER1);
+// try {
+// foreach ($this->circles as $circle) {
+// Circles::destroyCircle($circle->getId());
+// }
+// } catch (Exception $e) {
+// throw $e;
+// }
+//
+// Env::logout();
+// }
+//
+//
+// /**
+// * Testing Circles::version()
+// */
+// public function testVersion() {
+// $this->assertSame(Circles::version(), Circles::API_VERSION);
+// }
+//
+//
+// /**
+// * Testing the tools to switch users
+// */
+// public function testUserSession() {
+// Env::setUser(Env::ENV_TEST_ADMIN1);
+// $this->assertEquals(Env::currentUser(), Env::ENV_TEST_ADMIN1);
+// Env::setUser(Env::ENV_TEST_OWNER3);
+// try {
+// $this->assertEquals(Env::currentUser(), Env::ENV_TEST_ADMIN1);
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (Exception $e) {
+// }
+// Env::setUser(Env::ENV_TEST_OWNER1);
+// $this->assertEquals(Env::currentUser(), Env::ENV_TEST_OWNER1);
+// }
+//
+// /**
+// * Testing Leveling Members. (not in Personal Circle)
+// *
+// * @throws Exception
+// */
+// public function testLevelMemberInCircles() {
+// Env::setUser(Env::ENV_TEST_OWNER1);
+//
+// $circles = [$this->circles['Public'], $this->circles['Closed'], $this->circles['Secret']];
+//
+// // OWNER1 Should be able to add/level anyone to Admin Level at least
+// try {
+// foreach ($circles as $circle) {
+// $this->generateSimpleCircleWithAllLevel(
+// $circle->getId(), ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED)
+// );
+// }
+// } catch (Exception $e) {
+// throw $e;
+// }
+//
+// Env::logout();
+//
+//
+// // ADMIN1 should be able to add/level anyone to Moderator level
+// Env::setUser(Env::ENV_TEST_ADMIN1);
+//
+// try {
+// foreach ($circles as $circle) {
+// Circles::addMember($circle->getId(), Env::ENV_TEST_ADMIN2, DeprecatedMember::TYPE_USER);
+//
+// if ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED) {
+// // In closed circle, we need to confirm the invitation
+// Env::setUser(Env::ENV_TEST_ADMIN2);
+// Circles::joinCircle($circle->getId());
+// Env::setUser(Env::ENV_TEST_ADMIN1);
+// }
+//
+// Circles::levelMember(
+// $circle->getId(), Env::ENV_TEST_ADMIN2, DeprecatedMember::TYPE_USER,
+// DeprecatedMember::LEVEL_MODERATOR
+// );
+// }
+// } catch (Exception $e) {
+// throw $e;
+// }
+// Env::logout();
+//
+//
+// // ADMIN1 should not be able to level anyone to Admin Level
+// Env::setUser(Env::ENV_TEST_ADMIN1);
+//
+// foreach ($circles as $circle) {
+// try {
+// Circles::levelMember(
+// $circle->getId(), Env::ENV_TEST_ADMIN3, DeprecatedMember::TYPE_USER,
+// DeprecatedMember::LEVEL_MODERATOR
+// );
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (MemberDoesNotExistException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a MemberDoesNotExistException'
+// );
+// }
+//
+// try {
+// Circles::levelMember(
+// $circle->getId(), Env::ENV_TEST_ADMIN2, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_ADMIN
+// );
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (ModeratorIsNotHighEnoughException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a ModeratorIsNotHighEnoughException'
+// );
+// }
+//
+// try {
+// Circles::levelMember(
+// $circle->getId(), Env::ENV_TEST_ADMIN2, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_OWNER
+// );
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (MemberIsNotOwnerException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a MemberIsNotOwnerException'
+// );
+// }
+// }
+//
+// Env::logout();
+//
+//
+// // MODERATOR1 should be able to add anyone
+// Env::setUser(Env::ENV_TEST_MODERATOR1);
+//
+// try {
+// foreach ($circles as $circle) {
+// Circles::addMember($circle->getId(), Env::ENV_TEST_MODERATOR2, DeprecatedMember::TYPE_USER);
+// if ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED) {
+// // In closed circle, we need to confirm the invitation
+// Env::setUser(Env::ENV_TEST_MODERATOR2);
+// Circles::joinCircle($circle->getId());
+// Env::setUser(Env::ENV_TEST_MODERATOR1);
+// }
+// }
+// } catch (Exception $e) {
+// throw $e;
+// }
+//
+// Env::logout();
+//
+//
+// // MODERATOR1 should not be able to add/level anyone to Moderator/Admin Level
+// Env::setUser(Env::ENV_TEST_MODERATOR1);
+//
+// foreach ($circles as $circle) {
+// try {
+// Circles::levelMember(
+// $circle->getId(), Env::ENV_TEST_MODERATOR2, DeprecatedMember::TYPE_USER,
+// DeprecatedMember::LEVEL_MODERATOR
+// );
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (ModeratorIsNotHighEnoughException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a ModeratorIsNotHighEnoughException'
+// );
+// }
+// try {
+// Circles::levelMember(
+// $circle->getId(), Env::ENV_TEST_MODERATOR2, DeprecatedMember::TYPE_USER,
+// DeprecatedMember::LEVEL_ADMIN
+// );
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (ModeratorIsNotHighEnoughException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a ModeratorIsNotHighEnoughException'
+// );
+// }
+// try {
+// Circles::levelMember(
+// $circle->getId(), Env::ENV_TEST_MODERATOR2, DeprecatedMember::TYPE_USER,
+// DeprecatedMember::LEVEL_OWNER
+// );
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (MemberIsNotOwnerException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a MemberIsNotOwnerException'
+// );
+// }
+// }
+//
+// Env::logout();
+//
+//
+// // MEMBER1 should not be able to add/level anyone to any level
+// Env::setUser(Env::ENV_TEST_MEMBER1);
+//
+// foreach ($circles as $circle) {
+// try {
+// Circles::addMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
+// );
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (MemberIsNotModeratorException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a MemberIsNotModeratorException'
+// );
+// }
+//
+// try {
+// Circles::levelMember(
+// $circle->getId(), Env::ENV_TEST_USER1, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_MEMBER
+// );
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (MemberDoesNotExistException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a MemberDoesNotExistException'
+// );
+// }
+//
+// try {
+// Circles::levelMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER1, DeprecatedMember::TYPE_USER,
+// DeprecatedMember::LEVEL_MODERATOR
+// );
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (MemberIsNotModeratorException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false,
+// 'should have returned a MemberIsNotModeratorException - ' . $e->getMessage()
+// );
+// }
+//
+//
+// try {
+// Circles::levelMember(
+// $circle->getId(), Env::ENV_TEST_OWNER1, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_MEMBER
+// );
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (MemberIsNotModeratorException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false,
+// 'should have returned a MemberIsNotModeratorException - ' . $e->getMessage()
+// );
+// }
+// }
+//
+// Env::logout();
+// }
+//
+//
+// /**
+// * Testing Leveling Members in Personal Circle.
+// *
+// * @throws Exception
+// */
+// public function testLevelMemberInPersonalCircle() {
+// Env::setUser(Env::ENV_TEST_OWNER1);
+//
+// try {
+// $this->generateSimpleCircleWithAllLevel($this->circles['Personal']->getId());
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (CircleTypeNotValidException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(true, false, 'should have returned a CircleTypeNotValid');
+// }
+//
+// Env::logout();
+// }
+//
+//
+// /**
+// * Testing creation of a circle with duplicate name as the owner.
+// */
+// public function testCreateCircleWithDuplicate() {
+// Env::setUser(Env::ENV_TEST_OWNER1);
+//
+// $circleNames = [
+// self::NAME_PUBLIC_CIRCLE1,
+// self::NAME_SECRET_CIRCLE1,
+// self::NAME_CLOSED_CIRCLE1
+// ];
+//
+// for ($i = 0; $i < sizeof(Env::listCircleTypes()); $i++) {
+// if (Env::listCircleTypes()[$i] === DeprecatedCircle::CIRCLES_PERSONAL) {
+// try {
+// Circles::createCircle(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1);
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (CircleAlreadyExistsException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a CircleAlreadyExistsException'
+// );
+// }
+// } else {
+// for ($j = 0; $j < sizeof($circleNames); $j++) {
+// try {
+// Circles::createCircle(Env::listCircleTypes()[$i], $circleNames[$j]);
+// $this->assertSame(true, false, 'should return an exception');
+// } catch (CircleAlreadyExistsException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a CircleAlreadyExistsException'
+// );
+// }
+// }
+// }
+// }
+//
+// Env::logout();
+// }
+//
+//
+// /**
+// * Testing creation of a circle with duplicate name as a new owner.
+// */
+// public function testCreateCircleWithDuplicateFromOthers() {
+// Env::setUser(Env::ENV_TEST_OWNER2);
+//
+// $circleNames = [
+// self::NAME_PUBLIC_CIRCLE1,
+// self::NAME_SECRET_CIRCLE1,
+// self::NAME_CLOSED_CIRCLE1,
+// ];
+//
+// $circles = [];
+// array_push(
+// $circles, Circles::createCircle(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1)
+// );
+//
+// for ($i = 0; $i < sizeof(Env::listCircleTypes()); $i++) {
+// for ($j = 0; $j < sizeof($circleNames); $j++) {
+// if (Env::listCircleTypes()[$i] === DeprecatedCircle::CIRCLES_PERSONAL) {
+// try {
+// array_push(
+// $circles, Circles::createCircle(
+// Env::listCircleTypes()[$i], $circleNames[$j]
+// )
+// );
+// } catch (Exception $e) {
+// throw $e;
+// }
+// } else {
+// try {
+// Circles::createCircle(Env::listCircleTypes()[$i], $circleNames[$j]);
+// $this->assertSame(
+// true, false, 'should return an exception'
+// );
+// } catch (CircleAlreadyExistsException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false,
+// 'should have returned a CircleAlreadyExistsException'
+// );
+// }
+// }
+// }
+// }
+//
+// foreach ($circles as $circle) {
+// Circles::destroyCircle($circle->getId());
+// }
+//
+// Env::logout();
+// }
+//
+//
+// /**
+// * In this test, we will add user to circle, check their level and rights and remove them
+// * before checking their rights again.
+// */
+// public function testAddAndRemoveUser() {
+// Env::setUser(Env::ENV_TEST_OWNER1);
+//
+// for ($i = 0; $i < 3; $i++) {
+// foreach ($this->circles as $circle) {
+// try {
+// $member = Circles::getMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
+// );
+// $this->assertEquals(
+// [
+// Env::ENV_TEST_MEMBER2, DeprecatedMember::LEVEL_NONE, DeprecatedMember::STATUS_NONMEMBER,
+// $circle->getId()
+// ]
+// , [
+// $member->getUserId(), $member->getLevel(), $member->getStatus(),
+// $member->getCircleId()
+// ]
+// );
+// } catch (MemberDoesNotExistException $e) {
+// } catch (Exception $e) {
+// throw $e;
+// }
+//
+//
+// try {
+// Circles::addMember($circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER);
+//
+// // If Closed, we check that the user is not a member before confirming
+// // the invitation using member account
+// if ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED) {
+// $member = Circles::getMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
+// );
+// $this->assertEquals(
+// [
+// Env::ENV_TEST_MEMBER2, DeprecatedMember::LEVEL_NONE, DeprecatedMember::STATUS_INVITED,
+// $circle->getId()
+// ]
+// , [
+// $member->getUserId(), $member->getLevel(), $member->getStatus(),
+// $member->getCircleId()
+// ]
+// );
+//
+// Env::setUser(Env::ENV_TEST_MEMBER2);
+// Circles::joinCircle($circle->getId());
+// Env::setUser(Env::ENV_TEST_OWNER1);
+// }
+//
+// $member = Circles::getMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
+// );
+// $this->assertEquals(
+// [
+// Env::ENV_TEST_MEMBER2, DeprecatedMember::LEVEL_MEMBER, DeprecatedMember::STATUS_MEMBER,
+// $circle->getId()
+// ]
+// , [
+// $member->getUserId(), $member->getLevel(), $member->getStatus(),
+// $member->getCircleId()
+// ]
+// );
+//
+//
+// Circles::removeMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
+// );
+//
+// try {
+// $member = Circles::getMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER2, DeprecatedMember::TYPE_USER
+// );
+// $this->assertEquals(
+// [
+// Env::ENV_TEST_MEMBER2, DeprecatedMember::LEVEL_NONE, DeprecatedMember::STATUS_NONMEMBER,
+// $circle->getId()
+// ]
+// , [
+// $member->getUserId(), $member->getLevel(), $member->getStatus(),
+// $member->getCircleId()
+// ]
+// );
+// } catch (MemberDoesNotExistException $e) {
+// }
+// } catch (Exception $e) {
+// throw $e;
+// }
+// }
+// }
+//
+// Env::logout();
+// }
+//
+//
+// /**
+// * We check the join/leave and the rights of a member during the process.
+// *
+// * @throws Exception
+// */
+// public function testJoinCircleAndLeave() {
+// Env::setUser(Env::ENV_TEST_MEMBER3);
+//
+// for ($i = 0; $i < 3; $i++) {
+// foreach ($this->circles as $circle) {
+// try {
+// $member = Circles::getMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER3, DeprecatedMember::TYPE_USER
+// );
+// $this->assertEquals(
+// [
+// Env::ENV_TEST_MEMBER3, DeprecatedMember::LEVEL_NONE, DeprecatedMember::STATUS_NONMEMBER,
+// $circle->getId()
+// ]
+// , [
+// $member->getUserId(), $member->getLevel(), $member->getStatus(),
+// $member->getCircleId()
+// ]
+// );
+// } catch (MemberDoesNotExistException $e) {
+// if ($circle->getType() === DeprecatedCircle::CIRCLES_PERSONAL) {
+// throw $e;
+// }
+// } catch (CircleDoesNotExistException $f) {
+// if ($circle->getType() !== DeprecatedCircle::CIRCLES_PERSONAL) {
+// throw $f;
+// }
+// } catch (Exception $e) {
+// throw $e;
+// }
+//
+//
+// if ($circle->getType() === DeprecatedCircle::CIRCLES_PERSONAL) {
+// try {
+// Circles::joinCircle($circle->getId());
+// $this->assertSame(
+// true, false, 'should return an exception'
+// );
+// } catch (CircleDoesNotExistException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a CircleDoesNotExistException'
+// );
+// }
+// } else {
+// Circles::joinCircle($circle->getId());
+//
+//
+// try {
+//
+// // If Closed, we check that the user is not a member before accepting
+// // the request using a moderator account
+// if ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED) {
+// Env::setUser(Env::ENV_TEST_OWNER1);
+// $member = Circles::getMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER3, DeprecatedMember::TYPE_USER
+// );
+// $this->assertEquals(
+// [
+// Env::ENV_TEST_MEMBER3, DeprecatedMember::LEVEL_NONE,
+// DeprecatedMember::STATUS_REQUEST,
+// $circle->getId()
+// ]
+// , [
+// $member->getUserId(), $member->getLevel(), $member->getStatus(),
+// $member->getCircleId()
+// ]
+// );
+//
+// Circles::addMember($circle->getId(), Env::ENV_TEST_MEMBER3, DeprecatedMember::TYPE_USER);
+// Env::setUser(Env::ENV_TEST_MEMBER3);
+// }
+//
+// $member = Circles::getMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER3, DeprecatedMember::TYPE_USER
+// );
+// $this->assertEquals(
+// [
+// Env::ENV_TEST_MEMBER3, DeprecatedMember::LEVEL_MEMBER, DeprecatedMember::STATUS_MEMBER,
+// $circle->getId()
+// ]
+// , [
+// $member->getUserId(), $member->getLevel(), $member->getStatus(),
+// $member->getCircleId()
+// ]
+// );
+// } catch (Exception $e) {
+// throw $e;
+// }
+//
+// Circles::leaveCircle($circle->getId());
+//
+// // We check the member have no access to the circle
+// try {
+// Circles::getMember(
+// $circle->getId(), Env::ENV_TEST_MEMBER3, DeprecatedMember::TYPE_USER
+// );
+// $this->assertSame(
+// true, false, 'should return an exception'
+// );
+// } catch (MemberDoesNotExistException $e) {
+// } catch (Exception $e) {
+// $this->assertSame(
+// true, false, 'should have returned a MemberDoesNotExistException'
+// );
+// }
+//
+// // 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, DeprecatedMember::TYPE_USER
+// );
+// $this->assertEquals(
+// [
+// Env::ENV_TEST_MEMBER3, DeprecatedMember::LEVEL_NONE, DeprecatedMember::STATUS_NONMEMBER,
+// $circle->getId()
+// ]
+// , [
+// $member->getUserId(), $member->getLevel(), $member->getStatus(),
+// $member->getCircleId()
+// ]
+// );
+// } catch (MemberDoesNotExistException $e) {
+// } catch (Exception $e) {
+// throw $e;
+// }
+// Env::setUser(Env::ENV_TEST_MEMBER3);
+// }
+// }
+// }
+//
+// Env::logout();
+// }
+//
+//
+// /**
+// * Listing Circles, as a non-member and as a member
+// */
+// public function testListCircles() {
+//
+// // First, we check from an outside PoV, user is not in any circles right now.
+// Env::setUser(Env::ENV_TEST_MEMBER1);
+//
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_ALL);
+// $this->assertCount(2, $listing);
+//
+// $result = [];
+// foreach ($listing as $circle) {
+// array_push($result, $circle->getName());
+// }
+//
+// $this->assertEquals($result, [self::NAME_PUBLIC_CIRCLE1, self::NAME_CLOSED_CIRCLE1]);
+//
+//
+// // Let's add user to all circle
+// Env::setUser(Env::ENV_TEST_OWNER1);
+// $circles = [$this->circles['Public'], $this->circles['Closed'], $this->circles['Secret']];
+// foreach ($circles as $circle) {
+// $this->generateSimpleCircleWithAllLevel(
+// $circle->getId(), ($circle->getType() === DeprecatedCircle::CIRCLES_CLOSED)
+// );
+// }
+//
+//
+// // Let's check from an owner PoV
+// Env::setUser(Env::ENV_TEST_OWNER1);
+//
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_ALL);
+// $this->assertCount(4, $listing);
+//
+// $result = [];
+// foreach ($listing as $circle) {
+// array_push($result, $circle->getName());
+// }
+//
+// $this->assertEquals(
+// $result, [
+// self::NAME_PUBLIC_CIRCLE1,
+// self::NAME_SECRET_CIRCLE1,
+// self::NAME_CLOSED_CIRCLE1,
+// self::NAME_PERSONAL_CIRCLE1
+// ]
+// );
+//
+//
+// // check from a member PoV
+// Env::setUser(Env::ENV_TEST_MEMBER1);
+//
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_ALL);
+// $this->assertCount(3, $listing);
+//
+// $result = [];
+// foreach ($listing as $circle) {
+// array_push($result, $circle->getName());
+// }
+//
+// $this->assertEquals(
+// $result, [
+// self::NAME_PUBLIC_CIRCLE1,
+// self::NAME_SECRET_CIRCLE1,
+// self::NAME_CLOSED_CIRCLE1
+// ]
+// );
+//
+//
+// // member with a dedicated search on secret
+// Env::setUser(Env::ENV_TEST_MEMBER1);
+//
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE1);
+// $this->assertCount(1, $listing);
+//
+// // member with a search on secret
+// Env::setUser(Env::ENV_TEST_MEMBER1);
+//
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, '');
+// $this->assertCount(1, $listing);
+//
+// // removing member from Circle
+// Env::setUser(Env::ENV_TEST_OWNER1);
+// Circles::removeMember(
+// $this->circles['Secret']->getId(), Env::ENV_TEST_MEMBER1, DeprecatedMember::TYPE_USER
+// );
+//
+// // member with a search on secret
+// Env::setUser(Env::ENV_TEST_MEMBER1);
+//
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, '');
+// $this->assertCount(0, $listing);
+//
+// // non-member with a dedicated search on secret
+// Env::setUser(Env::ENV_TEST_MEMBER2);
+//
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE1);
+// $this->assertCount(1, $listing);
+//
+// // member with a dedicated search on personal
+// Env::setUser(Env::ENV_TEST_MEMBER1);
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1);
+// $this->assertCount(0, $listing);
+//
+// // non-member with a dedicated search on personal
+// Env::setUser(Env::ENV_TEST_MEMBER2);
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1);
+// $this->assertCount(0, $listing);
+//
+// // few request as another Owner on secret
+// Env::SetUser(Env::ENV_TEST_OWNER2);
+// $circle = Circles::createCircle(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE2);
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, '');
+// $this->assertCount(1, $listing);
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE1);
+// $this->assertCount(1, $listing);
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_SECRET, self::NAME_SECRET_CIRCLE2);
+// $this->assertCount(1, $listing);
+// Circles::destroyCircle($circle->getId());
+//
+// // few request as another Owner on personal
+// Env::SetUser(Env::ENV_TEST_OWNER2);
+// $circle = Circles::createCircle(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE2);
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_PERSONAL, '');
+// $this->assertCount(1, $listing);
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE1);
+// $this->assertCount(0, $listing);
+// $listing = Circles::listCircles(DeprecatedCircle::CIRCLES_PERSONAL, self::NAME_PERSONAL_CIRCLE2);
+// $this->assertCount(1, $listing);
+// Circles::destroyCircle($circle->getId());
+//
+// Env::logout();
+// }
+//
+//
+// public function testDetailsCircle() {
+// }
+//
+//
+// /**
+// * function to generate admin/moderator/member and assigning them their level.
+// *
+// * @param $circleId
+// * @param bool $isClosed
+// *
+// * @throws QueryException
+// */
+// protected function generateSimpleCircleWithAllLevel($circleId, $isClosed = false) {
+// $curr = Env::currentUser();
+//
+// Circles::addMember($circleId, Env::ENV_TEST_ADMIN1, DeprecatedMember::TYPE_USER);
+// if ($isClosed) {
+// Env::setUser(Env::ENV_TEST_ADMIN1);
+// Circles::joinCircle($circleId);
+// Env::setUser($curr);
+// }
+// Circles::levelMember(
+// $circleId, Env::ENV_TEST_ADMIN1, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_ADMIN
+// );
+//
+//
+// Circles::addMember($circleId, Env::ENV_TEST_MODERATOR1, DeprecatedMember::TYPE_USER);
+// if ($isClosed) {
+// Env::setUser(Env::ENV_TEST_MODERATOR1);
+// Circles::joinCircle($circleId);
+// Env::setUser($curr);
+// }
+// Circles::levelMember(
+// $circleId, Env::ENV_TEST_MODERATOR1, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_MODERATOR
+// );
+//
+// Circles::addMember($circleId, Env::ENV_TEST_MEMBER1, DeprecatedMember::TYPE_USER);
+// if ($isClosed) {
+// Env::setUser(Env::ENV_TEST_MEMBER1);
+// Circles::joinCircle($circleId);
+// Env::setUser($curr);
+// }
+// Circles::levelMember(
+// $circleId, Env::ENV_TEST_MEMBER1, DeprecatedMember::TYPE_USER, DeprecatedMember::LEVEL_MEMBER
+// );
+// }
}
diff --git a/tests/unit/lib/Controller/AdminControllerTest.php b/tests/unit/lib/Controller/AdminControllerTest.php
index 5564ad790..fd9fe1273 100644
--- a/tests/unit/lib/Controller/AdminControllerTest.php
+++ b/tests/unit/lib/Controller/AdminControllerTest.php
@@ -111,10 +111,13 @@ public function testCirclesList(int $limit, int $offset): void {
->setItemsLimit($limit);
$circle1 = new Circle();
$circle1->setName('Circle One');
+ $circle1->setSingleId('CircleOne');
$circle2 = new Circle();
$circle2->setName('Circle Two');
+ $circle2->setSingleId('CircleTwo');
$circle3 = new Circle();
$circle3->setName('Circle Three');
+ $circle3->setSingleId('CircleThree');
$circles = [$circle1, $circle2, $circle3];
$selectedCircles = array_slice($circles, $offset, $limit > 0 ? $limit : null);
$this->circleService->expects($this->once())->method('getCircles')->with($probe)->willReturn($selectedCircles);
diff --git a/tests/unit/lib/Controller/LocalControllerTest.php b/tests/unit/lib/Controller/LocalControllerTest.php
index 80b36343a..7fe43e178 100644
--- a/tests/unit/lib/Controller/LocalControllerTest.php
+++ b/tests/unit/lib/Controller/LocalControllerTest.php
@@ -106,10 +106,13 @@ public function testCirclesList(int $limit, int $offset): void {
->setItemsLimit($limit);
$circle1 = new Circle();
$circle1->setName('Circle One');
+ $circle1->setSingleId('CircleOne');
$circle2 = new Circle();
$circle2->setName('Circle Two');
+ $circle2->setSingleId('CircleTwo');
$circle3 = new Circle();
$circle3->setName('Circle Three');
+ $circle3->setSingleId('CircleThree');
$circles = [$circle1, $circle2, $circle3];
$selectedCircles = array_slice($circles, $offset, $limit > 0 ? $limit : null);
$this->circleService->expects($this->once())->method('getCircles')->with($probe)->willReturn($selectedCircles);