|
5 | 5 |
|
6 | 6 | class GP_Test_Template_Helper_Functions extends GP_UnitTestCase { |
7 | 7 |
|
8 | | - function test_map_glossary_entries_to_translation_originals_with_ampersand_in_glossary() { |
9 | | - $test_string = 'This string, <code></body></code>, should not have the code tags mangled.'; |
10 | | - $orig = ''; |
11 | | - $expected_result = 'This string, <code>&lt;/body<span class="glossary-word" data-translations="[{"translation":"&amp;","pos":"interjection","comment":null,"locale_entry":""}]">&</span>gt;</code>, should not have the code tags mangled.'; |
| 8 | + /** |
| 9 | + * Data provider. |
| 10 | + * |
| 11 | + * @var array |
| 12 | + */ |
| 13 | + function provide_test_map_glossary_entries_to_translation_originals_with_ampersand_in_glossary() { |
| 14 | + return array( |
| 15 | + // Shouldn't mangle the code tags. |
| 16 | + array( |
| 17 | + 'test_string' => 'This string, <code></body></code>, should not have the code tags mangled.', |
| 18 | + 'expected_result' => 'This string, <code>&lt;/body<span class="glossary-word" data-translations="[{"translation":"&amp;","pos":"interjection","comment":null,"locale_entry":""}]">&</span>gt;</code>, should not have the code tags mangled.', |
| 19 | + ), |
| 20 | + array( |
| 21 | + 'test_string' => 'Products & Services', |
| 22 | + 'expected_result' => 'Products & Services', // Wrong: Should match. |
| 23 | + ), |
| 24 | + // Test word left bound. |
| 25 | + array( |
| 26 | + 'test_string' => 'Products ,& Services', |
| 27 | + 'expected_result' => 'Products ,& Services', // Wrong: Should match. |
| 28 | + ), |
| 29 | + // Test word right bound. |
| 30 | + array( |
| 31 | + 'test_string' => 'Products ,& Services', |
| 32 | + 'expected_result' => 'Products ,& Services', // Wrong: Should match. |
| 33 | + ), |
| 34 | + // Test word both bounds. |
| 35 | + array( |
| 36 | + 'test_string' => 'Products ,&. Services', |
| 37 | + 'expected_result' => 'Products ,&. Services', // Wrong: Should match. |
| 38 | + ), |
| 39 | + // Don't match examples. |
| 40 | + array( |
| 41 | + 'test_string' => 'Shop > Products & Services', |
| 42 | + 'expected_result' => 'Shop &gt; Products &amp; Services', |
| 43 | + ), |
| 44 | + // Match the simple &. |
| 45 | + array( |
| 46 | + 'test_string' => 'Shop > Products & Services', |
| 47 | + 'expected_result' => 'Shop &gt; Products & Services', |
| 48 | + ), |
| 49 | + ); |
| 50 | + } |
12 | 51 |
|
| 52 | + /** |
| 53 | + * Expects matching glossary term '&'. |
| 54 | + * |
| 55 | + * @dataProvider provide_test_map_glossary_entries_to_translation_originals_with_ampersand_in_glossary |
| 56 | + */ |
| 57 | + function test_map_glossary_entries_to_translation_originals_with_ampersand_in_glossary( $test_string, $expected_result ) { |
13 | 58 | $entry = new Translation_Entry( array( 'singular' => $test_string, ) ); |
14 | 59 |
|
15 | 60 | $set = $this->factory->translation_set->create_with_project_and_locale(); |
|
0 commit comments