aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/Access/AccessListTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/Access/AccessListTest.php')
-rw-r--r--tests/unit/Access/AccessListTest.php49
1 files changed, 34 insertions, 15 deletions
diff --git a/tests/unit/Access/AccessListTest.php b/tests/unit/Access/AccessListTest.php
index 3c8d3e859..2f185db17 100644
--- a/tests/unit/Access/AccessListTest.php
+++ b/tests/unit/Access/AccessListTest.php
@@ -34,10 +34,9 @@ use Zotlabs\Access\AccessList;
class AccessListTest extends UnitTestCase {
/**
- * @brief Expected result for most tests.
- * @var array
+ * Expected result for most tests.
*/
- protected $expectedResult = [
+ protected array $expectedResult = [
'allow_cid' => '<acid><acid2>',
'allow_gid' => '<agid>',
'deny_cid' => '',
@@ -69,23 +68,24 @@ class AccessListTest extends UnitTestCase {
// Causes: "Illegal string offset 'channel_allow_cid'"
}
*/
- public function testDefaultGetExplicit() {
+ /**
+ * Test that the defaults are as expected when constructed with
+ * an empty array.
+ */
+ public function testDefaults() {
$accessList = new AccessList([]);
$this->assertFalse($accessList->get_explicit());
- }
+ $this->assertFalse($accessList->is_private());
- public function testDefaultGet() {
- $arr = [
+ $expected = [
'allow_cid' => '',
'allow_gid' => '',
'deny_cid' => '',
'deny_gid' => ''
];
- $accessList = new AccessList([]);
-
- $this->assertEquals($arr, $accessList->get());
+ $this->assertEquals($expected, $accessList->get());
}
public function testSet() {
@@ -123,7 +123,9 @@ class AccessListTest extends UnitTestCase {
*/
/**
- * set_from_array() calls some other functions, too which are not yet unit tested.
+ * The set_from_array() function calls some other functions, too which are
+ * not yet unit tested.
+ *
* @uses ::perms2str
* @uses ::sanitise_acl
* @uses ::notags
@@ -158,12 +160,11 @@ class AccessListTest extends UnitTestCase {
}
/**
+ * The AccessList should be private if any of the fields are set,
+ *
* @dataProvider isprivateProvider
*/
public function testIsPrivate($channel) {
- $accessListPublic = new AccessList([]);
- $this->assertFalse($accessListPublic->is_private());
-
$accessListPrivate = new AccessList($channel);
$this->assertTrue($accessListPrivate->is_private());
}
@@ -176,12 +177,30 @@ class AccessListTest extends UnitTestCase {
'channel_deny_cid' => '<dcid>',
'channel_deny_gid' => '<dgid>'
]],
- 'only one set' => [[
+ 'only allow_cid set' => [[
'channel_allow_cid' => '<acid>',
'channel_allow_gid' => '',
'channel_deny_cid' => '',
'channel_deny_gid' => ''
]],
+ 'only allow_gid set' => [[
+ 'channel_allow_cid' => '',
+ 'channel_allow_gid' => '<agid>',
+ 'channel_deny_cid' => '',
+ 'channel_deny_gid' => ''
+ ]],
+ 'only deny_cid set' => [[
+ 'channel_allow_cid' => '',
+ 'channel_allow_gid' => '',
+ 'channel_deny_cid' => '<dcid>',
+ 'channel_deny_gid' => ''
+ ]],
+ 'only deny_gid set' => [[
+ 'channel_allow_cid' => '',
+ 'channel_allow_gid' => '',
+ 'channel_deny_cid' => '',
+ 'channel_deny_gid' => '<dgid>'
+ ]],
'acid+null' => [[
'channel_allow_cid' => '<acid>',
'channel_allow_gid' => null,