Repository navigation
Expand file tree
/
Copy path35840_1.patch
More file actions
78 lines (78 loc) · 2.72 KB
/
Copy path35840_1.patch
File metadata and controls
78 lines (78 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Index: tests/phpunit/tests/functions/number_format_i18n.php
===================================================================
--- tests/phpunit/tests/functions/number_format_i18n.php (nonexistent)
+++ tests/phpunit/tests/functions/number_format_i18n.php (working copy)
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Test the number_format_i18n function by providing a string, wrong format,
+ * custom separators, and agains the values from en_US (, for thousands - . for decimal)
+ * and pt_BR (. for thousands - , for decimal).
+ *
+ * @group functions
+ */
+class Tests_Functions_number_format_i18n extends WP_UnitTestCase {
+
+ /**
+ *
+ */
+ function test_number_format_i18n_number_is_not_number() {
+
+ $this->assertEquals( '0', number_format_i18n( 'seven' ) );
+ }
+
+ /**
+ *
+ */
+ function test_number_format_i18n_decimal_is_not_number() {
+
+ $this->assertEquals( number_format_i18n( 10, 'seven' ) , '10' );
+ }
+
+ /**
+ *
+ *
+ */
+ function test_number_format_i18n_custom_separator() {
+ global $wp_locale;
+ $wp_locale->number_format['decimal_point'] = '@';
+ $wp_locale->number_format['thousands_sep'] = '^';
+
+ $this->assertEquals( '1^000@00', number_format_i18n( 1000.00, 2 ) );
+ $this->assertEquals( '1^000@00', number_format_i18n( (int)1000, 2 ) );
+ $this->assertEquals( '1^234^567^890@00000', number_format_i18n( 1234567890.00, 5 ) );
+ $this->assertEquals( '1^234^567^890@00000', number_format_i18n( 1234567890.99999, 5 ) );
+ $this->assertEquals( '1^234^567^890@00000', number_format_i18n( 1234567890.55555, 5 ) );
+ // clear $wp_locale
+ $wp_locale = null;
+ }
+ /**
+ *
+ */
+ function test_number_format_i18n_no_global_and_us() {
+
+ $this->assertEquals( '1,000.00', number_format_i18n( 1000.00, 2 ) );
+ $this->assertEquals( '1,000.00', number_format_i18n( (int)1000, 2 ) );
+ $this->assertEquals( '1,234,567,890.00000', number_format_i18n( 1234567890.00, 5 ) );
+ $this->assertEquals( '1,234,567,890.00000', number_format_i18n( 1234567890.99999, 5 ) );
+ $this->assertEquals( '1,234,567,890.00000', number_format_i18n( 1234567890.55555, 5 ) );
+ }
+
+ /**
+ *
+ */
+ function test_number_format_i18n_brazil() {
+ global $wp_locale;
+ $wp_locale->number_format['decimal_point'] = ',';
+ $wp_locale->number_format['thousands_sep'] = '.';
+
+ $this->assertEquals( '1.000,00', number_format_i18n( 1000.00, 2 ) );
+ $this->assertEquals( '1.000,00', number_format_i18n( (int)1000, 2 ) );
+ $this->assertEquals( '1.234.567.890,00000', number_format_i18n( 1234567890.00, 5 ) );
+ $this->assertEquals( '1.234.567.890,00000', number_format_i18n( 1234567890.99999, 5 ) );
+ $this->assertEquals( '1.234.567.890,00000', number_format_i18n( 1234567890.55555, 5 ) );
+ // clear $wp_locale
+ $wp_locale = null;
+ }
+}
\ No newline at end of file