aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/Lib/PermissionDescriptionTest.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-01-06 16:34:39 +0000
committerMario <mario@mariovavti.com>2024-01-06 16:34:39 +0000
commita36de8ba1a27204667413760c53f783ba60f22a7 (patch)
treefa219c32ebe5d8cad86dccc6b26b04ed6c22145b /tests/unit/Lib/PermissionDescriptionTest.php
parentc73518d8ec562aed63223c668a43d9cda152cb9d (diff)
parente3d30763dabdf12f961ed3d1d7cf4eaee44c65a9 (diff)
downloadvolse-hubzilla-a36de8ba1a27204667413760c53f783ba60f22a7.tar.gz
volse-hubzilla-a36de8ba1a27204667413760c53f783ba60f22a7.tar.bz2
volse-hubzilla-a36de8ba1a27204667413760c53f783ba60f22a7.zip
Merge branch 'tests/fix-db-and-ci-integration' into 'dev'
tests: Integrate the DB in "unit" tests. See merge request hubzilla/core!2081
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()
);
}