diff options
author | Fabio Comuni <fabrix.xm@gmail.com> | 2012-03-19 12:24:40 +0100 |
---|---|---|
committer | Fabio Comuni <fabrix.xm@gmail.com> | 2012-03-19 12:24:40 +0100 |
commit | ea4be0db89b5e95b50211e023e94aa008aadae46 (patch) | |
tree | 2d0654cae606cb3e543463e5569c2b2e689e45d6 /tests/expand_acl_test.php | |
parent | c30342e2f7bde6fda899193f97ce3051cd8b2fdd (diff) | |
parent | 2349852b4abd1638624b541f173f51d1fb1ea011 (diff) | |
download | volse-hubzilla-ea4be0db89b5e95b50211e023e94aa008aadae46.tar.gz volse-hubzilla-ea4be0db89b5e95b50211e023e94aa008aadae46.tar.bz2 volse-hubzilla-ea4be0db89b5e95b50211e023e94aa008aadae46.zip |
Merge remote-tracking branch 'friendica/master'
Diffstat (limited to 'tests/expand_acl_test.php')
-rwxr-xr-x | tests/expand_acl_test.php | 142 |
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 |