IniAclTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * IniAclTest file.
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @package Cake.Test.Case.Controller.Component.Acl
  16. * @since CakePHP(tm) v 2.0
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. App::uses('IniAcl', 'Controller/Component/Acl');
  20. /**
  21. * Test case for the IniAcl implementation
  22. *
  23. * @package Cake.Test.Case.Controller.Component.Acl
  24. */
  25. class IniAclTest extends CakeTestCase {
  26. /**
  27. * testIniCheck method
  28. *
  29. * @return void
  30. */
  31. public function testCheck() {
  32. $iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.ini.php';
  33. $Ini = new IniAcl();
  34. $Ini->config = $Ini->readConfigFile($iniFile);
  35. $this->assertFalse($Ini->check('admin', 'ads'));
  36. $this->assertTrue($Ini->check('admin', 'posts'));
  37. $this->assertTrue($Ini->check('jenny', 'posts'));
  38. $this->assertTrue($Ini->check('jenny', 'ads'));
  39. $this->assertTrue($Ini->check('paul', 'posts'));
  40. $this->assertFalse($Ini->check('paul', 'ads'));
  41. $this->assertFalse($Ini->check('nobody', 'comments'));
  42. }
  43. /**
  44. * check should accept a user array.
  45. *
  46. * @return void
  47. */
  48. public function testCheckArray() {
  49. $iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.ini.php';
  50. $Ini = new IniAcl();
  51. $Ini->config = $Ini->readConfigFile($iniFile);
  52. $Ini->userPath = 'User.username';
  53. $user = array(
  54. 'User' => array('username' => 'admin')
  55. );
  56. $this->assertTrue($Ini->check($user, 'posts'));
  57. }
  58. }