I18N: Add a unit test for before_last_bar()
.
Props realloc. Fixes #35073. git-svn-id: https://develop.svn.wordpress.org/trunk@35959 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b5b92d9cbd
commit
959f377c3e
@ -118,10 +118,11 @@ function translate( $text, $domain = 'default' ) {
|
||||
*/
|
||||
function before_last_bar( $string ) {
|
||||
$last_bar = strrpos( $string, '|' );
|
||||
if ( false === $last_bar )
|
||||
if ( false === $last_bar ) {
|
||||
return $string;
|
||||
else
|
||||
} else {
|
||||
return substr( $string, 0, $last_bar );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,4 +16,14 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
$this->assertTrue( unload_textdomain( 'wp-tests-domain' ) );
|
||||
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35073
|
||||
*/
|
||||
function test_before_last_bar() {
|
||||
$this->assertEquals( 'no-bar-at-all', before_last_bar( 'no-bar-at-all' ) );
|
||||
$this->assertEquals( 'before-last-bar', before_last_bar( 'before-last-bar|after-bar' ) );
|
||||
$this->assertEquals( 'first-before-bar|second-before-bar', before_last_bar( 'first-before-bar|second-before-bar|after-last-bar' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user