WordPress.org

Make WordPress Core

Ticket #41257: 41257.patch

File 41257.patch, 835 bytes (added by bobbingwide, 4 years ago)

Unit test case that demonstrates the unexpected results

  • tests/phpunit/tests/pomo/translations.php

     
    7272                $this->assertEquals( '1', $domain->translate( '1' ) );
    7373        }
    7474
     75        function test_41257_translate_null_returns_translation_of_0() {
     76                $entry_digit_0 = new Translation_Entry( array('singular' => '0', 'translations' => array('0=zero') ) );
     77                $domain = new Translations();
     78                $domain->add_entry( $entry_digit_0 );
     79                $this->assertEquals( '0=zero', $domain->translate( "0" ) );
     80                $this->assertEquals( '0=zero', $domain->translate( null ) );
     81                $this->assertEquals( '0=zero', $domain->translate( "" ) );
     82                $this->assertEquals( '0=zero', $domain->translate( 0 ) );
     83        }
     84
    7585}