aboutsummaryrefslogtreecommitdiffstats
path: root/tests/expand_acl_test.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-03-14 15:16:30 -0700
committerfriendica <info@friendica.com>2012-03-14 15:16:30 -0700
commit531201f2a141e6a8dd606b9d1844de0806566294 (patch)
tree35e7aeb19ea515ce3a07b1587d6eb5fdf8215115 /tests/expand_acl_test.php
parent959aa13de01238b1500c7c351d565b9745e5bf0a (diff)
parent70709a882594250684c954a21d186877ea6f983c (diff)
downloadvolse-hubzilla-531201f2a141e6a8dd606b9d1844de0806566294.tar.gz
volse-hubzilla-531201f2a141e6a8dd606b9d1844de0806566294.tar.bz2
volse-hubzilla-531201f2a141e6a8dd606b9d1844de0806566294.zip
Merge pull request #132 from campino/master
Test cases
Diffstat (limited to 'tests/expand_acl_test.php')
-rwxr-xr-xtests/expand_acl_test.php142
1 files changed, 142 insertions, 0 deletions
diff --git a/tests/expand_acl_test.php b/tests/expand_acl_test.php
new file mode 100755
index 000000000..b516a3f14
--- /dev/null
+++ b/tests/expand_acl_test.php
@@ -0,0 +1,142 @@
+<?php
+/**
+ * this test tests the expand_acl function
+ *
+ * @package test.util
+ */
+
+/** required, it is the file under test */
+require_once('include/text.php');
+
+/**
+ * TestCase for the expand_acl function
+ *
+ * @author Alexander Kampmann
+ * @package test.util
+ */
+class ExpandAclTest extends PHPUnit_Framework_TestCase {
+
+ /**
+ * test expand_acl, perfect input
+ */
+ public function testExpandAclNormal() {
+ $text='<1><2><3>';
+ $this->assertEquals(array(1, 2, 3), expand_acl($text));
+ }
+
+ /**
+ * test with a big number
+ */
+ public function testExpandAclBigNumber() {
+ $text='<1><'.PHP_INT_MAX.'><15>';
+ $this->assertEquals(array(1, PHP_INT_MAX, 15), expand_acl($text));
+ }
+
+ /**
+ * test with a string in it.
+ *
+ * TODO: is this valid input? Otherwise: should there be an exception?
+ */
+ public function testExpandAclString() {
+ $text="<1><279012><tt>";
+ $this->assertEquals(array(1, 279012, 'tt'), expand_acl($text));
+ }
+
+ /**
+ * test with a ' ' in it.
+ *
+ * TODO: is this valid input? Otherwise: should there be an exception?
+ */
+ public function testExpandAclSpace() {
+ $text="<1><279 012><32>";
+ $this->assertEquals(array(1, "279 012", "32"), expand_acl($text));
+ }
+
+ /**
+ * test empty input
+ */
+ public function testExpandAclEmpty() {
+ $text="";
+ $this->assertEquals(array(), expand_acl($text));
+ }
+
+ /**
+ * test invalid input, no < at all
+ *
+ * TODO: should there be an exception?
+ */
+ public function testExpandAclNoBrackets() {
+ $text="According to documentation, that's invalid. "; //should be invalid
+ $this->assertEquals(array(), expand_acl($text));
+ }
+
+ /**
+ * test invalid input, just open <
+ *
+ * TODO: should there be an exception?
+ */
+ public function testExpandAclJustOneBracket1() {
+ $text="<Another invalid string"; //should be invalid
+ $this->assertEquals(array(), expand_acl($text));
+ }
+
+ /**
+ * test invalid input, just close >
+ *
+ * TODO: should there be an exception?
+ */
+ public function testExpandAclJustOneBracket2() {
+ $text="Another invalid> string"; //should be invalid
+ $this->assertEquals(array(), expand_acl($text));
+ }
+
+ /**
+ * test invalid input, just close >
+ *
+ * TODO: should there be an exception?
+ */
+ public function testExpandAclCloseOnly() {
+ $text="Another> invalid> string>"; //should be invalid
+ $this->assertEquals(array(), expand_acl($text));
+ }
+
+ /**
+ * test invalid input, just open <
+ *
+ * TODO: should there be an exception?
+ */
+ public function testExpandAclOpenOnly() {
+ $text="<Another< invalid string<"; //should be invalid
+ $this->assertEquals(array(), expand_acl($text));
+ }
+
+ /**
+ * test invalid input, open and close do not match
+ *
+ * TODO: should there be an exception?
+ */
+ public function testExpandAclNoMatching1() {
+ $text="<Another<> invalid <string>"; //should be invalid
+ $this->assertEquals(array(), expand_acl($text));
+ }
+
+ /**
+ * test invalid input, open and close do not match
+ *
+ * TODO: should there be an exception?
+ */
+ public function testExpandAclNoMatching2() {
+ $text="<1>2><3>";
+ $this->assertEquals(array(), expand_acl($text));
+ }
+
+ /**
+ * test invalid input, empty <>
+ *
+ * TODO: should there be an exception? Or array(1, 3)
+ */
+ public function testExpandAclEmptyMatch() {
+ $text="<1><><3>";
+ $this->assertEquals(array(), expand_acl($text));
+ }
+} \ No newline at end of file