diff options
author | Mario <mario@mariovavti.com> | 2023-07-20 09:05:42 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2023-07-20 09:05:42 +0000 |
commit | ca994735bee5f479d840da13674b38c40930ba98 (patch) | |
tree | b4ba1ef14653e4a9e8ccb4eee8ae63f42a9765f3 /tests | |
parent | 7200c716736d879501a665c9797ccf9e0131b24c (diff) | |
parent | 718c303086e6ab6061b2a920bd8293b2c0d11348 (diff) | |
download | volse-hubzilla-ca994735bee5f479d840da13674b38c40930ba98.tar.gz volse-hubzilla-ca994735bee5f479d840da13674b38c40930ba98.tar.bz2 volse-hubzilla-ca994735bee5f479d840da13674b38c40930ba98.zip |
Merge branch 'zotlabs/improve-access-list-type-safety' into 'dev'
Zotlabs: Improve type safety for AccessList class.
See merge request hubzilla/core!2052
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/Access/AccessListTest.php | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/tests/unit/Access/AccessListTest.php b/tests/unit/Access/AccessListTest.php index 2f185db17..635f09930 100644 --- a/tests/unit/Access/AccessListTest.php +++ b/tests/unit/Access/AccessListTest.php @@ -60,14 +60,24 @@ class AccessListTest extends UnitTestCase { } /** - * @expectedException PHPUnit\Framework\Error\Error + * AccessList constructor should throw an exception if input is not + * an array. */ -/* - public function testPHPErrorOnInvalidConstructor() { + public function testConstructorThrowsOnInvalidInputType() { + $this->expectException("TypeError"); $accessList = new AccessList('invalid'); - // Causes: "Illegal string offset 'channel_allow_cid'" } -*/ + + /** + * AccessList constructor should throw an exception on + * invalid input. + */ + public function testConstructorThrowsOnMissingKeysInArray() { + $this->expectException("Exception"); + $this->expectExceptionMessage("Invalid AccessList object"); + $accessList = new AccessList(['something_else' => 'should_this_fail?']); + } + /** * Test that the defaults are as expected when constructed with * an empty array. @@ -111,16 +121,22 @@ class AccessListTest extends UnitTestCase { } /** - * @expectedException PHPUnit\Framework\Error\Error + * The set method should throw an exception if input is not an array. */ -/* - public function testPHPErrorOnInvalidSet() { + public function testSetThrowsOnInvalidInputType() { + $this->expectException('TypeError'); $accessList = new AccessList([]); $accessList->set('invalid'); - // Causes: "Illegal string offset 'allow_cid'" } -*/ + + public function testSetThrowsOnMissingKeysInArray() { + $this->expectException('Exception'); + $this->expectExceptionMessage('Invalid AccessList object'); + + $accessList = new AccessList([]); + $accessList->set(['something_else' => 'should_this_fail?']); + } /** * The set_from_array() function calls some other functions, too which are |