Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13532 anikendra 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
 */
34
	public function testName() {
35
		$event = new CakeEvent('fake.event');
36
		$this->assertEquals('fake.event', $event->name());
37
	}
38
 
39
/**
40
 * Tests the subject() method
41
 *
42
 * @return void
43
 */
44
	public function testSubject() {
45
		$event = new CakeEvent('fake.event', $this);
46
		$this->assertSame($this, $event->subject());
47
 
48
		$event = new CakeEvent('fake.event');
49
		$this->assertNull($event->subject());
50
	}
51
 
52
/**
53
 * Tests the event propagation stopping property
54
 *
55
 * @return void
56
 */
57
	public function testPropagation() {
58
		$event = new CakeEvent('fake.event');
59
		$this->assertFalse($event->isStopped());
60
		$event->stopPropagation();
61
		$this->assertTrue($event->isStopped());
62
	}
63
 
64
/**
65
 * Tests that it is possible to get/set custom data in a event
66
 *
67
 * @return void
68
 */
69
	public function testEventData() {
70
		$event = new CakeEvent('fake.event', $this, array('some' => 'data'));
71
		$this->assertEquals(array('some' => 'data'), $event->data);
72
	}
73
 
74
/**
75
 * Tests that it is possible to get the name and subject directly
76
 *
77
 * @return void
78
 */
79
	public function testEventDirectPropertyAccess() {
80
		$event = new CakeEvent('fake.event', $this);
81
		$this->assertEquals($this, $event->subject);
82
		$this->assertEquals('fake.event', $event->name);
83
	}
84
}