2012-04-16 02:54:13 +00:00
|
|
|
<?php
|
2011-10-10 21:18:48 +00:00
|
|
|
/**
|
|
|
|
* IniAclTest file.
|
|
|
|
*
|
|
|
|
* PHP 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
2013-02-08 11:59:49 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2011-10-10 21:18:48 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
2013-02-08 12:22:51 +00:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2011-10-10 21:18:48 +00:00
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2013-02-08 11:59:49 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2011-10-10 21:18:48 +00:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2012-02-23 18:45:32 +00:00
|
|
|
* @package Cake.Test.Case.Controller.Component.Acl
|
2011-10-10 21:18:48 +00:00
|
|
|
* @since CakePHP(tm) v 2.0
|
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
|
|
|
*/
|
2012-01-29 18:54:26 +00:00
|
|
|
App::uses('IniAcl', 'Controller/Component/Acl');
|
2011-09-14 01:25:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test case for the IniAcl implementation
|
|
|
|
*
|
2012-02-23 18:45:32 +00:00
|
|
|
* @package Cake.Test.Case.Controller.Component.Acl
|
2011-09-14 01:25:50 +00:00
|
|
|
*/
|
|
|
|
class IniAclTest extends CakeTestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* testIniCheck method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testCheck() {
|
2012-03-12 02:20:25 +00:00
|
|
|
$iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.ini.php';
|
2011-09-14 01:25:50 +00:00
|
|
|
|
|
|
|
$Ini = new IniAcl();
|
|
|
|
$Ini->config = $Ini->readConfigFile($iniFile);
|
|
|
|
|
|
|
|
$this->assertFalse($Ini->check('admin', 'ads'));
|
|
|
|
$this->assertTrue($Ini->check('admin', 'posts'));
|
|
|
|
|
|
|
|
$this->assertTrue($Ini->check('jenny', 'posts'));
|
|
|
|
$this->assertTrue($Ini->check('jenny', 'ads'));
|
|
|
|
|
|
|
|
$this->assertTrue($Ini->check('paul', 'posts'));
|
|
|
|
$this->assertFalse($Ini->check('paul', 'ads'));
|
|
|
|
|
|
|
|
$this->assertFalse($Ini->check('nobody', 'comments'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* check should accept a user array.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testCheckArray() {
|
2012-03-12 02:20:25 +00:00
|
|
|
$iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.ini.php';
|
2011-09-14 01:25:50 +00:00
|
|
|
|
|
|
|
$Ini = new IniAcl();
|
|
|
|
$Ini->config = $Ini->readConfigFile($iniFile);
|
|
|
|
$Ini->userPath = 'User.username';
|
|
|
|
|
|
|
|
$user = array(
|
|
|
|
'User' => array('username' => 'admin')
|
|
|
|
);
|
|
|
|
$this->assertTrue($Ini->check($user, 'posts'));
|
|
|
|
}
|
|
|
|
}
|