| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- App::uses('Auth', 'Tools.Lib');
- App::uses('MyCakeTestCase', 'Tools.Lib');
- /**
- * 2010-06-29 ms
- */
- class AuthTest extends MyCakeTestCase {
- public function testHasRole() {
- $res = Auth::hasRole(1, array(2, 3, 6));
- $this->assertFalse($res);
-
- $res = Auth::hasRole(3, array(2, 3, 6));
- $this->assertTrue($res);
-
- $res = Auth::hasRole(3, 1);
- $this->assertFalse($res);
-
- $res = Auth::hasRole(3, '3');
- $this->assertTrue($res);
-
- $res = Auth::hasRole(3, '');
- $this->assertFalse($res);
- }
- public function testHasRoles() {
- $res = Auth::hasRoles(array(1, 3), true, array(2, 3, 6));
- $this->assertTrue($res);
- $res = Auth::hasRoles(array(3), true, array(2, 3, 6));
- $this->assertTrue($res);
- $res = Auth::hasRoles(array(), true, array(2, 3, 6));
- $this->assertFalse($res);
- $res = Auth::hasRoles(null, true, array(2, 3, 6));
- $this->assertFalse($res);
- $res = Auth::hasRoles(array(2, 7), false, array(2, 3, 6));
- $this->assertFalse($res);
- $res = Auth::hasRoles(array(2, 6), false, array(2, 3, 6));
- $this->assertTrue($res);
- $res = Auth::hasRoles(array(2, 6), true, array(2, 3, 6));
- $this->assertTrue($res);
- $res = Auth::hasRoles(array(9, 11), true, array());
- $this->assertFalse($res);
- $res = Auth::hasRoles(array(9, 11), true, '');
- $this->assertFalse($res);
- $res = Auth::hasRoles(array(2, 7), false, array());
- $this->assertFalse($res);
- $res = Auth::hasRoles(array(2, 7), false);
- $this->assertFalse($res);
- }
- }
|