mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-07 01:39:04 +00:00
Move PHPUnit tests into a tests/phpunit directory.
wp-tests-config.php can/should reside in the root of a develop checkout. `phpunit` should be run from the root. see #25088. git-svn-id: https://develop.svn.wordpress.org/trunk@25165 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
34
tests/phpunit/tests/formatting/SanitizeFileName.php
Normal file
34
tests/phpunit/tests/formatting/SanitizeFileName.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase {
|
||||
function test_munges_extensions() {
|
||||
# r17990
|
||||
$file_name = sanitize_file_name( 'test.phtml.txt' );
|
||||
$this->assertEquals( 'test.phtml_.txt', $file_name );
|
||||
}
|
||||
|
||||
function test_removes_special_chars() {
|
||||
$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
|
||||
$string = 'test';
|
||||
foreach ( $special_chars as $char )
|
||||
$string .= $char;
|
||||
$string .= 'test';
|
||||
$this->assertEquals( 'testtest', sanitize_file_name( $string ) );
|
||||
}
|
||||
|
||||
function test_replaces_any_number_of_hyphens_with_one_hyphen() {
|
||||
$this->assertEquals("a-t-t", sanitize_file_name("a----t----t"));
|
||||
}
|
||||
|
||||
function test_trims_trailing_hyphens() {
|
||||
$this->assertEquals("a-t-t", sanitize_file_name("a----t----t----"));
|
||||
}
|
||||
|
||||
function test_replaces_any_amount_of_whitespace_with_one_hyphen() {
|
||||
$this->assertEquals("a-t", sanitize_file_name("a t"));
|
||||
$this->assertEquals("a-t", sanitize_file_name("a \n\n\nt"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user