[limb-svn] r6722 - 3.x/trunk/limb/i18n/tests/cases/wact

svn at limb-project.com svn at limb-project.com
Tue Jan 22 11:41:12 MSK 2008


Author: serega
Date: 2008-01-22 11:41:12 +0300 (Tue, 22 Jan 2008)
New Revision: 6722
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6722

Added:
   3.x/trunk/limb/i18n/tests/cases/wact/lmbCurrentLocaleTagTest.class.php
   3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NCapitalizeFilterTest.class.php
   3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NClipFilterTest.class.php
   3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NDateFilterTest.class.php
   3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NLowercaseFilterTest.class.php
   3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NNumberFilterTest.class.php
   3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NStringFilterTest.class.php
   3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NTrimFilterTest.class.php
   3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NUppercaseFilterTest.class.php
Removed:
   3.x/trunk/limb/i18n/tests/cases/wact/tags/
Log:
-- other WACT related folders renaming and movements in I18N package


Copied: 3.x/trunk/limb/i18n/tests/cases/wact/lmbCurrentLocaleTagTest.class.php (from rev 6721, 3.x/trunk/limb/i18n/tests/cases/wact/tags/i18n/lmbCurrentLocaleTagTest.class.php)
===================================================================
--- 3.x/trunk/limb/i18n/tests/cases/wact/lmbCurrentLocaleTagTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/i18n/tests/cases/wact/lmbCurrentLocaleTagTest.class.php	2008-01-22 08:41:12 UTC (rev 6722)
@@ -0,0 +1,38 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com 
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ */
+
+class lmbCurrentLocaleTagTest extends lmbWactTestCase
+{
+  function testUseEnglishLocale()
+  {
+    $this->toolkit->setLocale('en');
+    $template = '<limb:current_locale name="en">Some text</limb:current_locale>' .
+                '<limb:current_locale name="ru">Other text</limb:current_locale>';
+
+    $this->registerTestingTemplate('/limb/locale_default.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_default.html');
+
+    $this->assertEqual($page->capture(), 'Some text');
+  }
+
+  function testUseRussianLocale() // Just to be sure
+  {
+    $this->toolkit->setLocale('ru');
+    $template = '<limb:current_locale name="ru">Some text</limb:current_locale>' .
+                '<limb:current_locale name="en">Other text</limb:current_locale>';
+
+    $this->registerTestingTemplate('/limb/locale_default_use_russian.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_default_use_russian.html');
+
+    $this->assertEqual($page->capture(), 'Some text');
+  }
+}
+

Copied: 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NCapitalizeFilterTest.class.php (from rev 6721, 3.x/trunk/limb/i18n/tests/cases/wact/tags/i18n/lmbI18NCapitalizeFilterTest.class.php)
===================================================================
--- 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NCapitalizeFilterTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NCapitalizeFilterTest.class.php	2008-01-22 08:41:12 UTC (rev 6722)
@@ -0,0 +1,63 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com 
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ */
+require_once('limb/i18n/utf8.inc.php');
+
+class lmbI18NCapitalizeFilterTest extends lmbWactTestCase
+{
+  var $prev_driver;
+
+  function setUp()
+  {
+    parent :: setUp();
+    $this->prev_driver = lmb_use_charset_driver(new lmbUTF8BaseDriver());
+  }
+
+  function tearDown()
+  {
+    lmb_use_charset_driver($this->prev_driver);
+    parent :: tearDown();
+  }
+
+  function testSimple()
+  {
+    $template = '{$"тест"|i18n_capitalize}';
+
+    $this->registerTestingTemplate('/limb/locale_capitalize_filter.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_capitalize_filter.html');
+
+    $this->assertEqual($page->capture(), 'Тест');
+  }
+
+  function testDBE()
+  {
+    $template = '{$var|i18n_capitalize}';
+
+    $this->registerTestingTemplate('/limb/locale_capitalize_filter_dbe.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_capitalize_filter_dbe.html');
+    $page->set('var', 'тест');
+
+    $this->assertEqual($page->capture(), 'Тест');
+  }
+
+  function testPathBasedDBE()
+  {
+    $template = '{$my.var|i18n_capitalize}';
+
+    $this->registerTestingTemplate('/limb/locale_capitalize_filter_path_based_dbe.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_capitalize_filter_path_based_dbe.html');
+    $my_dataspace = new lmbSet(array('var' => 'тест'));
+    $page->set('my', $my_dataspace);
+
+    $this->assertEqual($page->capture(), 'Тест');
+  }
+}
+

Copied: 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NClipFilterTest.class.php (from rev 6721, 3.x/trunk/limb/i18n/tests/cases/wact/tags/i18n/lmbI18NClipFilterTest.class.php)
===================================================================
--- 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NClipFilterTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NClipFilterTest.class.php	2008-01-22 08:41:12 UTC (rev 6722)
@@ -0,0 +1,146 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com 
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ */
+require_once('limb/i18n/utf8.inc.php');
+
+class lmbI18NClipFilterTest extends lmbWactTestCase
+{
+  var $prev_driver;
+
+  function setUp()
+  {
+    parent :: setUp();
+    $this->prev_driver = lmb_use_charset_driver(new lmbUTF8BaseDriver());
+  }
+
+  function tearDown()
+  {
+    lmb_use_charset_driver($this->prev_driver);
+    parent :: tearDown();
+  }
+
+  function testLengthLimit()
+  {
+    $template = '{$"что-то"|i18n_clip:3}';
+
+    $this->registerTestingTemplate('/limb/clip_with_limit.html', $template);
+
+    $page = $this->initTemplate('/limb/clip_with_limit.html');
+
+    $this->assertEqual($page->capture(), 'что');
+  }
+
+  function testLengthLimitAndOffset()
+  {
+    $template = '{$"фреймворк для веб-приложений"|i18n_clip:3,5}';
+
+    $this->registerTestingTemplate('/limb/clip_with_offset.html', $template);
+
+    $page = $this->initTemplate('/limb/clip_with_offset.html');
+
+    $this->assertEqual($page->capture(), 'вор');
+  }
+
+  function testWithSuffix()
+  {
+    $template = '{$"фреймворк для веб-приложений"|i18n_clip:3,5,"..."}';
+
+    $this->registerTestingTemplate('/limb/clip_with_suffix.html', $template);
+
+    $page = $this->initTemplate('/limb/clip_with_suffix.html');
+
+    $this->assertEqual($page->capture(), 'вор...');
+  }
+
+  function testSuffixNotUsedTooShortString()
+  {
+    $template = '{$"фреймворк"|i18n_clip:10,"0","..."}';
+
+    $this->registerTestingTemplate('/limb/clip_terminator_not_used.html', $template);
+
+    $page = $this->initTemplate('/limb/clip_terminator_not_used.html');
+
+    $this->assertEqual($page->capture(), "фреймворк");
+  }
+
+  // can't implement this since PHP has some bugs with /b modifier in multibyte mode
+  function _testLongStringWordBoundary()
+  {
+    $template = '{$"фреймворк для веб-приложений"|i18n_clip:11,1,"...", "y"}';
+
+    $this->registerTestingTemplate('/limb/clip_with_word_bound.html', $template);
+
+    $page = $this->initTemplate('/limb/clip_with_word_bound.html');
+
+    $this->assertEqual($page->capture(), 'реймворк для...');
+  }
+
+  function testDBELengthLimit()
+  {
+    $template = '{$var|i18n_clip:3}';
+
+    $this->registerTestingTemplate('/limb/clip_dbe_with_limit.html', $template);
+
+    $page = $this->initTemplate('/limb/clip_dbe_with_limit.html');
+    $page->set('var', 'что-то');
+
+    $this->assertEqual($page->capture(), 'что');
+  }
+
+  function testDBELengthLimitAndOffset()
+  {
+    $template = '{$var|i18n_clip:3,5}';
+
+    $this->registerTestingTemplate('/limb/clip_dbe_with_offset.html', $template);
+
+    $page = $this->initTemplate('/limb/clip_dbe_with_offset.html');
+    $page->set('var', "фреймворк для веб-приложений");
+
+    $this->assertEqual($page->capture(), 'вор');
+  }
+
+  function testDBEWithSuffix()
+  {
+    $template = '{$var|i18n_clip:3,5,"..."}';
+
+    $this->registerTestingTemplate('/limb/clip_dbe_with_suffix.html', $template);
+
+    $page = $this->initTemplate('/limb/clip_dbe_with_suffix.html');
+    $page->set('var', "фреймворк для веб-приложений");
+
+    $this->assertEqual($page->capture(), 'вор...');
+  }
+
+  function testDBESuffixNotUsedTooShortString()
+  {
+    $template = '{$var|i18n_clip:10,"0","..."}';
+
+    $this->registerTestingTemplate('/limb/clip_dbe_suffix_not_used.html', $template);
+
+    $page = $this->initTemplate('/limb/clip_dbe_suffix_not_used.html');
+    $page->set('var', "фреймворк");
+
+    $this->assertEqual($page->capture(), "фреймворк");
+  }
+
+  function testPathBasedDBELengthLimit()
+  {
+    $template = '{$my.var|i18n_clip:3}';
+
+    $this->registerTestingTemplate('/limb/clip_path_based_dbe_with_limit.html', $template);
+
+    $page = $this->initTemplate('/limb/clip_path_based_dbe_with_limit.html');
+
+    $my_dataspace = new lmbSet(array('var' => 'что-то'));
+    $page->set('my', $my_dataspace);
+
+    $this->assertEqual($page->capture(), 'что');
+  }
+
+}
+

Copied: 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NDateFilterTest.class.php (from rev 6721, 3.x/trunk/limb/i18n/tests/cases/wact/tags/i18n/lmbI18NDateFilterTest.class.php)
===================================================================
--- 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NDateFilterTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NDateFilterTest.class.php	2008-01-22 08:41:12 UTC (rev 6722)
@@ -0,0 +1,192 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com 
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ */
+lmb_require('limb/datetime/src/lmbDateTime.class.php');
+
+class lmbI18NDateFilterTest extends lmbWactTestCase
+{
+  function setUp()
+  {
+    parent :: setUp();
+    $this->toolkit->addLocaleObject(new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../../../en.ini')));
+  }
+
+  function testSetDateByString()
+  {
+    $template = '{$"2002-02-20"|i18n_date:"en", "string"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_string.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_string.html');
+
+    $this->assertEqual($page->capture(), '02/20/2002');
+  }
+
+  function testSetDateByStampValue()
+  {
+    $date = new lmbDateTime('2004-12-20 10:15:30');
+
+    $template = '{$"' . $date->getStamp() . '"|i18n_date:"en", "stamp"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_stamp.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_stamp.html');
+
+    $this->assertEqual($page->capture(), '12/20/2004');
+  }
+
+  function testFormatType()
+  {
+    $date = new lmbDateTime('2005-01-20 10:15:30');
+
+    $template = '{$"' . $date->getStamp() . '"|i18n_date:"en", "stamp", "date"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_format_type.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_format_type.html');
+
+    $this->assertEqual($page->capture(), 'Thursday 20 January 2005');
+  }
+
+  function testSetDateTimeByString()
+  {
+    $template = '{$"2002-02-20 10:23:24"|i18n_date:"en", "string", "short_date_time"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_string_date_time.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_string_date_time.html');
+
+    $this->assertEqual($page->capture(), '02/20/2002 10:23:24');
+  }
+
+  function testDefinedFormat()
+  {
+    $date = new lmbDateTime('2004-12-20 10:15:30');
+
+    $template = '{$"' . $date->getStamp() . '"|i18n_date:"en", "stamp", "", "%Y %m %d"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_defined_format.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_defined_format.html');
+
+    $this->assertEqual($page->capture(), '2004 12 20');
+  }
+
+  function testUseRussianAsCurrentLocale()
+  {
+    $toolkit = lmbToolkit :: save();
+    $toolkit->addLocaleObject(new lmbLocale('ru', new lmbIni(dirname(__FILE__) . '/../../../ru.ini')));
+
+    $date = new lmbDateTime('2004-12-20 10:15:30');
+
+    $template = '{$"' . $date->getStamp() . '"|i18n_date:"ru", "stamp"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_use_russian_locale.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_use_russian_locale.html');
+
+    $this->assertEqual($page->capture(), '20.12.2004');
+
+    lmbToolkit :: restore();
+  }
+
+  function testDBESetDateByString()
+  {
+    $template = '{$var|i18n_date:"en", "string"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_dbe_string.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_dbe_string.html');
+
+    $page->set('var', "2002-02-20");
+
+    $this->assertEqual($page->capture(), '02/20/2002');
+  }
+
+  function testDBESetDateByStampValue()
+  {
+    $date = new lmbDateTime('2004-12-20 10:15:30');
+
+    $template = '{$var|i18n_date:"en", "stamp"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_dbe_stamp.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_dbe_stamp.html');
+
+    $page->set('var', $date->getStamp());
+
+    $this->assertEqual($page->capture(), '12/20/2004');
+  }
+
+  function testDBEFormatType()
+  {
+    $date = new lmbDateTime('2005-01-20 10:15:30');
+
+    $template = '{$var|i18n_date:"en", "stamp", "date"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_dbe_format_type.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_dbe_format_type.html');
+
+    $page->set('var', $date->getStamp());
+
+    $this->assertEqual($page->capture(), 'Thursday 20 January 2005');
+  }
+
+  function testDBEDefinedFormat()
+  {
+    $date = new lmbDateTime('2005-01-20 10:15:30');
+
+    $template = '{$var|i18n_date:"en", "stamp", "", "%Y %m %d"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_dbe_defined_format.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_dbe_defined_format.html');
+
+    $page->set('var', $date->getStamp());
+
+    $this->assertEqual($page->capture(), '2005 01 20');
+  }
+
+  function testDBEUseRussianAsCurrentLocale()
+  {
+    $toolkit = lmbToolkit :: save();
+    $toolkit->addLocaleObject(new lmbLocale('ru', new lmbIni(dirname(__FILE__) . '/../../../ru.ini')));
+
+    $date = new lmbDateTime('2005-01-20 10:15:30');
+
+    $template = '{$var|i18n_date:"ru", "stamp"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_dbe_use_russian_locale.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_dbe_use_russian_locale.html');
+
+    $page->set('var', $date->getStamp());
+
+    $this->assertEqual($page->capture(), '20.01.2005');
+
+    lmbToolkit :: restore();
+  }
+
+  function testComplexPathBasedDBEWithDefinedFormat()
+  {
+    $date = new lmbDateTime('2005-01-20 10:15:30');
+
+    $template = '{$my.var|i18n_date:"en", "stamp", "", "%Y %m %d"}';
+
+    $this->registerTestingTemplate('/limb/locale_date_filter_path_based_dbe_defined_format.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_date_filter_path_based_dbe_defined_format.html');
+
+    $my_dataspace = new lmbSet(array('var' => $date->getStamp()));
+    $page->set('my', $my_dataspace);
+
+    $this->assertEqual($page->capture(), '2005 01 20');
+  }
+}
+

Copied: 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NLowercaseFilterTest.class.php (from rev 6721, 3.x/trunk/limb/i18n/tests/cases/wact/tags/i18n/lmbI18NLowercaseFilterTest.class.php)
===================================================================
--- 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NLowercaseFilterTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NLowercaseFilterTest.class.php	2008-01-22 08:41:12 UTC (rev 6722)
@@ -0,0 +1,51 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com 
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ */
+require_once('limb/i18n/utf8.inc.php');
+
+class lmbI18NLowercaseFilterTest extends lmbWactTestCase
+{
+  var $prev_driver;
+
+  function setUp()
+  {
+    $this->prev_driver = lmb_use_charset_driver(new lmbUTF8BaseDriver());
+    parent :: setUp();
+  }
+
+  function tearDown()
+  {
+    lmb_use_charset_driver($this->prev_driver);
+    parent :: tearDown();
+  }
+
+  function testSimple()
+  {
+    $template = '{$"ТЕСТ"|i18n_lowercase}';
+
+    $this->registerTestingTemplate('/limb/locale_lowercase_filter.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_lowercase_filter.html');
+
+    $this->assertEqual($page->capture(), 'тест');
+  }
+
+  function testDBE()
+  {
+    $template = '{$var|i18n_lowercase}';
+
+    $this->registerTestingTemplate('/limb/locale_lowercase_filter_dbe.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_lowercase_filter_dbe.html');
+    $page->set('var', 'ТесТ');
+
+    $this->assertEqual($page->capture(), 'тест');
+  }
+
+}
+

Copied: 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NNumberFilterTest.class.php (from rev 6721, 3.x/trunk/limb/i18n/tests/cases/wact/tags/i18n/lmbI18NNumberFilterTest.class.php)
===================================================================
--- 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NNumberFilterTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NNumberFilterTest.class.php	2008-01-22 08:41:12 UTC (rev 6722)
@@ -0,0 +1,150 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com 
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ */
+lmb_require('limb/i18n/src/toolkit/lmbI18NTools.class.php');
+
+class lmbI18NNumberFilterTest extends lmbWactTestCase
+{
+  protected $locale;
+
+  function setUp()
+  {
+    parent :: setUp();
+
+    $this->locale = new lmbLocale('en');
+    $this->locale->fract_digits = 2;
+    $this->locale->decimal_symbol = '.';
+    $this->locale->thousand_separator = ',';
+    $this->toolkit->addLocaleObject($this->locale);
+  }
+
+  function testUseDefaultLocale()
+  {
+    $this->toolkit->setLocale('en');
+
+    $template = '{$"100000"|i18n_number}';
+
+    $this->registerTestingTemplate('/limb/locale_number_filter_default.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_number_filter_default.html');
+
+    $this->assertEqual($page->capture(), '100,000.00');
+  }
+
+  function testUseOtherLocale()
+  {
+    $this->locale->fract_digits = 4;
+    $this->toolkit->addLocaleObject($this->locale, 'foo');
+
+    $template = '{$"100000"|i18n_number:"foo"}';
+
+    $this->registerTestingTemplate('/limb/locale_number_filter_russian.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_number_filter_russian.html');
+
+    $this->assertEqual($page->capture(), '100,000.0000');
+  }
+
+  function testUseFractDigits()
+  {
+    $template = '{$"100000"|i18n_number:"en","3"}';
+
+    $this->registerTestingTemplate('/limb/locale_number_filter_fract_digits.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_number_filter_fract_digits.html');
+
+    $this->assertEqual($page->capture(), '100,000.000');
+  }
+
+  function testUseDecimalSymbol()
+  {
+    $template = '{$"100000"|i18n_number:"en","",","}';
+
+    $this->registerTestingTemplate('/limb/locale_number_filter_decimal_symbol.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_number_filter_decimal_symbol.html');
+
+    $this->assertEqual($page->capture(), '100,000,00');
+  }
+
+  function testUseThousandSeparator()
+  {
+    $template = '{$"100000"|i18n_number:"en","",""," "}';
+
+    $this->registerTestingTemplate('/limb/locale_number_filter_thousand_separator.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_number_filter_thousand_separator.html');
+
+    $this->assertEqual($page->capture(), '100 000.00');
+  }
+
+  function testDefaultDBE()
+  {
+    $template = '{$var|i18n_number}';
+
+    $this->registerTestingTemplate('/limb/locale_number_filter_DBE.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_number_filter_DBE.html');
+
+    $page->set('var', '100000');
+
+    $this->assertEqual($page->capture(), '100,000.00');
+  }
+
+  function testDBEUseOtherLocale()
+  {
+    $this->locale->fract_digits = 4;
+    $this->toolkit->addLocaleObject($this->locale, 'foo');
+
+    $template = '{$var|i18n_number:"foo"}';
+
+    $this->registerTestingTemplate('/limb/locale_number_filter_DBE_other_locale.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_number_filter_DBE_other_locale.html');
+    $page->set('var', '100000');
+
+    $this->assertEqual($page->capture(), '100,000.0000');
+  }
+
+  function testDBEUseFractDigits()
+  {
+    $template = '{$var|i18n_number:"en","3"}';
+
+    $this->registerTestingTemplate('/limb/locale_number_filter_DBE_fract_digits.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_number_filter_DBE_fract_digits.html');
+    $page->set('var', '100000');
+
+    $this->assertEqual($page->capture(), '100,000.000');
+  }
+
+  function testDBEUseDecimalSymbol()
+  {
+    $template = '{$var|i18n_number:"en","",","}';
+
+    $this->registerTestingTemplate('/limb/locale_number_filter_DBE_decimal_symbol.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_number_filter_DBE_decimal_symbol.html');
+    $page->set('var', '100000');
+
+    $this->assertEqual($page->capture(), '100,000,00');
+  }
+
+  function testDBEUseThousandSeparator()
+  {
+    $template = '{$var|i18n_number:"en","",""," "}';
+
+    $this->registerTestingTemplate('/limb/locale_number_filter_DBE_thousand_separator.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_number_filter_DBE_thousand_separator.html');
+    $page->set('var', '100000');
+
+    $this->assertEqual($page->capture(), '100 000.00');
+  }
+}
+

Copied: 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NStringFilterTest.class.php (from rev 6721, 3.x/trunk/limb/i18n/tests/cases/wact/tags/i18n/lmbI18NStringFilterTest.class.php)
===================================================================
--- 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NStringFilterTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NStringFilterTest.class.php	2008-01-22 08:41:12 UTC (rev 6722)
@@ -0,0 +1,84 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com 
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ */
+lmb_require('limb/i18n/src/translation/lmbI18NDictionary.class.php');
+
+class lmbI18NStringFilterTest extends lmbWactTestCase
+{
+  function testUseCurrentLocale()
+  {
+    $dictionary = new lmbI18NDictionary();
+    $dictionary->add('Apply filter', 'Применить фильтр');
+
+    $this->toolkit->setDictionary('ru', 'foo', $dictionary);
+    $this->toolkit->setLocale('ru');
+
+    $template = '{$"Apply filter"|i18n:"foo"}';
+
+    $this->registerTestingTemplate('/limb/locale_string_filter_locale.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_string_filter_locale.html');
+
+    $this->assertEqual($page->capture(), 'Применить фильтр');
+  }
+
+  function testWithAttributes()
+  {
+    $dictionary = new lmbI18NDictionary();
+    $dictionary->add('Apply %1 filter and %2', 'Применить фильтр %1 и %2');
+
+    $this->toolkit->setDictionary('ru', 'foo', $dictionary);
+    $this->toolkit->setLocale('ru');
+
+    $template = '{$"Apply %1 filter and %2"|i18n:"foo", "%1", "1", "%2", "2"}';
+
+    $this->registerTestingTemplate('/limb/locale_string_filter_with_attributes.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_string_filter_with_attributes.html');
+
+    $this->assertEqual($page->capture(), 'Применить фильтр 1 и 2');
+  }
+
+  function testWithDBEAttributes()
+  {
+    $dictionary = new lmbI18NDictionary();
+    $dictionary->add('Apply %name% filter to %var%', 'Применить фильтр %name% к %var%');
+
+    $this->toolkit->setDictionary('ru', 'foo', $dictionary);
+    $this->toolkit->setLocale('ru');
+
+    $template = '{$"Apply %name% filter to %var%"|i18n:"foo", "%name%", name, "%var%", variable.name}';
+
+    $this->registerTestingTemplate('/limb/locale_string_filter_with_dbe_attributes.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_string_filter_with_dbe_attributes.html');
+    $page->set('name', 'ИмяФильтра');
+    $page->set('variable', array('name' =>'ИмяПеременной'));
+    $this->assertEqual($page->capture(), 'Применить фильтр ИмяФильтра к ИмяПеременной');
+  }
+
+  function testDBEVariable()
+  {
+    $dictionary = new lmbI18NDictionary();
+    $dictionary->add('Apply filter', 'Применить фильтр');
+
+    $this->toolkit->setDictionary('ru', 'foo', $dictionary);
+    $this->toolkit->setLocale('ru');
+
+    $template = '{$var|i18n:"foo"}';
+
+    $this->registerTestingTemplate('/limb/locale_string_filter_dbe.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_string_filter_dbe.html');
+    $page->set('var', 'Apply filter');
+
+    $this->assertTrue($page->capture(), 'Применить фильтр');
+  }
+
+}
+

Copied: 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NTrimFilterTest.class.php (from rev 6721, 3.x/trunk/limb/i18n/tests/cases/wact/tags/i18n/lmbI18NTrimFilterTest.class.php)
===================================================================
--- 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NTrimFilterTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NTrimFilterTest.class.php	2008-01-22 08:41:12 UTC (rev 6722)
@@ -0,0 +1,59 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com 
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ */
+
+class lmbI18NTrimFilterTest extends lmbWactTestCase
+{
+  function testSimple()
+  {
+    $template = '{$" тест "|i18n_trim}';
+
+    $this->registerTestingTemplate('/limb/locale_trim_filter.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_trim_filter.html');
+
+    $this->assertEqual($page->capture(), 'тест');
+  }
+
+  function testCharacters()
+  {
+    $template = '{$"ф:тест:ф"|i18n_trim:"ф"}';
+
+    $this->registerTestingTemplate('/limb/locale_trim_filter_characters.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_trim_filter_characters.html');
+
+    $this->assertEqual($page->capture(), ':тест:');
+  }
+
+  function testDBE()
+  {
+    $template = '{$var|i18n_trim}';
+
+    $this->registerTestingTemplate('/limb/locale_trim_filter_dbe.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_trim_filter_dbe.html');
+    $page->set('var', ' тест ');
+
+    $this->assertEqual($page->capture(), 'тест');
+  }
+
+  function testDBECharacters()
+  {
+    $template = '{$var|i18n_trim: "ф"}';
+
+    $this->registerTestingTemplate('/limb/locale_trim_filter_dbe_characters.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_trim_filter_dbe_characters.html');
+    $page->set('var', 'ф:тест:ф');
+
+    $this->assertEqual($page->capture(), ':тест:');
+  }
+
+}
+

Copied: 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NUppercaseFilterTest.class.php (from rev 6721, 3.x/trunk/limb/i18n/tests/cases/wact/tags/i18n/lmbI18NUppercaseFilterTest.class.php)
===================================================================
--- 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NUppercaseFilterTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/i18n/tests/cases/wact/lmbI18NUppercaseFilterTest.class.php	2008-01-22 08:41:12 UTC (rev 6722)
@@ -0,0 +1,51 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com 
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ */
+require_once('limb/i18n/utf8.inc.php');
+
+class lmbI18NUppercaseFilterTest extends lmbWactTestCase
+{
+  var $prev_driver;
+
+  function setUp()
+  {
+    parent :: setUp();
+    $this->prev_driver = lmb_use_charset_driver(new lmbUTF8BaseDriver());
+  }
+
+  function tearDown()
+  {
+    lmb_use_charset_driver($this->prev_driver);
+    parent :: tearDown();
+  }
+
+  function testSimple()
+  {
+    $template = '{$"тест"|i18n_uppercase}';
+
+    $this->registerTestingTemplate('/limb/locale_uppercase_filter.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_uppercase_filter.html');
+
+    $this->assertEqual($page->capture(), 'ТЕСТ');
+  }
+
+  function testDBE()
+  {
+    $template = '{$var|i18n_uppercase}';
+
+    $this->registerTestingTemplate('/limb/locale_uppercase_filter_dbe.html', $template);
+
+    $page = $this->initTemplate('/limb/locale_uppercase_filter_dbe.html');
+    $page->set('var', 'ТесТ');
+
+    $this->assertEqual($page->capture(), 'ТЕСТ');
+  }
+
+}
+



More information about the limb-svn mailing list