[ Index ] |
PHP Cross Reference of GlotPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @group strings 5 */ 6 class GP_Test_Strings extends GP_UnitTestCase { 7 function test_gp_string_similarity() { 8 $string1 = 'Word'; 9 $string2 = 'Word!'; 10 $string3 = 'Word'; 11 12 $similarity = gp_string_similarity( $string1, $string2 ); 13 $similarity_2 = gp_string_similarity( $string1, $string3 ); 14 15 $this->assertEquals( $similarity, 0.775 ); 16 $this->assertEquals( $similarity_2, 1 ); 17 } 18 19 /** 20 * @dataProvider data_attributes_with_entities 21 */ 22 function test_gp_esc_attr_with_entities( $expected, $attribute ) { 23 $this->assertEquals( $expected, gp_esc_attr_with_entities( $attribute ) ); 24 } 25 26 function data_attributes_with_entities() { 27 return array( 28 array( '&#8212;', '—' ), // https://glotpress.trac.wordpress.org/ticket/12 29 array( 'Foo & Bar', 'Foo & Bar' ), 30 array( '"&hellip;"', '"…"' ), 31 ); 32 } 33 34 /** 35 * @dataProvider data_translations_with_entities 36 */ 37 function test_esc_translation( $expected, $translation ) { 38 $this->assertEquals( $expected, esc_translation( $translation ) ); 39 } 40 41 function data_translations_with_entities() { 42 return array( 43 array( 'Foo bar&hellip;', 'Foo bar…' ), 44 array( 'Foo <span class="count">(%s)</span>', 'Foo <span class="count">(%s)</span>' ), 45 array( '"&hellip;"', '"…"' ), 46 ); 47 } 48 49 function test_gp_sanitize_project_name() { 50 $this->assertEquals( gp_sanitize_slug( 'plugin V1.2.1' ), 'plugin-v1.2.1' ); 51 $this->assertEquals( gp_sanitize_slug( 'plugin \/<1.2.1>' ), 'plugin' ); 52 $this->assertEquals( gp_sanitize_slug( 'GlotPress&Plugin@1.1.1' ), 'glotpressplugin1.1.1' ); 53 } 54 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:01:07 2024 | Cross-referenced by PHPXref 0.7.1 |