Example #1
0
 /**
  * testMultibyteFormat
  *
  * @return void
  */
 public function testMultibyteFormat()
 {
     $value = '5199100.0006';
     $result = $this->Number->format($value, array('thousands' => ' ', 'decimals' => '&', 'places' => 3, 'escape' => false));
     $expected = '5 199 100&001';
     $this->assertEquals($expected, $result);
     $value = 1000.45;
     $result = $this->Number->format($value, array('thousands' => ',,', 'decimals' => '.a', 'escape' => false));
     $expected = '1,,000.a45';
     $this->assertEquals($expected, $result);
     $value = 519919827593784.0;
     $this->Number->addFormat('RUR', array('thousands' => 'ø€ƒ‡™', 'decimals' => '(§.§)', 'escape' => false, 'wholeSymbol' => '€', 'wholePosition' => 'after'));
     $result = $this->Number->currency($value, 'RUR');
     $expected = '519ø€ƒ‡™919ø€ƒ‡™827ø€ƒ‡™593ø€ƒ‡™784(§.§)00€';
     $this->assertEquals($expected, $result);
     $value = '13371337.1337';
     $result = Number::format($value, array('thousands' => '- |-| /-\\ >< () |2 -', 'decimals' => '- £€€† -'));
     $expected = '13- |-| /-\\ &gt;&lt; () |2 -371- |-| /-\\ &gt;&lt; () |2 -337- £€€† -13';
     $this->assertEquals($expected, $result);
 }
Example #2
0
 /**
  * Formats a number into a currency format.
  *
  * @see \Cake\Utility\Number::format()
  *
  * @param float $number A floating point number.
  * @param array $options Array of options.
  * @return string Formatted number
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::format
  */
 public function format($number, array $options = [])
 {
     return $this->_engine->format($number, $options);
 }