Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
15403 manish.sha 1
<?php
2
/**
3
 * ControllerTestCaseTest file
4
 *
5
 * Test Case for ControllerTestCase class
6
 *
7
 * CakePHP : Rapid Development Framework (http://cakephp.org)
8
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
9
 *
10
 * Licensed under The MIT License
11
 * For full copyright and license information, please see the LICENSE.txt
12
 * Redistributions of files must retain the above copyright notice.
13
 *
14
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
15
 * @link          http://cakephp.org CakePHP Project
16
 * @package       Cake.Test.Case.Event
17
 * @since         CakePHP v 2.1
18
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
19
 */
20
 
21
App::uses('CakeEvent', 'Event');
22
 
23
/**
24
 * Tests the CakeEvent class functionality
25
 *
26
 */
27
class CakeEventTest extends CakeTestCase {
28
 
29
/**
30
 * Tests the name() method
31
 *
32
 * @return void
33
 * @triggers fake.event
34
 */
35
	public function testName() {
36
		$event = new CakeEvent('fake.event');
37
		$this->assertEquals('fake.event', $event->name());
38
	}
39
 
40
/**
41
 * Tests the subject() method
42
 *
43
 * @return void
44
 * @triggers fake.event $this
45
 * @triggers fake.event
46
 */
47
	public function testSubject() {
48
		$event = new CakeEvent('fake.event', $this);
49
		$this->assertSame($this, $event->subject());
50
 
51
		$event = new CakeEvent('fake.event');
52
		$this->assertNull($event->subject());
53
	}
54
 
55
/**
56
 * Tests the event propagation stopping property
57
 *
58
 * @return void
59
 * @triggers fake.event
60
 */
61
	public function testPropagation() {
62
		$event = new CakeEvent('fake.event');
63
		$this->assertFalse($event->isStopped());
64
		$event->stopPropagation();
65
		$this->assertTrue($event->isStopped());
66
	}
67
 
68
/**
69
 * Tests that it is possible to get/set custom data in a event
70
 *
71
 * @return void
72
 * @triggers fake.event $this, array('some' => 'data')
73
 */
74
	public function testEventData() {
75
		$event = new CakeEvent('fake.event', $this, array('some' => 'data'));
76
		$this->assertEquals(array('some' => 'data'), $event->data);
77
	}
78
 
79
/**
80
 * Tests that it is possible to get the name and subject directly
81
 *
82
 * @return void
83
 * @triggers fake.event $this
84
 */
85
	public function testEventDirectPropertyAccess() {
86
		$event = new CakeEvent('fake.event', $this);
87
		$this->assertEquals($this, $event->subject);
88
		$this->assertEquals('fake.event', $event->name);
89
	}
90
}