| 12345 |
anikendra |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* DebugKit Debugger Test Case File
|
|
|
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 debug_kit 0.1
|
|
|
16 |
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
|
|
17 |
**/
|
|
|
18 |
|
|
|
19 |
App::uses('DebugKitDebugger', 'DebugKit.Lib');
|
|
|
20 |
require_once CakePlugin::path('DebugKit') . 'Test' . DS . 'Case' . DS . 'TestFireCake.php';
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Test case for the DebugKitDebugger
|
|
|
24 |
*
|
|
|
25 |
* @since debug_kit 0.1
|
|
|
26 |
*/
|
|
|
27 |
class DebugKitDebuggerTest extends CakeTestCase {
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* setUp method
|
|
|
31 |
*
|
|
|
32 |
* @return void
|
|
|
33 |
*/
|
|
|
34 |
public function setUp() {
|
|
|
35 |
parent::setUp();
|
|
|
36 |
Configure::write('log', false);
|
|
|
37 |
$this->firecake = FireCake::getInstance('TestFireCake');
|
|
|
38 |
TestFireCake::reset();
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* tearDown method
|
|
|
43 |
*
|
|
|
44 |
* @return void
|
|
|
45 |
*/
|
|
|
46 |
public function tearDown() {
|
|
|
47 |
parent::tearDown();
|
|
|
48 |
Configure::write('log', true);
|
|
|
49 |
DebugKitDebugger::clearTimers();
|
|
|
50 |
TestFireCake::reset();
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* test output switch to firePHP
|
|
|
55 |
*
|
|
|
56 |
* @return void
|
|
|
57 |
*/
|
|
|
58 |
public function testOutput() {
|
|
|
59 |
Debugger::getInstance('DebugKitDebugger');
|
|
|
60 |
Debugger::addFormat('fb', array('callback' => 'DebugKitDebugger::fireError'));
|
|
|
61 |
Debugger::outputAs('fb');
|
|
|
62 |
|
|
|
63 |
set_error_handler('ErrorHandler::handleError');
|
|
|
64 |
$foo .= '';
|
|
|
65 |
restore_error_handler();
|
|
|
66 |
|
|
|
67 |
$result = $this->firecake->sentHeaders;
|
|
|
68 |
|
|
|
69 |
$this->assertRegExp('/GROUP_START/', $result['X-Wf-1-1-1-1']);
|
|
|
70 |
$this->assertRegExp('/ERROR/', $result['X-Wf-1-1-1-2']);
|
|
|
71 |
$this->assertRegExp('/GROUP_END/', $result['X-Wf-1-1-1-5']);
|
|
|
72 |
|
|
|
73 |
Debugger::getInstance('Debugger');
|
|
|
74 |
Debugger::outputAs('html');
|
|
|
75 |
}
|
|
|
76 |
}
|