Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12345 anikendra 1
<?php
2
/**
3
 * DebugKit TimedBehavior Test Case
4
 *
5
 * PHP 5
6
 *
7
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
8
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
9
 *
10
 * Licensed under The MIT License
11
 * Redistributions of files must retain the above copyright notice.
12
 *
13
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
14
 * @link          http://cakephp.org CakePHP(tm) Project
15
 * @since         DebugKit 1.3
16
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
17
 */
18
 
19
App::uses('DebugKitDebugger', 'DebugKit.Lib');
20
 
21
/**
22
 * Class TimedBehaviorTestCase
23
 *
24
 * @since         DebugKit 1.3
25
 */
26
class TimedBehaviorTestCase extends CakeTestCase {
27
 
28
/**
29
 * Fixtures
30
 *
31
 * @var array
32
 */
33
	public $fixtures = array('core.article');
34
 
35
/**
36
 * Start Test callback
37
 *
38
 * @return void
39
 */
40
	public function setUp() {
41
		parent::setUp();
42
		$this->Article = ClassRegistry::init('Article');
43
		$this->Article->Behaviors->attach('DebugKit.Timed');
44
	}
45
 
46
/**
47
 * End a test
48
 *
49
 * @return void
50
 */
51
	public function tearDown() {
52
		parent::tearDown();
53
		unset($this->Article);
54
		ClassRegistry::flush();
55
		DebugKitDebugger::clearTimers();
56
	}
57
 
58
/**
59
 * Test find timers
60
 *
61
 * @return void
62
 */
63
	public function testFindTimers() {
64
		$timers = DebugKitDebugger::getTimers(false);
65
		$this->assertEquals(count($timers), 1);
66
 
67
		$this->Article->find('all');
68
		$result = DebugKitDebugger::getTimers(false);
69
		$this->assertEquals(count($result), 2);
70
 
71
		$this->Article->find('all');
72
		$result = DebugKitDebugger::getTimers(false);
73
		$this->assertEquals(count($result), 3);
74
	}
75
 
76
/**
77
 * Test save timers
78
 *
79
 * @return void
80
 */
81
	public function testSaveTimers() {
82
		$timers = DebugKitDebugger::getTimers(false);
83
		$this->assertEquals(count($timers), 1);
84
 
85
		$this->Article->save(array('user_id' => 1, 'title' => 'test', 'body' => 'test'));
86
		$result = DebugKitDebugger::getTimers(false);
87
		$this->assertEquals(count($result), 2);
88
	}
89
}