| [ Index ] |
PHP Cross Reference of GlotPress |
[Summary view] [Print] [Text view]
1 <?php 2 require_once( dirname( __FILE__ ) . '/../init.php'); 3 4 class GP_Test_Thing_Translation extends GP_UnitTestCase { 5 function test_translation_should_support_6_plurals() { 6 $plurals = array( 'translation_0' => 'Zero', 'translation_1' => 'One', 'translation_2' => 'Two', 'translation_3' => 'Three', 'translation_4' => 'Four', 'translation_5' => 'Five' ); 7 $translation = $this->factory->translation->create( $plurals ); 8 $this->assertEqualFields( $translation, $plurals ); 9 } 10 11 function test_translation_should_write_all_6_plurals_to_database() { 12 $plurals = array( 'translation_0' => 'Zero', 'translation_1' => 'One', 'translation_2' => 'Two', 'translation_3' => 'Three', 'translation_4' => 'Four', 'translation_5' => 'Five' ); 13 $translation = $this->factory->translation->create( $plurals ); 14 $translation->reload(); 15 $this->assertEqualFields( $translation, $plurals ); 16 } 17 18 function test_for_translation_shouldnt_exclude_originals_with_rejected_translation_if_status_has_untranslated() { 19 $set = $this->factory->translation_set->create_with_project_and_locale(); 20 $translation = $this->factory->translation->create_with_original_for_translation_set( $set ); 21 $translation->reject(); 22 $for_translation = GP::$translation->for_translation( $set->project, $set, 0, array( 'status' => 'untranslated' ) ); 23 $this->assertEquals( 1, count( $for_translation ) ); 24 $this->assertEquals( null, $for_translation[0]->id ); 25 } 26 27 function test_for_translation_should_include_untranslated_by_default() { 28 $set = $this->factory->translation_set->create_with_project_and_locale(); 29 $original1 = $this->factory->original->create( array( 'project_id' => $set->project_id ) ); 30 $original2 = $this->factory->original->create( array( 'project_id' => $set->project_id ) ); 31 $translation1 = $this->factory->translation->create( array( 'translation_set_id' => $set->id, 'original_id' => $original1->id, 'status' => 'current' ) ); 32 $for_translation = GP::$translation->for_translation( $set->project, $set, 0, array(), array('by' => 'translation', 'how' => 'asc') ); 33 $this->assertEquals( 2, count( $for_translation ) ); 34 $this->assertEquals( null, $for_translation[0]->id ); 35 $this->assertEquals( $translation1->id, $for_translation[1]->id ); 36 } 37 38 function test_for_translation_should_not_include_old_by_default() { 39 $set = $this->factory->translation_set->create_with_project_and_locale(); 40 $original1 = $this->factory->original->create( array( 'project_id' => $set->project_id ) ); 41 $original2 = $this->factory->original->create( array( 'project_id' => $set->project_id ) ); 42 $translation1_old = $this->factory->translation->create( array( 'translation_set_id' => $set->id, 'original_id' => $original1->id, 'status' => 'current' ) ); 43 $translation1_current = $this->factory->translation->create( array( 'translation_set_id' => $set->id, 'original_id' => $original1->id, 'status' => 'current' ) ); 44 $translation1_current->set_as_current(); 45 $for_translation = GP::$translation->for_translation( $set->project, $set, 0, array(), array('by' => 'translation', 'how' => 'asc') ); 46 $this->assertEquals( 2, count( $for_translation ) ); 47 $this->assertEquals( null, $for_translation[0]->id ); 48 $this->assertEquals( $translation1_current->id, $for_translation[1]->id ); 49 } 50 51 52 function test_for_translation_should_not_include_untranslated_for_single_status() { 53 $set = $this->factory->translation_set->create_with_project_and_locale(); 54 $original1 = $this->factory->original->create( array( 'project_id' => $set->project_id ) ); 55 $original2 = $this->factory->original->create( array( 'project_id' => $set->project_id ) ); 56 $translation1 = $this->factory->translation->create( array( 'translation_set_id' => $set->id, 'original_id' => $original1->id, 'status' => 'current' ) ); 57 $for_translation = GP::$translation->for_translation( $set->project, $set, 0, array('status' => 'current'), array('by' => 'translation', 'how' => 'asc') ); 58 $this->assertEquals( 1, count( $for_translation ) ); 59 $this->assertEquals( $translation1->id, $for_translation[0]->id ); 60 } 61 62 function test_for_export_should_include_untranslated() { 63 $set = $this->factory->translation_set->create_with_project_and_locale(); 64 $original1 = $this->factory->original->create( array( 'project_id' => $set->project_id ) ); 65 $original2 = $this->factory->original->create( array( 'project_id' => $set->project_id ) ); 66 $translation1 = $this->factory->translation->create( array( 'translation_set_id' => $set->id, 'original_id' => $original1->id, 'status' => 'current' ) ); 67 $for_export = GP::$translation->for_export( $set->project, $set, 0, array('status' => 'current'), array('by' => 'translation', 'how' => 'asc') ); 68 $this->assertEquals( 2, count( $for_export ) ); 69 $this->assertEquals( $translation1->id, $for_export[0]->id ); 70 71 } 72 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon May 20 03:59:54 2013 | Hosted by follow the white rabbit. |