@@ -21,7 +21,7 @@ class IntlCasterTest extends TestCase
2121{
2222 use VarDumperTestTrait;
2323
24- public function testArrayIterator ()
24+ public function testMessageFormatter ()
2525 {
2626 $ var = new \MessageFormatter ('en ' , 'Hello {name} ' );
2727
@@ -30,6 +30,123 @@ public function testArrayIterator()
3030 locale: "en"
3131 pattern: "Hello {name}"
3232}
33+ EOTXT ;
34+ $ this ->assertDumpEquals ($ expected , $ var );
35+ }
36+
37+ public function testCastNumberFormatter ()
38+ {
39+ $ var = new \NumberFormatter ('en ' , \NumberFormatter::DECIMAL );
40+
41+ $ expectedLocale = $ var ->getLocale ();
42+ $ expectedPattern = $ var ->getPattern ();
43+
44+ $ expectedAttribute1 = $ var ->getAttribute (\NumberFormatter::PARSE_INT_ONLY );
45+ $ expectedAttribute2 = $ var ->getAttribute (\NumberFormatter::GROUPING_USED );
46+ $ expectedAttribute3 = $ var ->getAttribute (\NumberFormatter::DECIMAL_ALWAYS_SHOWN );
47+ $ expectedAttribute4 = $ var ->getAttribute (\NumberFormatter::MAX_INTEGER_DIGITS );
48+ $ expectedAttribute5 = $ var ->getAttribute (\NumberFormatter::MIN_INTEGER_DIGITS );
49+ $ expectedAttribute6 = $ var ->getAttribute (\NumberFormatter::INTEGER_DIGITS );
50+ $ expectedAttribute7 = $ var ->getAttribute (\NumberFormatter::MAX_FRACTION_DIGITS );
51+ $ expectedAttribute8 = $ var ->getAttribute (\NumberFormatter::MIN_FRACTION_DIGITS );
52+ $ expectedAttribute9 = $ var ->getAttribute (\NumberFormatter::FRACTION_DIGITS );
53+ $ expectedAttribute10 = $ var ->getAttribute (\NumberFormatter::MULTIPLIER );
54+ $ expectedAttribute11 = $ var ->getAttribute (\NumberFormatter::GROUPING_SIZE );
55+ $ expectedAttribute12 = $ var ->getAttribute (\NumberFormatter::ROUNDING_MODE );
56+ $ expectedAttribute13 = number_format ($ var ->getAttribute (\NumberFormatter::ROUNDING_INCREMENT ), 1 );
57+ $ expectedAttribute14 = $ var ->getAttribute (\NumberFormatter::FORMAT_WIDTH );
58+ $ expectedAttribute15 = $ var ->getAttribute (\NumberFormatter::PADDING_POSITION );
59+ $ expectedAttribute16 = $ var ->getAttribute (\NumberFormatter::SECONDARY_GROUPING_SIZE );
60+ $ expectedAttribute17 = $ var ->getAttribute (\NumberFormatter::SIGNIFICANT_DIGITS_USED );
61+ $ expectedAttribute18 = $ var ->getAttribute (\NumberFormatter::MIN_SIGNIFICANT_DIGITS );
62+ $ expectedAttribute19 = $ var ->getAttribute (\NumberFormatter::MAX_SIGNIFICANT_DIGITS );
63+ $ expectedAttribute20 = $ var ->getAttribute (\NumberFormatter::LENIENT_PARSE );
64+
65+ $ expectedTextAttribute1 = $ var ->getTextAttribute (\NumberFormatter::POSITIVE_PREFIX );
66+ $ expectedTextAttribute2 = $ var ->getTextAttribute (\NumberFormatter::POSITIVE_SUFFIX );
67+ $ expectedTextAttribute3 = $ var ->getTextAttribute (\NumberFormatter::NEGATIVE_PREFIX );
68+ $ expectedTextAttribute4 = $ var ->getTextAttribute (\NumberFormatter::NEGATIVE_SUFFIX );
69+ $ expectedTextAttribute5 = $ var ->getTextAttribute (\NumberFormatter::PADDING_CHARACTER );
70+ $ expectedTextAttribute6 = $ var ->getTextAttribute (\NumberFormatter::CURRENCY_CODE );
71+ $ expectedTextAttribute7 = $ var ->getTextAttribute (\NumberFormatter::DEFAULT_RULESET ) ? 'true ' : 'false ' ;
72+ $ expectedTextAttribute8 = $ var ->getTextAttribute (\NumberFormatter::PUBLIC_RULESETS ) ? 'true ' : 'false ' ;
73+
74+ $ expectedSymbol1 = $ var ->getSymbol (\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL );
75+ $ expectedSymbol2 = $ var ->getSymbol (\NumberFormatter::GROUPING_SEPARATOR_SYMBOL );
76+ $ expectedSymbol3 = $ var ->getSymbol (\NumberFormatter::PATTERN_SEPARATOR_SYMBOL );
77+ $ expectedSymbol4 = $ var ->getSymbol (\NumberFormatter::PERCENT_SYMBOL );
78+ $ expectedSymbol5 = $ var ->getSymbol (\NumberFormatter::ZERO_DIGIT_SYMBOL );
79+ $ expectedSymbol6 = $ var ->getSymbol (\NumberFormatter::DIGIT_SYMBOL );
80+ $ expectedSymbol7 = $ var ->getSymbol (\NumberFormatter::MINUS_SIGN_SYMBOL );
81+ $ expectedSymbol8 = $ var ->getSymbol (\NumberFormatter::PLUS_SIGN_SYMBOL );
82+ $ expectedSymbol9 = $ var ->getSymbol (\NumberFormatter::CURRENCY_SYMBOL );
83+ $ expectedSymbol10 = $ var ->getSymbol (\NumberFormatter::INTL_CURRENCY_SYMBOL );
84+ $ expectedSymbol11 = $ var ->getSymbol (\NumberFormatter::MONETARY_SEPARATOR_SYMBOL );
85+ $ expectedSymbol12 = $ var ->getSymbol (\NumberFormatter::EXPONENTIAL_SYMBOL );
86+ $ expectedSymbol13 = $ var ->getSymbol (\NumberFormatter::PERMILL_SYMBOL );
87+ $ expectedSymbol14 = $ var ->getSymbol (\NumberFormatter::PAD_ESCAPE_SYMBOL );
88+ $ expectedSymbol15 = $ var ->getSymbol (\NumberFormatter::INFINITY_SYMBOL );
89+ $ expectedSymbol16 = $ var ->getSymbol (\NumberFormatter::NAN_SYMBOL );
90+ $ expectedSymbol17 = $ var ->getSymbol (\NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL );
91+ $ expectedSymbol18 = $ var ->getSymbol (\NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL );
92+
93+ $ expected = <<<EOTXT
94+ NumberFormatter {
95+ locale: " $ expectedLocale"
96+ pattern: " $ expectedPattern"
97+ attributes: {
98+ PARSE_INT_ONLY: $ expectedAttribute1
99+ GROUPING_USED: $ expectedAttribute2
100+ DECIMAL_ALWAYS_SHOWN: $ expectedAttribute3
101+ MAX_INTEGER_DIGITS: $ expectedAttribute4
102+ MIN_INTEGER_DIGITS: $ expectedAttribute5
103+ INTEGER_DIGITS: $ expectedAttribute6
104+ MAX_FRACTION_DIGITS: $ expectedAttribute7
105+ MIN_FRACTION_DIGITS: $ expectedAttribute8
106+ FRACTION_DIGITS: $ expectedAttribute9
107+ MULTIPLIER: $ expectedAttribute10
108+ GROUPING_SIZE: $ expectedAttribute11
109+ ROUNDING_MODE: $ expectedAttribute12
110+ ROUNDING_INCREMENT: $ expectedAttribute13
111+ FORMAT_WIDTH: $ expectedAttribute14
112+ PADDING_POSITION: $ expectedAttribute15
113+ SECONDARY_GROUPING_SIZE: $ expectedAttribute16
114+ SIGNIFICANT_DIGITS_USED: $ expectedAttribute17
115+ MIN_SIGNIFICANT_DIGITS: $ expectedAttribute18
116+ MAX_SIGNIFICANT_DIGITS: $ expectedAttribute19
117+ LENIENT_PARSE: $ expectedAttribute20
118+ }
119+ text_attributes: {
120+ POSITIVE_PREFIX: " $ expectedTextAttribute1"
121+ POSITIVE_SUFFIX: " $ expectedTextAttribute2"
122+ NEGATIVE_PREFIX: " $ expectedTextAttribute3"
123+ NEGATIVE_SUFFIX: " $ expectedTextAttribute4"
124+ PADDING_CHARACTER: " $ expectedTextAttribute5"
125+ CURRENCY_CODE: " $ expectedTextAttribute6"
126+ DEFAULT_RULESET: $ expectedTextAttribute7
127+ PUBLIC_RULESETS: $ expectedTextAttribute8
128+ }
129+ symbols: {
130+ DECIMAL_SEPARATOR_SYMBOL: " $ expectedSymbol1"
131+ GROUPING_SEPARATOR_SYMBOL: " $ expectedSymbol2"
132+ PATTERN_SEPARATOR_SYMBOL: " $ expectedSymbol3"
133+ PERCENT_SYMBOL: " $ expectedSymbol4"
134+ ZERO_DIGIT_SYMBOL: " $ expectedSymbol5"
135+ DIGIT_SYMBOL: " $ expectedSymbol6"
136+ MINUS_SIGN_SYMBOL: " $ expectedSymbol7"
137+ PLUS_SIGN_SYMBOL: " $ expectedSymbol8"
138+ CURRENCY_SYMBOL: " $ expectedSymbol9"
139+ INTL_CURRENCY_SYMBOL: " $ expectedSymbol10"
140+ MONETARY_SEPARATOR_SYMBOL: " $ expectedSymbol11"
141+ EXPONENTIAL_SYMBOL: " $ expectedSymbol12"
142+ PERMILL_SYMBOL: " $ expectedSymbol13"
143+ PAD_ESCAPE_SYMBOL: " $ expectedSymbol14"
144+ INFINITY_SYMBOL: " $ expectedSymbol15"
145+ NAN_SYMBOL: " $ expectedSymbol16"
146+ SIGNIFICANT_DIGIT_SYMBOL: " $ expectedSymbol17"
147+ MONETARY_GROUPING_SEPARATOR_SYMBOL: " $ expectedSymbol18"
148+ }
149+ }
33150EOTXT ;
34151 $ this ->assertDumpEquals ($ expected , $ var );
35152 }
0 commit comments