IniAclTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * IniAclTest file.
  4. *
  5. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  6. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  7. *
  8. * Licensed under The MIT License
  9. * For full copyright and license information, please see the LICENSE.txt
  10. * Redistributions of files must retain the above copyright notice.
  11. *
  12. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  13. * @link http://cakephp.org CakePHP(tm) Project
  14. * @since 2.0.0
  15. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  16. */
  17. namespace Cake\Test\TestCase\Controller\Component\Acl;
  18. use Cake\Controller\Component\AclComponent;
  19. use Cake\Controller\Component\Acl\IniAcl;
  20. use Cake\TestSuite\TestCase;
  21. /**
  22. * Test case for the IniAcl implementation
  23. *
  24. */
  25. class IniAclTest extends TestCase {
  26. /**
  27. * testIniCheck method
  28. *
  29. * @return void
  30. */
  31. public function testCheck() {
  32. $iniFile = TEST_APP . 'TestApp/Config/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 = TEST_APP . 'TestApp/Config/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. }