Make WordPress Core

Changeset 409 in tests


Ignore:
Timestamp:
08/04/2011 09:58:47 PM (14 years ago)
Author:
ryan
Message:

Smilies test. Props jakub.tyrcha. see #17

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_formatting.php

    r407 r409  
    10021002}
    10031003
     1004class TestSmilies extends WPTestCase {
     1005
     1006    function test_convert_smilies() {
     1007        global $wpsmiliestrans;
     1008        $includes_path = includes_url("images/smilies/");
     1009
     1010        // standard smilies, use_smilies: ON
     1011        update_option( 'use_smilies', 1 );
     1012
     1013        smilies_init();
     1014
     1015        $inputs = array(
     1016                        'Lorem ipsum dolor sit amet mauris ;-) Praesent gravida sodales. :lol: Vivamus nec diam in faucibus eu, bibendum varius nec, imperdiet purus est, at augue at lacus malesuada elit dapibus a, :eek: mauris. Cras mauris viverra elit. Nam laoreet viverra. Pellentesque tortor. Nam libero ante, porta urna ut turpis. Nullam wisi magna, :mrgreen: tincidunt nec, sagittis non, fringilla enim. Nam consectetuer nec, ullamcorper pede eu dui odio consequat vel, vehicula tortor quis pede turpis cursus quis, egestas ipsum ultricies ut, eleifend velit. Mauris vestibulum iaculis. Sed in nunc. Vivamus elit porttitor egestas. Mauris purus :?:',
     1017                        '<strong>Welcome to the jungle!</strong> We got fun n games! :) We got everything you want 8) <em>Honey we know the names :)</em>',
     1018                        "<strong;)>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",
     1019                        '<strong style="here comes the sun :-D">and I say it\'s allright:D:D',
     1020                        '<!-- Woo-hoo, I\'m a comment, baby! :x > -->',
     1021                        ':?:P:?::-x:mrgreen:::', /*
     1022                        'the question is, <textarea>Should smilies be converted in textareas :?:</textarea>',
     1023                        'the question is, <code>Should smilies be converted in code or pre tags :?:</code>',
     1024                        'the question is, <code style="color:#fff">Should smilies be converted in code or pre tags :?:</code>',
     1025                        'the question is, <code>Should smilies be converted in invalid code or pre tags :?:</pre>',
     1026                        '<Am I greedy?>Yes I am :)> :) The world makes me :mad:' */
     1027                        );
     1028
     1029        $outputs = array(
     1030                        'Lorem ipsum dolor sit amet mauris <img src=\''.$includes_path.'icon_wink.gif\' alt=\';-)\' class=\'wp-smiley\' />  Praesent gravida sodales. <img src=\''.$includes_path.'icon_lol.gif\' alt=\':lol:\' class=\'wp-smiley\' />  Vivamus nec diam in faucibus eu, bibendum varius nec, imperdiet purus est, at augue at lacus malesuada elit dapibus a, <img src=\''.$includes_path.'icon_surprised.gif\' alt=\':eek:\' class=\'wp-smiley\' />  mauris. Cras mauris viverra elit. Nam laoreet viverra. Pellentesque tortor. Nam libero ante, porta urna ut turpis. Nullam wisi magna, <img src=\''.$includes_path.'icon_mrgreen.gif\' alt=\':mrgreen:\' class=\'wp-smiley\' />  tincidunt nec, sagittis non, fringilla enim. Nam consectetuer nec, ullamcorper pede eu dui odio consequat vel, vehicula tortor quis pede turpis cursus quis, egestas ipsum ultricies ut, eleifend velit. Mauris vestibulum iaculis. Sed in nunc. Vivamus elit porttitor egestas. Mauris purus <img src=\''.$includes_path.'icon_question.gif\' alt=\':?:\' class=\'wp-smiley\' /> ',
     1031                        '<strong>Welcome to the jungle!</strong> We got fun n games! <img src=\''.$includes_path.'icon_smile.gif\' alt=\':)\' class=\'wp-smiley\' />  We got everything you want <img src=\''.$includes_path.'icon_cool.gif\' alt=\'8)\' class=\'wp-smiley\' /> <em>Honey we know the names <img src=\''.$includes_path.'icon_smile.gif\' alt=\':)\' class=\'wp-smiley\' /> </em>',
     1032                        "<strong;)>a little bit of this\na little bit:other: of that <img src='{$includes_path}icon_biggrin.gif' alt=':D' class='wp-smiley' />  <img src='{$includes_path}icon_biggrin.gif' alt=':D' class='wp-smiley' />  a little bit of good\nyeah with a little bit of bad8O",
     1033                        '<strong style="here comes the sun :-D">and I say it\'s allright:D:D',
     1034                        '<!-- Woo-hoo, I\'m a comment, baby! :x > -->',
     1035                        ' <img src=\''.$includes_path.'icon_question.gif\' alt=\':?:\' class=\'wp-smiley\' /> P:?::-x:mrgreen:::', /*
     1036                        'the question is, <textarea>Should smilies be converted in textareas :?:</textarea>',
     1037                        'the question is, <code>Should smilies be converted in code or pre tags :?:</code>',
     1038                        'the question is, <code style="color:#fff">Should smilies be converted in code or pre tags :?:</code>',
     1039                        'the question is, <code>Should smilies be converted in invalid code or pre tags :?:</pre>',
     1040                        '<Am I greedy?>Yes I am <img src=\''.$includes_path.'icon_smile.gif\' alt=\':)\' class=\'wp-smiley\' /> > <img src=\''.$includes_path.'icon_smile.gif\' alt=\':)\' class=\'wp-smiley\' />  The world makes me <img src=\'http://wp-test.php/wp-includes/images/smilies/icon_mad.gif\' alt=\':mad:\' class=\'wp-smiley\' />' */
     1041                        );
     1042
     1043        foreach ( $inputs as $k => $input ) {
     1044            $this->assertEquals( $outputs[$k], convert_smilies($input) );
     1045        }
     1046
     1047        update_option( 'use_smilies', 0 );
     1048
     1049        // standard smilies, use_smilies: OFF
     1050
     1051        foreach ( $inputs as $input ) {
     1052            $this->assertEquals( $input, convert_smilies($input) );
     1053        }
     1054
     1055        return;
     1056
     1057        // custom smilies, use_smilies: ON
     1058        update_option( 'use_smilies', 1 );
     1059        $wpsmiliestrans = array(
     1060          ':PP' => 'icon_tongue.gif',
     1061          ':arrow:' => 'icon_arrow.gif',
     1062          ':monkey:' => 'icon_shock_the_monkey.gif',
     1063          ':nervou:' => 'icon_nervou.gif'
     1064        );
     1065
     1066        smilies_init();
     1067
     1068        $inputs = array('Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. :monkey:',
     1069                        'Star Wars Jedi Knight:arrow: Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. :nervou:',
     1070                        ':arrow:monkey:Lorem ipsum dolor sit amet enim. Etiam ullam:PP<br />corper. Suspendisse a pellentesque dui, non felis.<a>:arrow::arrow</a>'
     1071                        );
     1072
     1073        $outputs = array('Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. <img src=\''.$includes_path.'icon_shock_the_monkey.gif\' alt=\'icon_arrow\' class=\'wp-smiley\' />',
     1074                        'Star Wars Jedi Knight<img src=\''.$includes_path.'icon_arrow.gif\' alt=\'icon_arrow\' class=\'wp-smiley\' /> Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. <img src=\''.$includes_path.'icon_nervou.gif\' alt=\'icon_nervou\' class=\'wp-smiley\' />',
     1075                        '<img src=\''.$includes_path.'icon_arrow.gif\' alt=\'icon_arrow\' class=\'wp-smiley\' />monkey:Lorem ipsum dolor sit amet enim. Etiam ullam<img src=\''.$includes_path.'icon_tongue.gif\' alt=\'icon_tongue\' class=\'wp-smiley\' /><br />corper. Suspendisse a pellentesque dui, non felis.<a><img src=\''.$includes_path.'icon_arrow.gif\' alt=\'icon_arrow\' class=\'wp-smiley\' />:arrow</a>'
     1076                        );
     1077
     1078        foreach ( $inputs as $k => $input ) {
     1079            $this->assertEquals( $outputs[$k], convert_smilies($input) );
     1080        }
     1081    }
     1082}
     1083
    10041084?>
Note: See TracChangeset for help on using the changeset viewer.