2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-03-18 17:55:58 +00:00
|
|
|
* AclComponentTest file
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-10-03 12:31:21 -04:00
|
|
|
* PHP 5
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-05-18 22:15:13 -03:00
|
|
|
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
|
2011-05-29 17:31:39 -04:00
|
|
|
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-10-03 12:31:21 -04:00
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2011-05-29 17:31:39 -04:00
|
|
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-05-18 22:15:13 -03:00
|
|
|
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
|
2011-07-26 01:46:14 -04:30
|
|
|
* @package Cake.Test.Case.Controller.Component
|
2008-10-30 17:30:26 +00:00
|
|
|
* @since CakePHP(tm) v 1.2.0.5435
|
2010-10-03 12:27:27 -04:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-03-05 17:40:42 -04:30
|
|
|
App::uses('AclComponent', 'Controller/Component');
|
|
|
|
class_exists('AclComponent');
|
2009-07-24 21:18:37 +02:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
2011-09-13 21:25:50 -04:00
|
|
|
* Test Case for AclComponent
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2011-07-26 01:46:14 -04:30
|
|
|
* @package Cake.Test.Case.Controller.Component
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
|
|
|
class AclComponentTest extends CakeTestCase {
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
2010-09-25 21:36:49 -04:00
|
|
|
* setUp method
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 22:02:32 +02:00
|
|
|
public function setUp() {
|
2010-09-25 21:36:49 -04:00
|
|
|
parent::setUp();
|
2010-06-10 20:17:35 -04:30
|
|
|
if (!class_exists('MockAclImplementation', false)) {
|
|
|
|
$this->getMock('AclInterface', array(), array(), 'MockAclImplementation');
|
|
|
|
}
|
2010-04-23 23:59:57 -04:00
|
|
|
Configure::write('Acl.classname', 'MockAclImplementation');
|
2010-07-04 18:41:08 -04:00
|
|
|
$Collection = new ComponentCollection();
|
|
|
|
$this->Acl = new AclComponent($Collection);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 21:18:37 +02:00
|
|
|
|
2009-03-18 17:55:58 +00:00
|
|
|
/**
|
|
|
|
* tearDown method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 22:02:32 +02:00
|
|
|
public function tearDown() {
|
2010-09-25 21:36:49 -04:00
|
|
|
parent::tearDown();
|
2009-03-18 17:55:58 +00:00
|
|
|
unset($this->Acl);
|
|
|
|
}
|
2009-07-24 21:18:37 +02:00
|
|
|
|
2010-04-23 23:03:51 -04:00
|
|
|
/**
|
2011-04-17 12:35:21 +02:00
|
|
|
* test that construtor throws an exception when Acl.classname is a
|
2010-04-23 23:03:51 -04:00
|
|
|
* non-existant class
|
|
|
|
*
|
2010-12-11 19:01:07 -05:00
|
|
|
* @expectedException CakeException
|
2010-04-23 23:03:51 -04:00
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 22:02:32 +02:00
|
|
|
public function testConstrutorException() {
|
2010-04-23 23:03:51 -04:00
|
|
|
Configure::write('Acl.classname', 'AclClassNameThatDoesNotExist');
|
2010-07-04 18:41:08 -04:00
|
|
|
$Collection = new ComponentCollection();
|
|
|
|
$acl = new AclComponent($Collection);
|
2010-04-23 23:03:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test that adapter() allows control of the interal implementation AclComponent uses.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 22:02:32 +02:00
|
|
|
public function testAdapter() {
|
2010-04-23 23:59:57 -04:00
|
|
|
$implementation = new MockAclImplementation();
|
2010-06-10 20:17:35 -04:30
|
|
|
$implementation->expects($this->once())->method('initialize')->with($this->Acl);
|
2010-04-23 23:03:51 -04:00
|
|
|
$this->assertNull($this->Acl->adapter($implementation));
|
|
|
|
|
|
|
|
$this->assertEqual($this->Acl->adapter(), $implementation, 'Returned object is different %s');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test that adapter() whines when the class is not an AclBase
|
|
|
|
*
|
2010-12-11 19:01:07 -05:00
|
|
|
* @expectedException CakeException
|
2010-04-23 23:03:51 -04:00
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 22:02:32 +02:00
|
|
|
public function testAdapterException() {
|
2010-04-23 23:03:51 -04:00
|
|
|
$thing = new StdClass();
|
|
|
|
$this->Acl->adapter($thing);
|
|
|
|
}
|
|
|
|
|
2010-04-23 23:52:36 -04:00
|
|
|
}
|