-
Notifications
You must be signed in to change notification settings - Fork 36
/
fire_php_toobar.test.php
129 lines (123 loc) · 3.46 KB
/
fire_php_toobar.test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* Toolbar Abstract Helper Test Case
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org
* @package debug_kit
* @subpackage debug_kit.tests.views.helpers
* @since DebugKit 0.1
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
**/
App::import('Helper', 'DebugKit.FirePhpToolbar');
App::import('Core', array('View', 'Controller'));
App::import('File', 'TestFireCake', false, Configure::read('pluginPaths'), 'test_objects.php');
FireCake::getInstance('TestFireCake');
class FirePhpToolbarHelperTestCase extends CakeTestCase {
/**
* setUp
*
* @return void
**/
function setUp() {
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::parse('/');
$this->Toolbar =& new ToolbarHelper(array('output' => 'DebugKit.FirePhpToolbar'));
$this->Toolbar->FirePhpToolbar =& new FirePhpToolbarHelper();
$this->Controller =& ClassRegistry::init('Controller');
if (isset($this->_debug)) {
Configure::write('debug', $this->_debug);
}
}
/**
* start Case - switch view paths
*
* @return void
**/
function startCase() {
$this->_viewPaths = Configure::read('viewPaths');
Configure::write('viewPaths', array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS,
APP . 'plugins' . DS . 'debug_kit' . DS . 'views'. DS,
ROOT . DS . LIBS . 'view' . DS
));
$this->_debug = Configure::read('debug');
$this->firecake =& FireCake::getInstance();
}
/**
* test neat array (dump)creation
*
* @return void
*/
function testMakeNeatArray() {
$this->Toolbar->makeNeatArray(array(1,2,3));
$result = $this->firecake->sentHeaders;
$this->assertTrue(isset($result['X-Wf-1-1-1-1']));
$this->assertPattern('/\[1,2,3\]/', $result['X-Wf-1-1-1-1']);
}
/**
* testAfterlayout element rendering
*
* @return void
*/
function testAfterLayout(){
$this->Controller->viewPath = 'posts';
$this->Controller->action = 'index';
$this->Controller->params = array(
'action' => 'index',
'controller' => 'posts',
'plugin' => null,
'url' => array('url' => 'posts/index', 'ext' => 'xml'),
'base' => null,
'here' => '/posts/index',
);
$this->Controller->layout = 'default';
$this->Controller->uses = null;
$this->Controller->components = array('DebugKit.Toolbar');
$this->Controller->constructClasses();
$this->Controller->Component->initialize($this->Controller);
$this->Controller->Component->startup($this->Controller);
$this->Controller->Component->beforeRender($this->Controller);
$result = $this->Controller->render();
$this->assertNoPattern('/debug-toolbar/', $result);
$result = $this->firecake->sentHeaders;
$this->assertTrue(is_array($result));
}
/**
* endTest()
*
* @return void
*/
function endTest() {
TestFireCake::reset();
}
/**
* reset the view paths
*
* @return void
**/
function endCase() {
Configure::write('viewPaths', $this->_viewPaths);
}
/**
* tearDown
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Toolbar, $this->Controller);
ClassRegistry::removeObject('view');
ClassRegistry::flush();
Router::reload();
}
}
?>