+<?php
+/**
+ * this test tests the expand_acl function
+ *
+ * @package test.util
+ */
+
+/** required, it is the file under test */
+require_once('include/text.php');
+
+/**\r
+ * TestCase for the expand_acl function\r
+ *\r
+ * @author Alexander Kampmann\r
+ * @package test.util\r
+ */\r
+class ExpandAclTest extends PHPUnit_Framework_TestCase {
+
+ /**\r
+ * test expand_acl, perfect input\r
+ */\r
+ public function testExpandAclNormal() {\r
+ $text='<1><2><3>';\r
+ $this->assertEquals(array(1, 2, 3), expand_acl($text));\r
+ }\r
+
+ /**
+ * test with a big number
+ */\r
+ public function testExpandAclBigNumber() {\r
+ $text='<1><'.PHP_INT_MAX.'><15>';\r
+ $this->assertEquals(array(1, PHP_INT_MAX, 15), expand_acl($text));\r
+ }\r
+
+ /**
+ * test with a string in it.
+ *
+ * TODO: is this valid input? Otherwise: should there be an exception?
+ */\r
+ public function testExpandAclString() {\r
+ $text="<1><279012><tt>"; \r
+ $this->assertEquals(array(1, 279012, 'tt'), expand_acl($text));\r
+ }\r
+
+ /**
+ * test with a ' ' in it.
+ *
+ * TODO: is this valid input? Otherwise: should there be an exception?
+ */\r
+ public function testExpandAclSpace() {\r
+ $text="<1><279 012><32>"; \r
+ $this->assertEquals(array(1, "279 012", "32"), expand_acl($text));\r
+ }\r
+
+ /**
+ * test empty input
+ */\r
+ public function testExpandAclEmpty() {\r
+ $text=""; \r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
+
+ /**
+ * test invalid input, no < at all
+ *
+ * TODO: should there be an exception?
+ */\r
+ public function testExpandAclNoBrackets() {\r
+ $text="According to documentation, that's invalid. "; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
+
+ /**\r
+ * test invalid input, just open <\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclJustOneBracket1() {\r
+ $text="<Another invalid string"; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
+
+ /**\r
+ * test invalid input, just close >\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclJustOneBracket2() {\r
+ $text="Another invalid> string"; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
+
+ /**\r
+ * test invalid input, just close >\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclCloseOnly() {\r
+ $text="Another> invalid> string>"; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
+
+ /**\r
+ * test invalid input, just open <\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclOpenOnly() {\r
+ $text="<Another< invalid string<"; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
+
+ /**\r
+ * test invalid input, open and close do not match\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclNoMatching1() {\r
+ $text="<Another<> invalid <string>"; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
+
+ /**\r
+ * test invalid input, open and close do not match\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclNoMatching2() {\r
+ $text="<1>2><3>";\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }
+
+ /**\r
+ * test invalid input, empty <>\r
+ *\r
+ * TODO: should there be an exception? Or array(1, 3)\r
+ */\r
+ public function testExpandAclEmptyMatch() {\r
+ $text="<1><><3>";\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }
+}
\ No newline at end of file