| [ 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/i18n/src/translation/lmbI18NDictionary.class.php'); 10 11 class lmbI18NDictionaryTest extends UnitTestCase 12 { 13 function testIsEmpty() 14 { 15 $d = new lmbI18NDictionary(); 16 $this->assertTrue($d->isEmpty()); 17 $d->add('Hello', 'Привет'); 18 $this->assertFalse($d->isEmpty()); 19 } 20 21 function testTranslateFailed() 22 { 23 $d = new lmbI18NDictionary(); 24 $this->assertFalse($d->has('Hello')); 25 $this->assertEqual($d->translate('Hello'), 'Hello'); 26 } 27 28 function testTranslateOk() 29 { 30 $d = new lmbI18NDictionary(); 31 $d->add('Hello', 'Привет'); 32 $this->assertTrue($d->has('Hello')); 33 $this->assertEqual($d->translate('Hello'), 'Привет'); 34 } 35 36 function testTranslateWithAttributes() 37 { 38 $d = new lmbI18NDictionary(); 39 $d->add('Hello {what}', 'Привет {what}'); 40 $this->assertEqual($d->translate('Hello {what}', array('{what}' => 'Bob')), 'Привет Bob'); 41 } 42 43 function testSetTranslations() 44 { 45 $d = new lmbI18NDictionary(); 46 $d->setTranslations(array('Hello' => 'Привет')); 47 $this->assertEqual($d->translate('Hello'), 'Привет'); 48 } 49 50 function testMergeAppend() 51 { 52 $d1 = new lmbI18NDictionary(); 53 $d1->add('Hello', 'Привет'); 54 55 $d2 = new lmbI18NDictionary(); 56 $d2->add('Test', 'Тест'); 57 58 $d3 = $d1->merge($d2); 59 60 $this->assertEqual($d3->translate('Hello'), 'Привет'); 61 $this->assertEqual($d3->translate('Test'), 'Тест'); 62 } 63 64 function testMergeReplace() 65 { 66 $d1 = new lmbI18NDictionary(); 67 $d1->add('Hello', 'Привет'); 68 69 $d2 = new lmbI18NDictionary(); 70 $d2->add('Hello', 'Привет снова'); 71 72 $d3 = $d1->merge($d2); 73 74 $this->assertEqual($d3->translate('Hello'), 'Привет снова'); 75 } 76 77 function testIsTranslated() 78 { 79 $d = new lmbI18NDictionary(); 80 $d->add('Hello', 'Привет'); 81 $d->add('Test'); 82 83 $this->assertTrue($d->isTranslated('Hello')); 84 $this->assertFalse($d->isTranslated('Test')); 85 86 $this->assertEqual($d->translate('Test'), 'Test'); 87 } 88 89 function testHasSameEntries() 90 { 91 $d1 = new lmbI18NDictionary(); 92 $d1->add('Hello', 'Привет'); 93 $d1->add('Test'); 94 95 $d2 = new lmbI18NDictionary(); 96 $d2->add('Test'); 97 $d2->add('Hello'); 98 99 $this->assertTrue($d1->hasSameEntries($d2)); 100 $this->assertFalse($d1->isEqual($d2)); 101 } 102 103 function testHasNotSameEntries() 104 { 105 $d1 = new lmbI18NDictionary(); 106 $d1->add('Foo', 'Foo'); 107 $d1->add('Test'); 108 109 $d2 = new lmbI18NDictionary(); 110 $d2->add('Test'); 111 $d2->add('Bar'); 112 113 $this->assertFalse($d1->hasSameEntries($d2)); 114 } 115 } 116 117 ?>
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 |