From 342d132b37bf25783771719bf6144e1d77190bfd Mon Sep 17 00:00:00 2001 From: Ella Iseulde Van Dorpe Date: Sun, 17 Jan 2016 23:37:51 +0000 Subject: [PATCH] Fix unit tests after [36336] git-svn-id: https://develop.svn.wordpress.org/trunk@36337 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/formatting/Smilies.php | 57 +++++++++++----------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/tests/phpunit/tests/formatting/Smilies.php b/tests/phpunit/tests/formatting/Smilies.php index ff38c6e5bb..5e487c2312 100644 --- a/tests/phpunit/tests/formatting/Smilies.php +++ b/tests/phpunit/tests/formatting/Smilies.php @@ -20,7 +20,7 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { ), array ( 'Welcome to the jungle! We got fun n games! :) We got everything you want 8-) Honey we know the names :)', - "Welcome to the jungle! We got fun n games! \":)\" We got everything you want \xf0\x9f\x98\x8e Honey we know the names \":)\"" + "Welcome to the jungle! We got fun n games! \xf0\x9f\x99\x82 We got everything you want \xf0\x9f\x98\x8e Honey we know the names \xf0\x9f\x99\x82" ), array ( "a little bit of this\na little bit:other: of that :D\n:D a little bit of good\nyeah with a little bit of bad8O", @@ -169,7 +169,7 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { return array ( array ( '8-O :-(', - "\xf0\x9f\x98\xaf \":-(\"" + "\xf0\x9f\x98\xaf \xf0\x9f\x99\x81" ), array ( '8-) 8-O', @@ -181,15 +181,15 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { ), array ( '8-) :-(', - "\xf0\x9f\x98\x8e \":-(\"" + "\xf0\x9f\x98\x8e \xf0\x9f\x99\x81" ), array ( '8-) :twisted:', "\xf0\x9f\x98\x8e \xf0\x9f\x98\x88" ), array ( - '8O :twisted: :( :? :(', - "\xf0\x9f\x98\xaf \xf0\x9f\x98\x88 \":(\" \xf0\x9f\x98\x95 \":(\"" + '8O :twisted: :( :? :roll:', + "\xf0\x9f\x98\xaf \xf0\x9f\x98\x88 \xf0\x9f\x99\x81 \xf0\x9f\x98\x95 \":roll:\"" ), ); } @@ -272,6 +272,25 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { $wpsmiliestrans = $orig_trans; // reset original translations array } + public function get_spaces_around_smilies() { + $nbsp = "\xC2\xA0"; + + return array( + array( + 'test :) smile', + "test \xf0\x9f\x99\x82 smile" + ), + array( + 'test  :) smile', + "test  \xf0\x9f\x99\x82 smile" + ), + array( + "test {$nbsp}:){$nbsp}smile", + "test {$nbsp}\xf0\x9f\x99\x82{$nbsp}smile" + ) + ); + } + /** * Check that $wp_smiliessearch pattern will match smilies * between spaces, but never capture those spaces. @@ -280,35 +299,15 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { * or added when replacing the text with an image. * * @ticket 22692 + * @dataProvider get_spaces_around_smilies */ - function test_spaces_around_smilies() { - $nbsp = "\xC2\xA0"; - + function test_spaces_around_smilies( $in_txt, $converted_txt ) { // standard smilies, use_smilies: ON update_option( 'use_smilies', 1 ); + smilies_init(); - $input = array(); - $output = array(); - - $input[] = 'My test :) smile'; - $output[] = array('test smile'); - - $input[] = 'My test  :) smile'; - $output[] = array('test   smile'); - - $input[] = "My test {$nbsp}:){$nbsp}smile"; - $output[] = array("test {$nbsp}{$nbsp}smile"); - - foreach($input as $key => $in) { - $result = convert_smilies( $in ); - foreach($output[$key] as $out) { - - // Each output element must appear in the results. - $this->assertContains( $out, $result ); - - } - } + $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) ); // standard smilies, use_smilies: OFF update_option( 'use_smilies', 0 );