Make WordPress Core

Changeset 35959


Ignore:
Timestamp:
12/16/2015 08:03:38 AM (9 years ago)
Author:
SergeyBiryukov
Message:

I18N: Add a unit test for before_last_bar().

Props realloc.
Fixes #35073.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/l10n.php

    r35856 r35959  
    119119function before_last_bar( $string ) {
    120120    $last_bar = strrpos( $string, '|' );
    121     if ( false === $last_bar )
     121    if ( false === $last_bar ) {
    122122        return $string;
    123     else
     123    } else {
    124124        return substr( $string, 0, $last_bar );
     125    }
    125126}
    126127
  • trunk/tests/phpunit/tests/l10n.php

    r30521 r35959  
    1717        $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
    1818    }
     19
     20    /**
     21     * @ticket 35073
     22     */
     23    function test_before_last_bar() {
     24        $this->assertEquals( 'no-bar-at-all', before_last_bar( 'no-bar-at-all' ) );
     25        $this->assertEquals( 'before-last-bar', before_last_bar( 'before-last-bar|after-bar' ) );
     26        $this->assertEquals( 'first-before-bar|second-before-bar', before_last_bar( 'first-before-bar|second-before-bar|after-last-bar' ) );
     27    }
     28
    1929}
Note: See TracChangeset for help on using the changeset viewer.