[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/i18n/tests/cases/template/tags/i18n/ -> lmbI18NNumberFilterTest.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/i18n/src/toolkit/lmbI18NTools.class.php');
  10  
  11  class lmbI18NNumberFilterTest extends lmbWactTestCase
  12  {
  13    protected $locale;
  14  
  15    function setUp()
  16    {
  17      parent :: setUp();
  18  
  19      $this->locale = new lmbLocale('en');
  20      $this->locale->fract_digits = 2;
  21      $this->locale->decimal_symbol = '.';
  22      $this->locale->thousand_separator = ',';
  23      $this->toolkit->addLocaleObject($this->locale);
  24    }
  25  
  26    function testUseDefaultLocale()
  27    {
  28      $this->toolkit->setLocale('en');
  29  
  30      $template = '{$"100000"|i18n_number}';
  31  
  32      $this->registerTestingTemplate('/limb/locale_number_filter_default.html', $template);
  33  
  34      $page = $this->initTemplate('/limb/locale_number_filter_default.html');
  35  
  36      $this->assertEqual($page->capture(), '100,000.00');
  37    }
  38  
  39    function testUseOtherLocale()
  40    {
  41      $this->locale->fract_digits = 4;
  42      $this->toolkit->addLocaleObject($this->locale, 'foo');
  43  
  44      $template = '{$"100000"|i18n_number:"foo"}';
  45  
  46      $this->registerTestingTemplate('/limb/locale_number_filter_russian.html', $template);
  47  
  48      $page = $this->initTemplate('/limb/locale_number_filter_russian.html');
  49  
  50      $this->assertEqual($page->capture(), '100,000.0000');
  51    }
  52  
  53    function testUseFractDigits()
  54    {
  55      $template = '{$"100000"|i18n_number:"en","3"}';
  56  
  57      $this->registerTestingTemplate('/limb/locale_number_filter_fract_digits.html', $template);
  58  
  59      $page = $this->initTemplate('/limb/locale_number_filter_fract_digits.html');
  60  
  61      $this->assertEqual($page->capture(), '100,000.000');
  62    }
  63  
  64    function testUseDecimalSymbol()
  65    {
  66      $template = '{$"100000"|i18n_number:"en","",","}';
  67  
  68      $this->registerTestingTemplate('/limb/locale_number_filter_decimal_symbol.html', $template);
  69  
  70      $page = $this->initTemplate('/limb/locale_number_filter_decimal_symbol.html');
  71  
  72      $this->assertEqual($page->capture(), '100,000,00');
  73    }
  74  
  75    function testUseThousandSeparator()
  76    {
  77      $template = '{$"100000"|i18n_number:"en","",""," "}';
  78  
  79      $this->registerTestingTemplate('/limb/locale_number_filter_thousand_separator.html', $template);
  80  
  81      $page = $this->initTemplate('/limb/locale_number_filter_thousand_separator.html');
  82  
  83      $this->assertEqual($page->capture(), '100 000.00');
  84    }
  85  
  86    function testDefaultDBE()
  87    {
  88      $template = '{$var|i18n_number}';
  89  
  90      $this->registerTestingTemplate('/limb/locale_number_filter_DBE.html', $template);
  91  
  92      $page = $this->initTemplate('/limb/locale_number_filter_DBE.html');
  93  
  94      $page->set('var', '100000');
  95  
  96      $this->assertEqual($page->capture(), '100,000.00');
  97    }
  98  
  99    function testDBEUseOtherLocale()
 100    {
 101      $this->locale->fract_digits = 4;
 102      $this->toolkit->addLocaleObject($this->locale, 'foo');
 103  
 104      $template = '{$var|i18n_number:"foo"}';
 105  
 106      $this->registerTestingTemplate('/limb/locale_number_filter_DBE_other_locale.html', $template);
 107  
 108      $page = $this->initTemplate('/limb/locale_number_filter_DBE_other_locale.html');
 109      $page->set('var', '100000');
 110  
 111      $this->assertEqual($page->capture(), '100,000.0000');
 112    }
 113  
 114    function testDBEUseFractDigits()
 115    {
 116      $template = '{$var|i18n_number:"en","3"}';
 117  
 118      $this->registerTestingTemplate('/limb/locale_number_filter_DBE_fract_digits.html', $template);
 119  
 120      $page = $this->initTemplate('/limb/locale_number_filter_DBE_fract_digits.html');
 121      $page->set('var', '100000');
 122  
 123      $this->assertEqual($page->capture(), '100,000.000');
 124    }
 125  
 126    function testDBEUseDecimalSymbol()
 127    {
 128      $template = '{$var|i18n_number:"en","",","}';
 129  
 130      $this->registerTestingTemplate('/limb/locale_number_filter_DBE_decimal_symbol.html', $template);
 131  
 132      $page = $this->initTemplate('/limb/locale_number_filter_DBE_decimal_symbol.html');
 133      $page->set('var', '100000');
 134  
 135      $this->assertEqual($page->capture(), '100,000,00');
 136    }
 137  
 138    function testDBEUseThousandSeparator()
 139    {
 140      $template = '{$var|i18n_number:"en","",""," "}';
 141  
 142      $this->registerTestingTemplate('/limb/locale_number_filter_DBE_thousand_separator.html', $template);
 143  
 144      $page = $this->initTemplate('/limb/locale_number_filter_DBE_thousand_separator.html');
 145      $page->set('var', '100000');
 146  
 147      $this->assertEqual($page->capture(), '100 000.00');
 148    }
 149  }
 150  ?>


Generated: Tue Oct 7 05:02:03 2008 Cross-referenced by PHPXref 0.7