Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.0' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpacheco committed Mar 29, 2012
2 parents 3b636f9 + 86b1fae commit bf97ea7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
24 changes: 0 additions & 24 deletions Model/Behavior/AjusteFloatBehavior.php
Expand Up @@ -119,29 +119,5 @@ public function beforeSave($model) {

return true;
}



/**
* After Find
*
* @param object $model
* @param array $results
* @param boolean $primary
* @return void
* @access public
* @deprecated Isto deve ser feito na view
*/
public function afterFind($model, $results, $primary) {
foreach ($results as $key => $r) {
if (isset($r[$model->alias]) && is_array($r[$model->alias])) {
foreach (array_keys($r[$model->alias]) as $arrayKey) {
if (in_array($arrayKey, $this->floatFields[$model->alias]) && $r[$model->alias][$arrayKey] !== null) {
$results[$key][$model->alias][$arrayKey] = number_format($r[$model->alias][$arrayKey], 2, ',', '.');
}
}
}
}
return $results;
}
}
8 changes: 4 additions & 4 deletions Test/Case/Model/Behavior/AjusteFloatTest.php
Expand Up @@ -94,21 +94,21 @@ public function testFind() {
'Produto' => array(
'id' => 1,
'nome' => 'Produto 1',
'valor' => '1,99'
'valor' => '1.99'
)
),
array(
'Produto' => array(
'id' => 2,
'nome' => 'Produto 2',
'valor' => '1.000,20'
'valor' => '1000.20'
)
),
array(
'Produto' => array(
'id' => 3,
'nome' => 'Produto 3',
'valor' => '1.999.000,00'
'valor' => '1999000.00'
)
)
);
Expand Down Expand Up @@ -221,7 +221,7 @@ public function testSave() {
$this->assertEqual($data, $result);

$result = $this->Produto->read(array('valor'), $id);
$this->assertEqual(array('Produto' => array('valor' => '5.000,00')), $result);
$this->assertEqual(array('Produto' => array('valor' => '5000.00')), $result);

$result = $this->Produto->read(array('nome'), $id); // Verificar se dá erro quando não vem o campo
$this->assertEqual(array('Produto' => array('nome' => 'Produto 4')), $result);
Expand Down

0 comments on commit bf97ea7

Please sign in to comment.