wordpress-develop/tests/phpunit/tests/formatting/WpRichEditPre.php
Sergey Biryukov 164b22cf6a Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Props johnbillion, jrf, SergeyBiryukov.
See #38266.

git-svn-id: https://develop.svn.wordpress.org/trunk@48937 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-02 00:35:36 +00:00

38 lines
1.0 KiB
PHP

<?php
/**
* @group formatting
* @expectedDeprecated wp_richedit_pre
*/
class Tests_Formatting_WpRichEditPre extends WP_UnitTestCase {
function _charset_iso_8859_1() {
return 'iso-8859-1';
}
/*
* Only fails in PHP 5.4 onwards
* @ticket 23688
*/
function test_wp_richedit_pre_charset_iso_8859_1() {
add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) );
$iso8859_1 = 'Fran' . chr( 135 ) . 'ais';
$this->assertSame( '&lt;p&gt;' . $iso8859_1 . "&lt;/p&gt;\n", wp_richedit_pre( $iso8859_1 ) );
remove_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) );
}
function _charset_utf_8() {
return 'UTF-8';
}
/*
* @ticket 23688
*/
function test_wp_richedit_pre_charset_utf_8() {
add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) );
$utf8 = 'Fran' . chr( 195 ) . chr( 167 ) . 'ais';
$this->assertSame( '&lt;p&gt;' . $utf8 . "&lt;/p&gt;\n", wp_richedit_pre( $utf8 ) );
remove_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) );
}
}