]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Util/ACLFormaterTest.php
Check null for acl-fields
[friendica.git] / tests / src / Util / ACLFormaterTest.php
index c3cfb705146c3635da84fbd8195c4fc741bffbce..ac5b25e6c26346c6a1e50acba0dd28d969c6490b 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Friendica\Test\src\Util;
 
+use Error;
 use Friendica\Model\Group;
 use Friendica\Util\ACLFormatter;
 use PHPUnit\Framework\TestCase;
@@ -161,4 +162,52 @@ class ACLFormaterTest extends TestCase
                $text="<1><><3>";
                $this->assertEquals(array('1', '3'), $aclFormatter->expand($text));
        }
+
+       /**
+        * Test expected exception in case of wrong typehint
+        *
+        * @expectedException Error
+        */
+       public function testExpandNull()
+       {
+               $aclFormatter = new ACLFormatter();
+
+               $aclFormatter->expand(null);
+       }
+
+       public function dataAclToString()
+       {
+               return [
+                       'empty'   => [
+                               'input'  => '',
+                               'assert' => '',
+                       ],
+                       'string'  => [
+                               'input'  => '1,2,3,4',
+                               'assert' => '<1><2><3><4>',
+                       ],
+                       'array'   => [
+                               'input'  => [1, 2, 3, 4],
+                               'assert' => '<1><2><3><4>',
+                       ],
+                       'invalid' => [
+                               'input'  => [1, 'a', 3, 4],
+                               'assert' => '<1><3><4>',
+                       ],
+                       'invalidString' => [
+                               'input'  => 'a,bsd23,4',
+                               'assert' => '<4>',
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider dataAclToString
+        */
+       public function testAclToString($input, string $assert)
+       {
+               $aclFormatter = new ACLFormatter();
+
+               $this->assertEquals($assert, $aclFormatter->toString($input));
+       }
 }