[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/i18n/tests/cases/locale/ -> lmbLocaleTest.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/config/src/lmbIni.class.php');
  10  lmb_require('limb/i18n/src/locale/lmbLocaleSpec.class.php');
  11  lmb_require('limb/i18n/src/locale/lmbLocale.class.php');
  12  
  13  class lmbLocaleTest extends UnitTestCase
  14  {
  15    function testGetLocaleSpec()
  16    {
  17      $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini'));
  18      $this->assertEqual($locale->getLocaleSpec(), new lmbLocaleSpec('en'));
  19    }
  20  
  21    function testGetMonthName()
  22    {
  23      $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini'));
  24  
  25      $this->assertEqual($locale->getMonthName(0), 'January');
  26      $this->assertEqual($locale->getMonthName(11), 'December');
  27      $this->assertNull($locale->getMonthName(12));
  28    }
  29  
  30    function testGetDayName()
  31    {
  32      $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini'));
  33  
  34      $this->assertEqual($locale->getDayName(0, $short = false), 'Sunday');
  35      $this->assertEqual($locale->getDayName(0, $short = true), 'Sun');
  36      $this->assertEqual($locale->getDayName(6, $short = false), 'Saturday');
  37      $this->assertEqual($locale->getDayName(6, $short = true), 'Sat');
  38    }
  39  
  40    function testGetOtherOptions()
  41    {
  42      $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini'));
  43  
  44      $this->assertEqual($locale->getCharset(), 'utf-8');
  45      $this->assertEqual($locale->getLanguageDirection(), 'ltr');
  46    }
  47  
  48    function testGetCountryOptions()
  49    {
  50      $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini'));
  51  
  52      $this->assertEqual($locale->getCountryName(), 'USA');
  53      $this->assertEqual($locale->getCountryComment(), '');
  54    }
  55  
  56    function testGetLanguageOptions()
  57    {
  58      $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini'));
  59  
  60      $this->assertEqual($locale->getLanguageName(), 'English (American)');
  61      $this->assertEqual($locale->getIntlLanguageName(), 'English (American)');
  62    }
  63  
  64    function testGetCurrencyOptions()
  65    {
  66      $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini'));
  67  
  68      $this->assertEqual($locale->getCurrencySymbol(), '$');
  69      $this->assertEqual($locale->getCurrencyName(), 'US Dollar');
  70      $this->assertEqual($locale->getCurrencyShortName(), 'USD');
  71    }
  72  
  73    function testGetDateTimeFormatOptions()
  74    {
  75      $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini'));
  76  
  77      $this->assertEqual($locale->getTimeFormat(), '%H:%M:%S %p');
  78      $this->assertEqual($locale->getShortTimeFormat(), '%H:%M %p');
  79      $this->assertEqual($locale->getDateFormat(), '%A %d %B %Y');
  80      $this->assertEqual($locale->getShortDateFormat(), '%m/%d/%Y');
  81      $this->assertEqual($locale->getShortDateTimeFormat(), '%m/%d/%Y %H:%M:%S');
  82      $this->assertEqual($locale->getDateTimeFormat(), '%A %d %B %Y %H:%M:%S');
  83    }
  84  
  85    function testGetWeekDaysOptions()
  86    {
  87      $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini'));
  88  
  89      $this->assertFalse($locale->isMondayFirst());
  90      $this->assertEqual($locale->getWeekDays(), array(0, 1, 2, 3, 4, 5, 6));
  91      $this->assertEqual($locale->getMonths(), array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));
  92      $this->assertEqual($locale->getWeekDayNames(), array('Sunday',
  93                                                           'Monday',
  94                                                           'Tuesday',
  95                                                           'Wednesday',
  96                                                           'Thursday',
  97                                                           'Friday',
  98                                                           'Saturday'));
  99  
 100      $this->assertEqual($locale->getWeekDayNames($short = true), array('Sun',
 101                                                                        'Mon',
 102                                                                        'Tue',
 103                                                                        'Wed',
 104                                                                        'Thu',
 105                                                                        'Fri',
 106                                                                        'Sat'));
 107  
 108      $this->assertEqual($locale->getMonthNames(), array('January',
 109                                                         'February',
 110                                                         'March',
 111                                                         'April',
 112                                                         'May',
 113                                                         'June',
 114                                                         'July',
 115                                                         'August',
 116                                                         'September',
 117                                                         'October',
 118                                                         'November',
 119                                                         'December'));
 120  
 121      $this->assertEqual($locale->getMonthNames($short = true), array('Jan',
 122                                                                      'Feb',
 123                                                                      'Mar',
 124                                                                      'Apr',
 125                                                                      'May',
 126                                                                      'Jun',
 127                                                                      'Jul',
 128                                                                      'Aug',
 129                                                                      'Sep',
 130                                                                      'Oct',
 131                                                                      'Nov',
 132                                                                      'Dec'));
 133  
 134      $this->assertEqual($locale->getMeridiemName(10), 'am');
 135      $this->assertEqual($locale->getMeridiemName(22), 'pm');
 136    }
 137  }
 138  ?>


Generated: Sat Nov 22 03:48:54 2008 Cross-referenced by PHPXref 0.7