Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12345 anikendra 1
<?php
2
/**
3
 * DebugKit Debug Memory Test Cases
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
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
16
 **/
17
 
18
App::uses('DebugMemory', 'DebugKit.Lib');
19
 
20
/**
21
 * Class DebugMemoryTest
22
 *
23
 */
24
class DebugMemoryTest extends CakeTestCase {
25
 
26
/**
27
 * test memory usage
28
 *
29
 * @return void
30
 */
31
	public function testMemoryUsage() {
32
		$result = DebugMemory::getCurrent();
33
		$this->assertTrue(is_int($result));
34
 
35
		$result = DebugMemory::getPeak();
36
		$this->assertTrue(is_int($result));
37
	}
38
 
39
/**
40
 * test making memory use markers.
41
 *
42
 * @return void
43
 */
44
	public function testMemorySettingAndGetting() {
45
		DebugMemory::clear();
46
		$result = DebugMemory::record('test marker');
47
		$this->assertTrue($result);
48
 
49
		$result = DebugMemory::getAll(true);
50
		$this->assertEquals(count($result), 1);
51
		$this->assertTrue(isset($result['test marker']));
52
		$this->assertTrue(is_numeric($result['test marker']));
53
 
54
		$result = DebugMemory::getAll();
55
		$this->assertTrue(empty($result));
56
 
57
		DebugMemory::record('test marker');
58
		DebugMemory::record('test marker');
59
		$result = DebugMemory::getAll();
60
 
61
		$this->assertEquals(count($result), 2);
62
		$this->assertTrue(isset($result['test marker']));
63
		$this->assertTrue(isset($result['test marker #2']));
64
	}
65
}