1
+ <?php
2
+ /**
3
+ * php safe options - only tests for module intl
4
+ * Php 5.3+
5
+ */
6
+
7
+ /** ---------------------------------- Tests functions -------------------------------------------- */
8
+
9
+ // ------------------------- INTL tests -----------------------
10
+
11
+ /**
12
+ * @since 5.3.0
13
+ */
14
+ function test_30_Intl_Number_Format ()
15
+ {
16
+ global $ testsLoopLimits , $ totalOps , $ emptyResult ;
17
+
18
+ if (!class_exists ('NumberFormatter ' , false )) {
19
+ return $ emptyResult ;
20
+ }
21
+ if (!function_exists ('numfmt_create ' )) {
22
+ return $ emptyResult ;
23
+ }
24
+
25
+ $ count = $ testsLoopLimits ['30_intl_number_format ' ];
26
+ $ time_start = get_microtime ();
27
+
28
+ $ fmt = new NumberFormatter ( 'ru_RU ' , NumberFormatter::DECIMAL );
29
+ $ fmtD = new NumberFormatter ( 'ru_RU ' , NumberFormatter::DURATION );
30
+ $ fmtC = new NumberFormatter ( 'ru_RU ' , NumberFormatter::CURRENCY );
31
+ $ fmtS = new NumberFormatter ( 'en ' , NumberFormatter::SPELLOUT );
32
+
33
+ for ($ i = 0 ; $ i < $ count ; $ i ++) {
34
+ $ num = $ i / 100. ;
35
+ $ fmt ->format ($ num );
36
+
37
+ $ fmtC ->formatCurrency ($ num , 'EUR ' );
38
+ $ fmtC ->formatCurrency ($ num , 'RUR ' );
39
+
40
+ $ fmtD ->format ($ num );
41
+ $ fmtD ->setTextAttribute (NumberFormatter::DEFAULT_RULESET , "%in-numerals " );
42
+ $ fmtD ->format ($ num );
43
+ $ fmtD ->setTextAttribute (NumberFormatter::DEFAULT_RULESET , "%with-words " );
44
+ $ fmtD ->format ($ num );
45
+
46
+ $ fmtS ->format ($ num );
47
+ }
48
+ $ totalOps += $ count ;
49
+ return format_result_test (get_microtime () - $ time_start , $ count , mymemory_usage ());
50
+ }
51
+
52
+ /**
53
+ * @since: 5.5.0
54
+ */
55
+ function test_32_Intl_Calendar ()
56
+ {
57
+ global $ testsLoopLimits , $ totalOps , $ emptyResult ;
58
+
59
+ if (!class_exists ('IntlCalendar ' , false )) {
60
+ return $ emptyResult ;
61
+ }
62
+ if (!class_exists ('IntlTimeZone ' , false )) {
63
+ return $ emptyResult ;
64
+ }
65
+
66
+ $ count = $ testsLoopLimits ['32_intl_calendar ' ];
67
+ $ time_start = get_microtime ();
68
+
69
+ $ cal = IntlCalendar::createInstance (IntlTimeZone::getGMT ());
70
+
71
+ $ a = 0 ;
72
+ for ($ i = 0 ; $ i < $ count ; $ i ++) {
73
+ $ num = $ i / 100. ;
74
+ $ cal ->clear ();
75
+ $ cal ->setTime ($ num );
76
+
77
+ if ($ cal ->inDaylightTime ()) $ a ++;
78
+ if ($ cal ->isWeekend ()) $ a --;
79
+ if ($ cal ->getMinimalDaysInFirstWeek ()) $ a ++;
80
+
81
+ $ cal ->add (IntlCalendar::FIELD_MONTH , 1 );
82
+ $ cal ->add (IntlCalendar::FIELD_DAY_OF_MONTH , 1 );
83
+ if ($ cal ->inDaylightTime ()) $ a --;
84
+ if ($ cal ->isWeekend ()) $ a ++;
85
+ if ($ cal ->getMinimalDaysInFirstWeek ()) $ a --;
86
+ }
87
+ $ totalOps += $ count ;
88
+ return format_result_test (get_microtime () - $ time_start , $ count , mymemory_usage ());
89
+ }
0 commit comments