Skip to content

Commit 90a3c92

Browse files
committed
Tests: Cover contextual localization of the PHP update URL.
Verify that `wp_get_default_update_php_url()` uses the expected source URL and translation context. Developed in: #14749 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64813 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6085b97 commit 90a3c92

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/**
4+
* Tests for wp_get_default_update_php_url().
5+
*
6+
* @group functions
7+
*
8+
* @covers ::wp_get_default_update_php_url
9+
*/
10+
class Tests_Functions_WpGetDefaultUpdatePhpUrl extends WP_UnitTestCase {
11+
12+
/**
13+
* @ticket 65819
14+
*/
15+
public function test_returns_contextually_localized_php_upgrade_url() {
16+
$translated = 'https://example.test/update-php-localized/';
17+
18+
$filter = static function ( $translation, $text, $context ) use ( $translated ) {
19+
if (
20+
'https://wordpress.org/support/update-php/' === $text
21+
&& 'localized PHP upgrade information page' === $context
22+
) {
23+
return $translated;
24+
}
25+
26+
return $translation;
27+
};
28+
29+
add_filter( 'gettext_with_context', $filter, 10, 3 );
30+
31+
$this->assertSame( $translated, wp_get_default_update_php_url() );
32+
33+
remove_filter( 'gettext_with_context', $filter, 10 );
34+
}
35+
}

0 commit comments

Comments
 (0)