| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/datetime/src/lmbDate.class.php'); 10 11 class lmbI18NDateFilterTest extends lmbWactTestCase 12 { 13 function setUp() 14 { 15 parent :: setUp(); 16 $this->toolkit->addLocaleObject(new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../../../en.ini'))); 17 } 18 19 function testSetDateByString() 20 { 21 $template = '{$"2002-02-20"|i18n_date:"en", "string"}'; 22 23 $this->registerTestingTemplate('/limb/locale_date_filter_string.html', $template); 24 25 $page = $this->initTemplate('/limb/locale_date_filter_string.html'); 26 27 $this->assertEqual($page->capture(), '02/20/2002'); 28 } 29 30 function testSetDateByStampValue() 31 { 32 $date = new lmbDate('2004-12-20 10:15:30'); 33 34 $template = '{$"' . $date->getStamp() . '"|i18n_date:"en", "stamp"}'; 35 36 $this->registerTestingTemplate('/limb/locale_date_filter_stamp.html', $template); 37 38 $page = $this->initTemplate('/limb/locale_date_filter_stamp.html'); 39 40 $this->assertEqual($page->capture(), '12/20/2004'); 41 } 42 43 function testFormatType() 44 { 45 $date = new lmbDate('2005-01-20 10:15:30'); 46 47 $template = '{$"' . $date->getStamp() . '"|i18n_date:"en", "stamp", "date"}'; 48 49 $this->registerTestingTemplate('/limb/locale_date_filter_format_type.html', $template); 50 51 $page = $this->initTemplate('/limb/locale_date_filter_format_type.html'); 52 53 $this->assertEqual($page->capture(), 'Thursday 20 January 2005'); 54 } 55 56 function testSetDateTimeByString() 57 { 58 $template = '{$"2002-02-20 10:23:24"|i18n_date:"en", "string", "short_date_time"}'; 59 60 $this->registerTestingTemplate('/limb/locale_date_filter_string_date_time.html', $template); 61 62 $page = $this->initTemplate('/limb/locale_date_filter_string_date_time.html'); 63 64 $this->assertEqual($page->capture(), '02/20/2002 10:23:24'); 65 } 66 67 function testDefinedFormat() 68 { 69 $date = new lmbDate('2004-12-20 10:15:30'); 70 71 $template = '{$"' . $date->getStamp() . '"|i18n_date:"en", "stamp", "", "%Y %m %d"}'; 72 73 $this->registerTestingTemplate('/limb/locale_date_filter_defined_format.html', $template); 74 75 $page = $this->initTemplate('/limb/locale_date_filter_defined_format.html'); 76 77 $this->assertEqual($page->capture(), '2004 12 20'); 78 } 79 80 function testUseRussianAsCurrentLocale() 81 { 82 $toolkit = lmbToolkit :: save(); 83 $toolkit->addLocaleObject(new lmbLocale('ru', new lmbIni(dirname(__FILE__) . '/../../../ru.ini'))); 84 85 $date = new lmbDate('2004-12-20 10:15:30'); 86 87 $template = '{$"' . $date->getStamp() . '"|i18n_date:"ru", "stamp"}'; 88 89 $this->registerTestingTemplate('/limb/locale_date_filter_use_russian_locale.html', $template); 90 91 $page = $this->initTemplate('/limb/locale_date_filter_use_russian_locale.html'); 92 93 $this->assertEqual($page->capture(), '20.12.2004'); 94 95 lmbToolkit :: restore(); 96 } 97 98 function testDBESetDateByString() 99 { 100 $template = '{$var|i18n_date:"en", "string"}'; 101 102 $this->registerTestingTemplate('/limb/locale_date_filter_dbe_string.html', $template); 103 104 $page = $this->initTemplate('/limb/locale_date_filter_dbe_string.html'); 105 106 $page->set('var', "2002-02-20"); 107 108 $this->assertEqual($page->capture(), '02/20/2002'); 109 } 110 111 function testDBESetDateByStampValue() 112 { 113 $date = new lmbDate('2004-12-20 10:15:30'); 114 115 $template = '{$var|i18n_date:"en", "stamp"}'; 116 117 $this->registerTestingTemplate('/limb/locale_date_filter_dbe_stamp.html', $template); 118 119 $page = $this->initTemplate('/limb/locale_date_filter_dbe_stamp.html'); 120 121 $page->set('var', $date->getStamp()); 122 123 $this->assertEqual($page->capture(), '12/20/2004'); 124 } 125 126 function testDBEFormatType() 127 { 128 $date = new lmbDate('2005-01-20 10:15:30'); 129 130 $template = '{$var|i18n_date:"en", "stamp", "date"}'; 131 132 $this->registerTestingTemplate('/limb/locale_date_filter_dbe_format_type.html', $template); 133 134 $page = $this->initTemplate('/limb/locale_date_filter_dbe_format_type.html'); 135 136 $page->set('var', $date->getStamp()); 137 138 $this->assertEqual($page->capture(), 'Thursday 20 January 2005'); 139 } 140 141 function testDBEDefinedFormat() 142 { 143 $date = new lmbDate('2005-01-20 10:15:30'); 144 145 $template = '{$var|i18n_date:"en", "stamp", "", "%Y %m %d"}'; 146 147 $this->registerTestingTemplate('/limb/locale_date_filter_dbe_defined_format.html', $template); 148 149 $page = $this->initTemplate('/limb/locale_date_filter_dbe_defined_format.html'); 150 151 $page->set('var', $date->getStamp()); 152 153 $this->assertEqual($page->capture(), '2005 01 20'); 154 } 155 156 function testDBEUseRussianAsCurrentLocale() 157 { 158 $toolkit = lmbToolkit :: save(); 159 $toolkit->addLocaleObject(new lmbLocale('ru', new lmbIni(dirname(__FILE__) . '/../../../ru.ini'))); 160 161 $date = new lmbDate('2005-01-20 10:15:30'); 162 163 $template = '{$var|i18n_date:"ru", "stamp"}'; 164 165 $this->registerTestingTemplate('/limb/locale_date_filter_dbe_use_russian_locale.html', $template); 166 167 $page = $this->initTemplate('/limb/locale_date_filter_dbe_use_russian_locale.html'); 168 169 $page->set('var', $date->getStamp()); 170 171 $this->assertEqual($page->capture(), '20.01.2005'); 172 173 lmbToolkit :: restore(); 174 } 175 176 function testComplexPathBasedDBEWithDefinedFormat() 177 { 178 $date = new lmbDate('2005-01-20 10:15:30'); 179 180 $template = '{$my.var|i18n_date:"en", "stamp", "", "%Y %m %d"}'; 181 182 $this->registerTestingTemplate('/limb/locale_date_filter_path_based_dbe_defined_format.html', $template); 183 184 $page = $this->initTemplate('/limb/locale_date_filter_path_based_dbe_defined_format.html'); 185 186 $my_dataspace = new lmbSet(array('var' => $date->getStamp())); 187 $page->set('my', $my_dataspace); 188 189 $this->assertEqual($page->capture(), '2005 01 20'); 190 } 191 } 192 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Nov 22 03:48:54 2008 | Cross-referenced by PHPXref 0.7 |