| [ Index ] |
PHP Cross Reference of GlotPress |
[Summary view] [Print] [Text view]
1 <?php 2 require_once ('init.php'); 3 4 class GP_Test_Translation_Warnings extends GP_UnitTestCase { 5 function setUp() { 6 parent::setUp(); 7 $this->is_baba = create_function('$o, $t, $l', 'return $t == "баба"? true : "error";'); 8 $this->is_equal = create_function('$o, $t, $l', 'return $t == $o? true : "error";'); 9 $this->w = new GP_Translation_Warnings; 10 $this->with_equal = new GP_Translation_Warnings; 11 $this->with_equal->add( 'is_equal', $this->is_equal ); 12 $this->standard_plural_locale = $this->factory->locale->create(); 13 } 14 15 function test_add() { 16 $this->w->add( 'is_baba', $this->is_baba ); 17 $this->assertEquals( true, $this->w->has( 'is_baba' ) ); 18 $this->assertEquals( false, $this->w->has( 'is_dyado' ) ); 19 } 20 21 function test_remove() { 22 $this->w->add( 'is_baba', $this->is_baba ); 23 $this->assertEquals( true, $this->w->has( 'is_baba' ) ); 24 $this->w->remove( 'is_baba' ); 25 $this->assertEquals( false, $this->w->has( 'is_baba' ) ); 26 } 27 28 function test_check() { 29 $this->w->add( 'is_baba', $this->is_baba ); 30 $this->assertEquals( array( 31 1 => array('is_baba' => 'error')), 32 $this->w->check( 'baba', null, array('баба', 'баби'), $this->standard_plural_locale ) ); 33 $this->assertEquals( null, 34 $this->w->check( 'baba', null, array('баба', 'баба', 'баба'), $this->standard_plural_locale ) ); 35 } 36 37 /** 38 * For the plural form, corresponding to the number 1 check only against the singular, not also against the plural 39 */ 40 function test_check_singular_plural_correspondence() { 41 $this->assertEquals( null, 42 $this->with_equal->check( 'baba', 'babas', array('baba', 'babas'), $this->standard_plural_locale ) ); 43 $this->assertEquals( array(1 => array('is_equal' => 'error')), 44 $this->with_equal->check( 'baba', 'babas', array('baba', 'baba'), $this->standard_plural_locale ) ); 45 $this->assertEquals( array(0 => array('is_equal' => 'error')), 46 $this->with_equal->check( 'baba', 'babas', array('babas', 'babas'), $this->standard_plural_locale ) ); 47 } 48 49 /** 50 * If a locale has no plural forms, we should check only against the plural original, since 51 * it probably contains the placeholders 52 */ 53 function test_check_no_plural_forms_locales() { 54 $no_plural_locale = new GP_Locale; 55 $no_plural_locale->nplurals = 1; 56 $no_plural_locale->plural_expression = '0'; 57 $this->assertEquals( null, 58 $this->with_equal->check( 'baba', 'babas', array('babas'), $no_plural_locale ) ); 59 $this->assertEquals( array(0 => array('is_equal' => 'error')), 60 $this->with_equal->check( 'baba', 'babas', array('baba'), $no_plural_locale ) ); 61 $this->assertEquals( array(0 => array('is_equal' => 'error')), 62 $this->with_equal->check( 'baba', 'babas', array('xxx'), $no_plural_locale ) ); 63 64 } 65 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu May 24 03:59:35 2012 | Hosted by follow the white rabbit. |