From 3f5712a450a54ab184f526db7ae01595c59a2ac0 Mon Sep 17 00:00:00 2001
From: Matias Benedetto This is a test text with HTML.
This is a test text.
', - 'expected_markup' => '', + 'expected_markup' => '', ), 'paragraph on nested groups' => array( @@ -46,7 +46,7 @@ public function data_test_escape_text_content_of_blocks() { 'El polvo elemental que nos ignora+
y que fue el rojo Adán y que es ahora
todos los hombres, y que no veremos.\', \'test-locale-theme\');?>
El polvo elemental que nos ignora', ), @@ -119,7 +119,7 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' - + ', ), @@ -130,7 +130,7 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' - + ', ), @@ -143,8 +143,8 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' -
y que fue el rojo Adán y que es ahora
todos los hombres, y que no veremos.\', \'test-locale-theme\') );?>
This is text to localize
'; $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "", $new_template->content ); + $this->assertStringContainsString( "", $new_template->content ); $this->assertStringNotContainsString( 'This is text to localize
', $new_template->content ); } @@ -37,7 +37,7 @@ public function test_paragraphs_in_groups_are_localized() {This is text to localize
', $new_template->content ); } @@ -49,7 +49,7 @@ public function test_buttons_are_localized() {Here is some verse to localize'; $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "verse to localize', '');?>", $new_template->content ); + $this->assertStringContainsString( "verse to localize', '') );?>", $new_template->content ); } public function test_localize_table() { @@ -274,10 +274,10 @@ public function test_localize_table() { '; $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "
This is a test text with HTML.
'; - $escaped_string = CBT_Theme_Locale::escape_string( $string ); - $this->assertEquals( "This is a test text with HTML.', 'test-locale-theme') );?>", $escaped_string ); - } - - public function test_escape_string_with_already_escaped_string() { - $string = ""; - $escaped_string = CBT_Theme_Locale::escape_string( $string ); - $this->assertEquals( $string, $escaped_string ); - } - - public function test_escape_string_with_non_string() { - $string = null; - $escaped_string = CBT_Theme_Locale::escape_string( $string ); - $this->assertEquals( $string, $escaped_string ); - } -} - diff --git a/tests/CbtThemeLocale/escapeTextContentOfBlocks.php b/tests/CbtThemeLocale/escapeTextContentOfBlocks.php index 9c279c85..59d86e44 100644 --- a/tests/CbtThemeLocale/escapeTextContentOfBlocks.php +++ b/tests/CbtThemeLocale/escapeTextContentOfBlocks.php @@ -130,7 +130,7 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' - + ', ), @@ -143,7 +143,7 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' -This is a test text.
', - 'expected_markup' => '', + 'expected_markup' => '', ), 'paragraph on nested groups' => array( @@ -46,7 +46,7 @@ public function data_test_escape_text_content_of_blocks() { 'El polvo elemental que nos ignora+
y que fue el rojo Adán y que es ahora
todos los hombres, y que no veremos.\', \'test-locale-theme\') );?>
El polvo elemental que nos ignora', ), @@ -119,7 +119,7 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' - + ', ), @@ -130,7 +130,7 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' - + ', ), @@ -143,8 +143,8 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' -
y que fue el rojo Adán y que es ahora
todos los hombres, y que no veremos.\', \'test-locale-theme\' ) ); ?>
This is text to localize
'; $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "", $new_template->content ); + $this->assertStringContainsString( "", $new_template->content ); $this->assertStringNotContainsString( 'This is text to localize
', $new_template->content ); } + public function test_empty_paragraphs_are_not_localized() { + $template = new stdClass(); + $template->content = ''; + $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); + $this->assertStringContainsString( '', $new_template->content ); + $this->assertStringNotContainsString( 'esc_html_e', $new_template->content ); + } + /** * Ensure that escape_text_in_template is not called when the localizeText flag is set to false */ @@ -37,7 +45,7 @@ public function test_paragraphs_in_groups_are_localized() {This is text to localize
', $new_template->content ); } @@ -49,7 +57,7 @@ public function test_buttons_are_localized() {Here is some verse to localize'; $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "verse to localize', '') );?>", $new_template->content ); + $this->assertStringContainsString( "verse to localize', '' ) ); ?>", $new_template->content ); } public function test_localize_table() { @@ -274,10 +293,10 @@ public function test_localize_table() { '; $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "
El polvo elemental que nos ignora+
y que fue el rojo Adán y que es ahora
todos los hombres, y que no veremos.\', \'test-locale-theme\' ) ); ?>
El polvo elemental que nos ignora', ), diff --git a/tests/test-theme-templates.php b/tests/test-theme-templates.php index ce8fc79a..0ab57e2c 100644 --- a/tests/test-theme-templates.php +++ b/tests/test-theme-templates.php @@ -143,7 +143,7 @@ public function test_properly_encode_quotes_and_doublequotes() { '; $escaped_template = CBT_Theme_Templates::escape_text_in_template( $template ); - /* That looks like a mess, but what it should look like for REAL is */ + /* That looks like a mess, but what it should look like for REAL is */ $this->assertStringContainsString( "", $escaped_template->content ); } @@ -164,7 +164,7 @@ public function test_properly_encode_html_markup() { '; $escaped_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "Bold text has feelings <> TOO', '' ) ); ?>", $escaped_template->content ); + $this->assertStringContainsString( "Bold text has feelings <> TOO', '' ); ?>", $escaped_template->content ); } public function test_empty_alt_text_is_not_localized() { @@ -262,7 +262,7 @@ public function test_localize_verse() {
y que fue el rojo Adán y que es ahora
todos los hombres, y que no veremos.\', \'test-locale-theme\' ); ?>
Here is some verse to localize'; $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "verse to localize', '' ) ); ?>", $new_template->content ); + $this->assertStringContainsString( "verse to localize', '' ); ?>", $new_template->content ); } public function test_localize_table() { From 90fe266094ac9b52fa8bebf9ee7478b3211bef36 Mon Sep 17 00:00:00 2001 From: Matias Benedetto
This is a test text with HTML.
'; + $escaped_string = $this->call_private_method( 'escape_text_content', array( $string ) ); + $this->assertEquals( "This is a test text with HTML.', 'test-locale-theme');?>", $escaped_string ); + } + + public function test_escape_text_content_with_already_escaped_string() { + $string = ""; + $escaped_string = $this->call_private_method( 'escape_text_content', array( $string ) ); + $this->assertEquals( $string, $escaped_string ); + } + + public function test_escape_text_content_with_non_string() { + $string = null; + $escaped_string = $this->call_private_method( 'escape_text_content', array( $string ) ); + $this->assertEquals( $string, $escaped_string ); + } +} diff --git a/tests/CbtThemeLocale/escapeTextContentOfBlocks.php b/tests/CbtThemeLocale/escapeTextContentOfBlocks.php index 296cb15d..2fee4adf 100644 --- a/tests/CbtThemeLocale/escapeTextContentOfBlocks.php +++ b/tests/CbtThemeLocale/escapeTextContentOfBlocks.php @@ -30,7 +30,7 @@ public function data_test_escape_text_content_of_blocks() { 'paragraph' => array( 'block_markup' => 'This is a test text.
', - 'expected_markup' => '', + 'expected_markup' => '', ), 'paragraph on nested groups' => array( @@ -46,7 +46,7 @@ public function data_test_escape_text_content_of_blocks() { 'El polvo elemental que nos ignora+
y que fue el rojo Adán y que es ahora
todos los hombres, y que no veremos.\', \'test-locale-theme\' ); ?>
El polvo elemental que nos ignora', ), @@ -119,7 +119,7 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' - + ', ), @@ -130,7 +130,7 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' - + ', ), @@ -143,8 +143,8 @@ public function data_test_escape_text_content_of_blocks() { ', 'expected_markup' => ' -
y que fue el rojo Adán y que es ahora
todos los hombres, y que no veremos.\', \'test-locale-theme\');?>
This is text to localize
'; $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "", $new_template->content ); + $this->assertStringContainsString( "", $new_template->content ); $this->assertStringNotContainsString( 'This is text to localize
', $new_template->content ); } @@ -45,7 +45,7 @@ public function test_paragraphs_in_groups_are_localized() {This is text to localize
', $new_template->content ); } @@ -57,7 +57,7 @@ public function test_buttons_are_localized() {Here is some verse to localize'; $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "verse to localize', '' ); ?>", $new_template->content ); + $this->assertStringContainsString( "verse to localize', '');?>", $new_template->content ); } public function test_localize_table() { @@ -293,10 +293,10 @@ public function test_localize_table() { '; $new_template = CBT_Theme_Templates::escape_text_in_template( $template ); - $this->assertStringContainsString( "