aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/Lib/PermissionDescriptionTest.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-01-06 16:34:38 +0000
committerMario <mario@mariovavti.com>2024-01-06 16:34:38 +0000
commite3d30763dabdf12f961ed3d1d7cf4eaee44c65a9 (patch)
treeed3d493e8423ad9ccbde5e8e199e65164820e70f /tests/unit/Lib/PermissionDescriptionTest.php
parent6252340804bee66736e49de4bdc08755510f1c70 (diff)
downloadvolse-hubzilla-e3d30763dabdf12f961ed3d1d7cf4eaee44c65a9.tar.gz
volse-hubzilla-e3d30763dabdf12f961ed3d1d7cf4eaee44c65a9.tar.bz2
volse-hubzilla-e3d30763dabdf12f961ed3d1d7cf4eaee44c65a9.zip
tests: Integrate the DB in "unit" tests.
Diffstat (limited to 'tests/unit/Lib/PermissionDescriptionTest.php')
-rw-r--r--tests/unit/Lib/PermissionDescriptionTest.php47
1 files changed, 44 insertions, 3 deletions
diff --git a/tests/unit/Lib/PermissionDescriptionTest.php b/tests/unit/Lib/PermissionDescriptionTest.php
index 96c381d0c..fdd676f61 100644
--- a/tests/unit/Lib/PermissionDescriptionTest.php
+++ b/tests/unit/Lib/PermissionDescriptionTest.php
@@ -63,11 +63,52 @@ class PermissionDescriptionTest extends UnitTestCase {
$this->assertNotNull($permDescSelf);
}
+ /**
+ * Test fetching permission descriptions for the current channel.
+ */
public function testFromGlobalPermission() {
- //$permDesc = PermissionDescription::fromGlobalPermission('view_profile');
+ // Initiate the global App with a channel_id
+ \App::$channel = array(
+ 'channel_id' => 42,
+ );
+
+ // Make sure the requested permission is set for this channel.
+ \Zotlabs\Access\PermissionLimits::Set(
+ \App::$channel['channel_id'],
+ 'view_profile',
+ PERMS_NETWORK
+ );
+
+ \Zotlabs\Access\PermissionLimits::Set(
+ \App::$channel['channel_id'],
+ 'write_storage',
+ PERMS_SPECIFIC
+ );
+
+ // Set an invalid(?) permission
+ \Zotlabs\Access\PermissionLimits::Set(
+ \App::$channel['channel_id'],
+ 'view_wiki',
+ 1337
+ );
+
+ $permDesc = PermissionDescription::fromGlobalPermission('view_profile');
+ $this->assertEquals(
+ 'Anybody in the Hubzilla network',
+ $permDesc->get_permission_description()
+ );
+
+ $permDesc = PermissionDescription::fromGlobalPermission('write_storage');
+ $this->assertEquals(
+ 'Only connections I specifically allow',
+ $permDesc->get_permission_description()
+ );
- $this->markTestIncomplete(
- 'The method fromGlobalPermission() is not yet testable ...'
+ // Permissions we don't know about will get the fallback description.
+ $permDesc = PermissionDescription::fromGlobalPermission('view_wiki');
+ $this->assertEquals(
+ 'Visible to your default audience',
+ $permDesc->get_permission_description()
);
}