Permalink
Browse files

Fix tableCells()

  • Loading branch information...
dereuromark committed May 2, 2015
1 parent 1cc7fce commit 4915e802c15a189bcb371d282c9dd881bf46dd6a
Showing with 24 additions and 2 deletions.
  1. +15 −0 lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
  2. +9 −2 lib/Cake/View/Helper/HtmlHelper.php
@@ -1926,6 +1926,21 @@ public function testTableCells() {
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false);
$expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
$this->assertEquals($expected, $result);
$tr = array(
'td content 1',
'td content 2',
array('td content 3', array('class' => 'foo'))
);
$result = $this->Html->tableCells($tr, null, null, true);
$expected = array(
'<tr',
array('td' => array('class' => 'column-1')), 'td content 1', '/td',
array('td' => array('class' => 'column-2')), 'td content 2', '/td',
array('td' => array('class' => 'foo column-3')), 'td content 3', '/td',
'/tr'
);
$this->assertTags($result, $expected);
}
/**
@@ -901,9 +901,16 @@ public function tableCells($data, $oddTrOptions = null, $evenTrOptions = null, $
if (is_array($cell)) {
$cellOptions = $cell[1];
$cell = $cell[0];
} elseif ($useCount) {
$cellOptions['class'] = 'column-' . ++$i;
}
if ($useCount) {
if (isset($cellOptions['class'])) {
$cellOptions['class'] .= ' column-' . ++$i;
} else {
$cellOptions['class'] = 'column-' . ++$i;
}
}
$cellsOut[] = sprintf($this->_tags['tablecell'], $this->_parseAttributes($cellOptions), $cell);
}
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);

0 comments on commit 4915e80

Please sign in to comment.