Skip to content

Commit 2345370

Browse files
committed
Fix failing tests and add a new test for object printing.
1 parent 2486e8b commit 2345370

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Test/Case/View/Helper/HtmlToolbarHelperTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public function testMakeNeatArray() {
165165
'ul' => array('class' => 'neat-array depth-0'),
166166
'<li', '<strong', 'key', '/strong', 'value', '/li',
167167
'<li', '<strong', 'foo', '/strong',
168+
'(array)',
168169
array('ul' => array('class' => 'neat-array depth-1')),
169170
'<li', '<strong', 'this', '/strong', 'deep', '/li',
170171
'<li', '<strong', 'another', '/strong', 'value', '/li',
@@ -190,12 +191,14 @@ public function testMakeNeatArray() {
190191
'ul' => array('class' => 'neat-array depth-0 expanded'),
191192
'<li', '<strong', 'key', '/strong', 'value', '/li',
192193
'<li', '<strong', 'foo', '/strong',
194+
'(array)',
193195
array('ul' => array('class' => 'neat-array depth-1')),
194196
'<li', '<strong', 'this', '/strong', 'deep', '/li',
195197
'<li', '<strong', 'another', '/strong', 'value', '/li',
196198
'/ul',
197199
'/li',
198200
'<li', '<strong', 'lotr', '/strong',
201+
'(array)',
199202
array('ul' => array('class' => 'neat-array depth-1')),
200203
'<li', '<strong', 'gandalf', '/strong', 'wizard', '/li',
201204
'<li', '<strong', 'bilbo', '/strong', 'hobbit', '/li',
@@ -210,12 +213,14 @@ public function testMakeNeatArray() {
210213
'ul' => array('class' => 'neat-array depth-0 expanded'),
211214
'<li', '<strong', 'key', '/strong', 'value', '/li',
212215
'<li', '<strong', 'foo', '/strong',
216+
'(array)',
213217
array('ul' => array('class' => 'neat-array depth-1 expanded')),
214218
'<li', '<strong', 'this', '/strong', 'deep', '/li',
215219
'<li', '<strong', 'another', '/strong', 'value', '/li',
216220
'/ul',
217221
'/li',
218222
'<li', '<strong', 'lotr', '/strong',
223+
'(array)',
219224
array('ul' => array('class' => 'neat-array depth-1 expanded')),
220225
'<li', '<strong', 'gandalf', '/strong', 'wizard', '/li',
221226
'<li', '<strong', 'bilbo', '/strong', 'hobbit', '/li',
@@ -236,6 +241,32 @@ public function testMakeNeatArray() {
236241
$this->assertTags($result, $expected);
237242
}
238243

244+
/**
245+
* Test makeNeatArray with object inputs.
246+
*
247+
* @return void
248+
*/
249+
public function testMakeNeatArrayObjects() {
250+
$in = new StdClass();
251+
$in->key = 'value';
252+
$in->nested = new StdClass();
253+
$in->nested->name = 'mark';
254+
255+
$result = $this->Toolbar->makeNeatArray($in);
256+
$expected = array(
257+
array('ul' => array('class' => 'neat-array depth-0')),
258+
'<li', '<strong', 'key', '/strong', 'value', '/li',
259+
'<li', '<strong', 'nested', '/strong',
260+
'(object)',
261+
array('ul' => array('class' => 'neat-array depth-1')),
262+
'<li', '<strong', 'name', '/strong', 'mark', '/li',
263+
'/ul',
264+
'/li',
265+
'/ul'
266+
);
267+
$this->assertTags($result, $expected);
268+
}
269+
239270
/**
240271
* Test injection of toolbar
241272
*

0 commit comments

Comments
 (0)