From 4f91aae382485d12cb039a5d43bb624c1610bb83 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 28 Feb 2016 20:48:58 +0000 Subject: [PATCH] L10n: Add unit tests for `_n_noop()` and `_nx_noop()`. Props realloc. Fixes #35961. git-svn-id: https://develop.svn.wordpress.org/trunk@36766 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/l10n.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/phpunit/tests/l10n.php b/tests/phpunit/tests/l10n.php index 1934b90236..e5713da2b2 100644 --- a/tests/phpunit/tests/l10n.php +++ b/tests/phpunit/tests/l10n.php @@ -6,6 +6,33 @@ */ class Tests_L10n extends WP_UnitTestCase { + /** + * @ticket 35961 + */ + function test_n_noop() { + $text_domain = 'text-domain'; + $nooped_plural = _n_noop( '%s post', '%s posts', $text_domain ); + + $this->assertNotEmpty( $nooped_plural['domain'] ); + $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) ); + $this->assertEquals( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) ); + $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) ); + } + + /** + * @ticket 35961 + */ + function test_nx_noop() { + $text_domain = 'text-domain'; + $nooped_plural = _nx_noop( '%s post', '%s posts', 'my-context', $text_domain ); + + $this->assertNotEmpty( $nooped_plural['domain'] ); + $this->assertNotEmpty( $nooped_plural['context'] ); + $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) ); + $this->assertEquals( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) ); + $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) ); + } + function test_load_unload_textdomain() { $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) ); $this->assertFalse( unload_textdomain( 'wp-tests-domain' ) );