|
11 | 11 | class Translate_Link extends WP_UnitTestCase { |
12 | 12 |
|
13 | 13 | public function test_default_path() { |
14 | | - add_filter( 'locale', function () { |
15 | | - return 'de_DE'; |
16 | | - } ); |
| 14 | + add_filter( |
| 15 | + 'locale', |
| 16 | + function () { |
| 17 | + return 'de_DE'; |
| 18 | + } |
| 19 | + ); |
17 | 20 | $url = 'https://example.com'; |
18 | 21 | $this->assertEquals( $url . '/de', tsdk_translate_link( $url ) ); |
19 | 22 | $url = 'https://example.com/some/path'; |
20 | | - $this->assertEquals( $url . '/de', tsdk_translate_link( $url ) ); |
| 23 | + $this->assertEquals( 'https://example.com/de/some/path', tsdk_translate_link( $url ) ); |
21 | 24 | $url = 'https://example.com/some/path/'; |
22 | | - $this->assertEquals( $url . 'de/', tsdk_translate_link( $url ) ); |
| 25 | + $this->assertEquals( 'https://example.com/de/some/path/', tsdk_translate_link( $url ) ); |
23 | 26 | } |
24 | 27 |
|
25 | 28 | public function test_query() { |
26 | | - add_filter( 'locale', function () { |
27 | | - return 'de_DE'; |
28 | | - } ); |
| 29 | + add_filter( |
| 30 | + 'locale', |
| 31 | + function () { |
| 32 | + return 'de_DE'; |
| 33 | + } |
| 34 | + ); |
29 | 35 | $url = 'https://example.com'; |
30 | | - $this->assertEquals( 'https://example.com/?lang=de', tsdk_translate_link( $url, 'query' ) ); |
| 36 | + $this->assertEquals( 'https://example.com?lang=de', tsdk_translate_link( $url, 'query' ) ); |
31 | 37 | } |
32 | 38 |
|
33 | 39 | public function test_domain() { |
34 | | - add_filter( 'locale', function () { |
35 | | - return 'de_DE'; |
36 | | - } ); |
| 40 | + add_filter( |
| 41 | + 'locale', |
| 42 | + function () { |
| 43 | + return 'de_DE'; |
| 44 | + } |
| 45 | + ); |
37 | 46 | $url = 'https://example.com'; |
38 | 47 | $this->assertEquals( 'https://optimole.de', tsdk_translate_link( $url, 'domain', [ 'de_DE' => 'optimole.de' ] ) ); |
39 | 48 | } |
40 | 49 |
|
41 | 50 | public function test_non_existent() { |
42 | | - add_filter( 'locale', function () { |
43 | | - return 'da_DK'; |
44 | | - } ); |
| 51 | + add_filter( |
| 52 | + 'locale', |
| 53 | + function () { |
| 54 | + return 'da_DK'; |
| 55 | + } |
| 56 | + ); |
45 | 57 | $url = 'https://example.com'; |
46 | 58 | $this->assertEquals( 'https://example.com', tsdk_translate_link( $url ) ); |
47 | 59 | } |
|
0 commit comments