mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Coding Standards: Add visibility to methods in tests/phpunit/tests/.
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods. Adds a `private` visibility to helper methods within test classes. Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit. Props costdev, jrf, hellofromTonya. Fixes #54177. git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase {
|
||||
function test_munges_extensions() {
|
||||
public function test_munges_extensions() {
|
||||
// r17990
|
||||
$file_name = sanitize_file_name( 'test.phtml.txt' );
|
||||
$this->assertSame( 'test.phtml_.txt', $file_name );
|
||||
}
|
||||
|
||||
function test_removes_special_chars() {
|
||||
public function test_removes_special_chars() {
|
||||
$special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', '’', '«', '»', '”', '“', chr( 0 ) );
|
||||
$string = 'test';
|
||||
foreach ( $special_chars as $char ) {
|
||||
@@ -23,7 +23,7 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 22363
|
||||
*/
|
||||
function test_removes_accents() {
|
||||
public function test_removes_accents() {
|
||||
$in = 'àáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ';
|
||||
$out = 'aaaaaaaeceeeeiiiinoooooouuuuyy';
|
||||
$this->assertSame( $out, sanitize_file_name( $in ) );
|
||||
@@ -34,7 +34,7 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 16330
|
||||
*/
|
||||
function test_replaces_spaces() {
|
||||
public function test_replaces_spaces() {
|
||||
$urls = array(
|
||||
'unencoded space.png' => 'unencoded-space.png',
|
||||
'encoded-space.jpg' => 'encoded-space.jpg',
|
||||
@@ -47,15 +47,15 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_replaces_any_number_of_hyphens_with_one_hyphen() {
|
||||
public function test_replaces_any_number_of_hyphens_with_one_hyphen() {
|
||||
$this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t' ) );
|
||||
}
|
||||
|
||||
function test_trims_trailing_hyphens() {
|
||||
public function test_trims_trailing_hyphens() {
|
||||
$this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t----' ) );
|
||||
}
|
||||
|
||||
function test_replaces_any_amount_of_whitespace_with_one_hyphen() {
|
||||
public function test_replaces_any_amount_of_whitespace_with_one_hyphen() {
|
||||
$this->assertSame( 'a-t', sanitize_file_name( 'a t' ) );
|
||||
$this->assertSame( 'a-t', sanitize_file_name( "a \n\n\nt" ) );
|
||||
}
|
||||
@@ -63,17 +63,17 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 16226
|
||||
*/
|
||||
function test_replaces_percent_sign() {
|
||||
public function test_replaces_percent_sign() {
|
||||
$this->assertSame( 'a22b.jpg', sanitize_file_name( 'a%22b.jpg' ) );
|
||||
}
|
||||
|
||||
function test_replaces_unnamed_file_extensions() {
|
||||
public function test_replaces_unnamed_file_extensions() {
|
||||
// Test filenames with both supported and unsupported extensions.
|
||||
$this->assertSame( 'unnamed-file.exe', sanitize_file_name( '_.exe' ) );
|
||||
$this->assertSame( 'unnamed-file.jpg', sanitize_file_name( '_.jpg' ) );
|
||||
}
|
||||
|
||||
function test_replaces_unnamed_file_extensionless() {
|
||||
public function test_replaces_unnamed_file_extensionless() {
|
||||
// Test a filenames that becomes extensionless.
|
||||
$this->assertSame( 'no-extension', sanitize_file_name( '_.no-extension' ) );
|
||||
}
|
||||
@@ -81,11 +81,11 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_wp_filenames
|
||||
*/
|
||||
function test_replaces_invalid_utf8_characters( $input, $expected ) {
|
||||
public function test_replaces_invalid_utf8_characters( $input, $expected ) {
|
||||
$this->assertSame( $expected, sanitize_file_name( $input ) );
|
||||
}
|
||||
|
||||
function data_wp_filenames() {
|
||||
public function data_wp_filenames() {
|
||||
return array(
|
||||
array( urldecode( '%B1myfile.png' ), 'myfile.png' ),
|
||||
array( urldecode( '%B1myfile' ), 'myfile' ),
|
||||
|
||||
Reference in New Issue
Block a user