| 315 | |
| 316 | /** |
| 317 | * Test to ensure smilies can be removed with a filter |
| 318 | * |
| 319 | * @ticket 35905 |
| 320 | */ |
| 321 | public function test_smilies_filter_removes_smilies() { |
| 322 | add_filter( 'smilies', array( $this, '_filter_remove_smilies' ) ); |
| 323 | smilies_init(); |
| 324 | remove_filter( 'smilies', array( $this, '_filter_remove_smilies' ) ); |
| 325 | |
| 326 | $txt = ':oops: I did it again'; |
| 327 | |
| 328 | $this->assertEquals( $txt, convert_smilies( $txt ) ); |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Test to ensure smilies can be added with a filter |
| 333 | * |
| 334 | * @ticket 35905 |
| 335 | */ |
| 336 | public function test_smilies_filter_adds_smilies() { |
| 337 | add_filter( 'smilies', array( $this, '_filter_add_smilies' ) ); |
| 338 | smilies_init(); |
| 339 | remove_filter( 'smilies', array( $this, '_filter_add_smilies' ) ); |
| 340 | |
| 341 | $txt = 'You played with my <3'; |
| 342 | $expected_txt = 'You played with my \xe2\x9d\xa4'; |
| 343 | |
| 344 | $this->assertEquals( $expected_txt, convert_smilies( $txt ) ); |
| 345 | } |
| 346 | |
| 347 | |
| 348 | public function _filter_remove_smilies( $wpsmiliestrans ) { |
| 349 | unset( $wpsmiliestrans[':oops:'] ); |
| 350 | return $wpsmiliestrans; |
| 351 | } |
| 352 | |
| 353 | public function _filter_add_smilies( $wpsmiliestrans ) { |
| 354 | $wpsmiliestrans['<3'] = '\xe2\x9d\xa4'; |
| 355 | return $wpsmiliestrans; |
| 356 | } |