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
\r
14 * @author Alexander Kampmann
\r
15 * @package test.util
\r
17 class ExpandAclTest extends PHPUnit_Framework_TestCase {
20 * test expand_acl, perfect input
\r
22 public function testExpandAclNormal() {
\r
24 $this->assertEquals(array(1, 2, 3), expand_acl($text));
\r
28 * test with a big number
30 public function testExpandAclBigNumber() {
\r
31 $text='<1><'.PHP_INT_MAX.'><15>';
\r
32 $this->assertEquals(array(1, PHP_INT_MAX, 15), expand_acl($text));
\r
36 * test with a string in it.
38 * TODO: is this valid input? Otherwise: should there be an exception?
40 public function testExpandAclString() {
\r
41 $text="<1><279012><tt>";
\r
42 $this->assertEquals(array(1, 279012), expand_acl($text));
\r
46 * test with a ' ' in it.
48 * TODO: is this valid input? Otherwise: should there be an exception?
50 public function testExpandAclSpace() {
\r
51 $text="<1><279 012><32>";
\r
52 $this->assertEquals(array(1, "279", "32"), expand_acl($text));
\r
58 public function testExpandAclEmpty() {
\r
60 $this->assertEquals(array(), expand_acl($text));
\r
64 * test invalid input, no < at all
66 * TODO: should there be an exception?
68 public function testExpandAclNoBrackets() {
\r
69 $text="According to documentation, that's invalid. "; //should be invalid
\r
70 $this->assertEquals(array(), expand_acl($text));
\r
74 * test invalid input, just open <
\r
76 * TODO: should there be an exception?
\r
78 public function testExpandAclJustOneBracket1() {
\r
79 $text="<Another invalid string"; //should be invalid
\r
80 $this->assertEquals(array(), expand_acl($text));
\r
84 * test invalid input, just close >
\r
86 * TODO: should there be an exception?
\r
88 public function testExpandAclJustOneBracket2() {
\r
89 $text="Another invalid> string"; //should be invalid
\r
90 $this->assertEquals(array(), expand_acl($text));
\r
94 * test invalid input, just close >
\r
96 * TODO: should there be an exception?
\r
98 public function testExpandAclCloseOnly() {
\r
99 $text="Another> invalid> string>"; //should be invalid
\r
100 $this->assertEquals(array(), expand_acl($text));
\r
104 * test invalid input, just open <
\r
106 * TODO: should there be an exception?
\r
108 public function testExpandAclOpenOnly() {
\r
109 $text="<Another< invalid string<"; //should be invalid
\r
110 $this->assertEquals(array(), expand_acl($text));
\r
114 * test invalid input, open and close do not match
\r
116 * TODO: should there be an exception?
\r
118 public function testExpandAclNoMatching1() {
\r
119 $text="<Another<> invalid <string>"; //should be invalid
\r
120 $this->assertEquals(array(), expand_acl($text));
\r
124 * test invalid input, open and close do not match
\r
126 * TODO: should there be an exception?
\r
128 public function testExpandAclNoMatching2() {
\r
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));
\r
139 * test invalid input, empty <>
\r
141 * TODO: should there be an exception? Or array(1, 3)
\r
142 * (This should be array(1,3) - mike)
144 public function testExpandAclEmptyMatch() {
\r
146 $this->assertEquals(array(1,3), expand_acl($text));
\r