Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13532 anikendra 1
<?php
2
/**
3
 * AclComponentTest file
4
 *
5
 * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
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://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
14
 * @package       Cake.Test.Case.Controller.Component
15
 * @since         CakePHP(tm) v 1.2.0.5435
16
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
17
 */
18
 
19
App::uses('AclComponent', 'Controller/Component');
20
class_exists('AclComponent');
21
 
22
/**
23
 * Test Case for AclComponent
24
 *
25
 * @package       Cake.Test.Case.Controller.Component
26
 */
27
class AclComponentTest extends CakeTestCase {
28
 
29
/**
30
 * setUp method
31
 *
32
 * @return void
33
 */
34
	public function setUp() {
35
		parent::setUp();
36
		if (!class_exists('MockAclImplementation', false)) {
37
			$this->getMock('AclInterface', array(), array(), 'MockAclImplementation');
38
		}
39
		Configure::write('Acl.classname', 'MockAclImplementation');
40
		$Collection = new ComponentCollection();
41
		$this->Acl = new AclComponent($Collection);
42
	}
43
 
44
/**
45
 * tearDown method
46
 *
47
 * @return void
48
 */
49
	public function tearDown() {
50
		parent::tearDown();
51
		unset($this->Acl);
52
	}
53
 
54
/**
55
 * test that constructor throws an exception when Acl.classname is a
56
 * non-existent class
57
 *
58
 * @expectedException CakeException
59
 * @return void
60
 */
61
	public function testConstrutorException() {
62
		Configure::write('Acl.classname', 'AclClassNameThatDoesNotExist');
63
		$Collection = new ComponentCollection();
64
		new AclComponent($Collection);
65
	}
66
 
67
/**
68
 * test that adapter() allows control of the internal implementation AclComponent uses.
69
 *
70
 * @return void
71
 */
72
	public function testAdapter() {
73
		$implementation = new MockAclImplementation();
74
		$implementation->expects($this->once())->method('initialize')->with($this->Acl);
75
		$this->assertNull($this->Acl->adapter($implementation));
76
 
77
		$this->assertEquals($this->Acl->adapter(), $implementation, 'Returned object is different %s');
78
	}
79
 
80
/**
81
 * test that adapter() whines when the class is not an AclBase
82
 *
83
 * @expectedException CakeException
84
 * @return void
85
 */
86
	public function testAdapterException() {
87
		$thing = new StdClass();
88
		$this->Acl->adapter($thing);
89
	}
90
 
91
}