mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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
37 lines
980 B
PHP
37 lines
980 B
PHP
<?php
|
|
|
|
/**
|
|
* @group formatting
|
|
*/
|
|
class Tests_Formatting_Utf8UriEncode extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* Non-ASCII UTF-8 characters should be percent-encoded. Spaces etc.
|
|
* are dealt with elsewhere.
|
|
*
|
|
* @dataProvider data
|
|
*/
|
|
function test_percent_encodes_non_reserved_characters( $utf8, $urlencoded ) {
|
|
$this->assertSame( $urlencoded, utf8_uri_encode( $utf8 ) );
|
|
}
|
|
|
|
/**
|
|
* @dataProvider data
|
|
*/
|
|
function test_output_is_not_longer_than_optional_length_argument( $utf8, $unused_for_this_test ) {
|
|
$max_length = 30;
|
|
$this->assertTrue( strlen( utf8_uri_encode( $utf8, $max_length ) ) <= $max_length );
|
|
}
|
|
|
|
function data() {
|
|
$utf8_urls = file( DIR_TESTDATA . '/formatting/utf-8/utf-8.txt' );
|
|
$urlencoded = file( DIR_TESTDATA . '/formatting/utf-8/urlencoded.txt' );
|
|
$data_provided = array();
|
|
foreach ( $utf8_urls as $key => $value ) {
|
|
$data_provided[] = array( trim( $value ), trim( $urlencoded[ $key ] ) );
|
|
}
|
|
return $data_provided;
|
|
}
|
|
}
|
|
|