Adding tests for securing private variable inclussion on templates.
[akelos.git] / test / unit / lib / AkActionView / helpers / number_helper.php
blob2af1339ffa7735a81c73e5e4edcf32abfef8962e
1 <?php
3 require_once('_HelpersUnitTester.php');
4 require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'helpers'.DS.'number_helper.php');
7 class NumberHelperTests extends HelpersUnitTester
8 {
9 function test_for_NumberHelper()
11 $number = new NumberHelper();
12 $this->assertEqual($number->number_to_phone(1235551234),'123-555-1234');
13 $this->assertEqual($number->number_to_phone(1235551234, array('area_code' => true)),'(123) 555-1234');
14 $this->assertEqual($number->number_to_phone(1235551234, array('delimiter' => ' ')),'123 555 1234');
15 $this->assertEqual($number->number_to_phone(1235551234, array('area_code' => true, 'extension' => 555)),
16 '(123) 555-1234 x 555');
19 $this->assertEqual($number->number_to_currency("1234567890.50"),'$1,234,567,890.50');
21 $this->assertEqual($number->number_to_currency(123456789.123456, array('precision'=>2, 'unit' => ' Skk',
22 'unit_position' => 'right', 'separator'=> ',', 'delimiter' => ' ')),'123 456 789,12 Skk');
24 $this->assertEqual($number->number_to_currency("1234567890.50"),'$1,234,567,890.50');
25 $this->assertEqual($number->number_to_currency(1234567890.506), '$1,234,567,890.51');
26 $this->assertEqual($number->number_to_currency(1234567890.50, array('unit' => "&pound;", 'separator' => ",", 'delimiter' => "")), '&pound;1234567890,50');
27 $this->assertEqual($number->number_to_currency(1234567890.50, array('unit' => " &euro;", 'separator' => ",", 'delimiter' => ".",'unit_position' => 'right')), '1.234.567.890,50 &euro;');
29 $this->assertEqual($number->number_to_percentage(100), '100.00%');
30 $this->assertEqual($number->number_to_percentage(100, array('precision' => 0)), '100%');
31 $this->assertEqual($number->number_to_percentage(302.0576, array('precision' => 3)), '302.058%');
33 $this->assertEqual($number->number_with_delimiter(12345678), '12,345,678');
34 $this->assertEqual($number->number_with_delimiter(12345678.2), '12,345,678.2');
36 $this->assertEqual($number->human_size(123) , '123 Bytes');
37 $this->assertEqual($number->human_size(1234) , '1.2 KB');
38 $this->assertEqual($number->human_size(12345) , '12.1 KB');
39 $this->assertEqual($number->human_size(1234567) , '1.2 MB');
40 $this->assertEqual($number->human_size(1234567890) , '1.1 GB');
42 $this->assertEqual($number->human_size_to_bytes('123 Bytes'), 123);
43 $this->assertEqual($number->human_size_to_bytes('1.2 KB'), 1229);
44 $this->assertEqual($number->human_size_to_bytes('12.1 KB'), 12391);
45 $this->assertEqual($number->human_size_to_bytes('1.2 MB'), 1258292);
46 $this->assertEqual($number->human_size_to_bytes('1.1 GB'), 1181116007);
48 $this->assertEqual($number->number_with_precision(111.2345), '111.235');
50 $this->assertEqual($number->zeropad(123, 6), '000123');
51 $this->assertEqual($number->zeropad('0123', 6), '000123');
52 $this->assertEqual($number->zeropad(12345, 2), '12345');
57 ak_test('NumberHelperTests');