3 * this test tests the expand_acl function
8 /** required, it is the file under test */
9 require_once('include/text.php');
12 * TestCase for the expand_acl function
14 * @author Alexander Kampmann
17 class ExpandAclTest extends PHPUnit_Framework_TestCase {
20 * test expand_acl, perfect input
22 public function testExpandAclNormal() {
24 $this->assertEquals(array(1, 2, 3), expand_acl($text));
28 * test with a big number
30 public function testExpandAclBigNumber() {
31 $text='<1><'.PHP_INT_MAX.'><15>';
32 $this->assertEquals(array(1, PHP_INT_MAX, 15), expand_acl($text));
36 * test with a string in it.
38 * TODO: is this valid input? Otherwise: should there be an exception?
40 public function testExpandAclString() {
41 $text="<1><279012><tt>";
42 $this->assertEquals(array(1, 279012), expand_acl($text));
46 * test with a ' ' in it.
48 * TODO: is this valid input? Otherwise: should there be an exception?
50 public function testExpandAclSpace() {
51 $text="<1><279 012><32>";
52 $this->assertEquals(array(1, "279", "32"), expand_acl($text));
58 public function testExpandAclEmpty() {
60 $this->assertEquals(array(), expand_acl($text));
64 * test invalid input, no < at all
66 * TODO: should there be an exception?
68 public function testExpandAclNoBrackets() {
69 $text="According to documentation, that's invalid. "; //should be invalid
70 $this->assertEquals(array(), expand_acl($text));
74 * test invalid input, just open <
76 * TODO: should there be an exception?
78 public function testExpandAclJustOneBracket1() {
79 $text="<Another invalid string"; //should be invalid
80 $this->assertEquals(array(), expand_acl($text));
84 * test invalid input, just close >
86 * TODO: should there be an exception?
88 public function testExpandAclJustOneBracket2() {
89 $text="Another invalid> string"; //should be invalid
90 $this->assertEquals(array(), expand_acl($text));
94 * test invalid input, just close >
96 * TODO: should there be an exception?
98 public function testExpandAclCloseOnly() {
99 $text="Another> invalid> string>"; //should be invalid
100 $this->assertEquals(array(), expand_acl($text));
104 * test invalid input, just open <
106 * TODO: should there be an exception?
108 public function testExpandAclOpenOnly() {
109 $text="<Another< invalid string<"; //should be invalid
110 $this->assertEquals(array(), expand_acl($text));
114 * test invalid input, open and close do not match
116 * TODO: should there be an exception?
118 public function testExpandAclNoMatching1() {
119 $text="<Another<> invalid <string>"; //should be invalid
120 $this->assertEquals(array(), expand_acl($text));
124 * test invalid input, open and close do not match
126 * TODO: should there be an exception?
128 public function testExpandAclNoMatching2() {
130 // The angles are delimiters which aren't important
131 // the important thing is the numeric content, this returns array(1,2,3) currently
132 // we may wish to eliminate 2 from the results, though it isn't harmful
133 // It would be a better test to figure out if there is any ACL input which can
134 // produce this $text and fix that instead.
135 // $this->assertEquals(array(), expand_acl($text));
139 * test invalid input, empty <>
141 * TODO: should there be an exception? Or array(1, 3)
142 * (This should be array(1,3) - mike)
144 public function testExpandAclEmptyMatch() {
146 $this->assertEquals(array(1,3), expand_acl($text));