Skip to content

Commit b7f0a67

Browse files
committed
Add tests for stringy values.
1 parent fb4ec6f commit b7f0a67

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/phpunit/tests/l10n/wpTranslations.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,16 @@ public function test_translate_plural() {
226226
public function test_translate_plural_complex() {
227227
load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/l10n/plural-complex.mo' );
228228

229+
$this->assertSame( '%s razpoložljiva posodobitev', _n( '%s update available', '%s updates available', '1', 'wp-tests-domain' ) ); // 1, 101, 201
229230
$this->assertSame( '%s razpoložljiva posodobitev', _n( '%s update available', '%s updates available', 101, 'wp-tests-domain' ) ); // 1, 101, 201
230231
$this->assertSame( '%s razpoložljivi posodobitvi', _n( '%s update available', '%s updates available', 102, 'wp-tests-domain' ) ); // 2, 102, 202
231232
$this->assertSame( '%s razpoložljive posodobitve', _n( '%s update available', '%s updates available', 103, 'wp-tests-domain' ) ); // 3, 4, 103
232233
$this->assertSame( '%s razpoložljivih posodobitev', _n( '%s update available', '%s updates available', 5, 'wp-tests-domain' ) ); // 0, 5, 6
234+
235+
// Test with strings that are not in the MO file.
236+
$this->assertSame( 'Singular', _n( 'Singular', 'Plural', 1, 'wp-tests-domain' ) );
237+
$this->assertSame( 'Singular', _n( 'Singular', 'Plural', '1', 'wp-tests-domain' ) );
238+
$this->assertSame( 'Plural', _n( 'Singular', 'Plural', 2, 'wp-tests-domain' ) );
233239
}
234240

235241
/**
@@ -239,10 +245,16 @@ public function test_translate_plural_complex() {
239245
public function test_translate_plural_complex_php() {
240246
load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/l10n/plural-complex.php' );
241247

248+
$this->assertSame( '%s razpoložljiva posodobitev', _n( '%s update available', '%s updates available', '1', 'wp-tests-domain' ) ); // 1, 101, 201
242249
$this->assertSame( '%s razpoložljiva posodobitev', _n( '%s update available', '%s updates available', 101, 'wp-tests-domain' ) ); // 1, 101, 201
243250
$this->assertSame( '%s razpoložljivi posodobitvi', _n( '%s update available', '%s updates available', 102, 'wp-tests-domain' ) ); // 2, 102, 202
244251
$this->assertSame( '%s razpoložljive posodobitve', _n( '%s update available', '%s updates available', 103, 'wp-tests-domain' ) ); // 3, 4, 103
245252
$this->assertSame( '%s razpoložljivih posodobitev', _n( '%s update available', '%s updates available', 5, 'wp-tests-domain' ) ); // 0, 5, 6
253+
254+
// Test with strings that are not in the PHP file.
255+
$this->assertSame( 'Singular', _n( 'Singular', 'Plural', 1, 'wp-tests-domain' ) );
256+
$this->assertSame( 'Singular', _n( 'Singular', 'Plural', '1', 'wp-tests-domain' ) );
257+
$this->assertSame( 'Plural', _n( 'Singular', 'Plural', 2, 'wp-tests-domain' ) );
246258
}
247259

248260
/**

0 commit comments

Comments
 (0)