Subversion Repositories Applications.papyrus

Rev

Rev 1463 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1463 alexandre_ 1
<?php
2
 
3
// some tests may fail with other locales - just see yourself
4
$GLOBALS['____locale'] = 'en_US';
5
 
6
require_once 'PHPUnit.php';
7
require_once 'I18Nv2/Locale.php';
8
 
9
PEAR::setErrorHandling(PEAR_ERROR_PRINT, "PEAR_Error: %s\n");
10
 
11
/**
12
* TestCase for I18Nv2_LocaleTest class
13
* Generated by PHPEdit.XUnit Plugin
14
*/
15
class I18Nv2_LocaleTest extends PHPUnit_TestCase
16
{
17
    /**
18
    * Constructor
19
    *
20
    * @param string $name The name of the test.
21
    * @access protected
22
    */
23
    function I18Nv2_LocaleTest($name)
24
    {
25
        $this->PHPUnit_TestCase($name);
26
    }
27
 
28
    /**
29
    * Called before the test functions will be executed this function is defined in PHPUnit_TestCase and overwritten here
30
    *
31
    * @access protected
32
    */
33
    function setUp()
34
    {
35
        $this->l = &new I18Nv2_Locale($GLOBALS['____locale']);
36
        $this->t = time();
37
    }
38
 
39
    /**
40
    * Called after the test functions are executed this function is defined in PHPUnit_TestCase and overwritten here
41
    *
42
    * @access protected
43
    */
44
    function tearDown()
45
    {
46
        unset($this->l);
47
        $this->l = null;
48
    }
49
 
50
    /**
51
    * Regression test for I18Nv2_Locale.setLocale method
52
    *
53
    * @access public
54
    */
55
    function testsetLocale()
56
    {
57
        $this->assertTrue($this->l->setLocale($GLOBALS['____locale']));
58
    }
59
 
60
    /**
61
    * Regression test for I18Nv2_Locale.setCurrencyFormat method
62
    *
63
    * @access public
64
    */
65
    function testsetCurrencyFormat()
66
    {
67
        $this->assertFalse(PEAR::isError($this->l->setCurrencyFormat(I18Nv2_CURRENCY_LOCAL)));
68
    }
69
 
70
    /**
71
    * Regression test for I18Nv2_Locale.setNumberFormat method
72
    *
73
    * @access public
74
    */
75
    function testsetNumberFormat()
76
    {
77
        $this->assertFalse(PEAR::isError($this->l->setNumberFormat(I18Nv2_NUMBER_FLOAT)));
78
    }
79
 
80
    /**
81
    * Regression test for I18Nv2_Locale.setDateFormat method
82
    *
83
    * @access public
84
    */
85
    function testsetDateFormat()
86
    {
87
        $this->assertFalse(PEAR::isError($this->l->setDateFormat(I18Nv2_DATETIME_FULL)));
88
    }
89
 
90
    /**
91
    * Regression test for I18Nv2_Locale.setTimeFormat method
92
    *
93
    * @access public
94
    */
95
    function testsetTimeFormat()
96
    {
97
        $this->assertFalse(PEAR::isError($this->l->setTimeFormat(I18Nv2_DATETIME_FULL)));
98
    }
99
 
100
    /**
101
    * Regression test for I18Nv2_Locale.setCustomFormat method
102
    *
103
    * @access public
104
    */
105
    function testsetCustomFormat()
106
    {
107
        $tf = '%d. %B %Y';
108
        $this->l->setCustomFormat(I18Nv2_DATETIME_DEFAULT, $tf);
109
        $this->assertEquals($tf, $this->l->customFormats[I18Nv2_DATETIME_DEFAULT]);
110
        $this->l->setDateTimeFormat(I18Nv2_DATETIME_DEFAULT, true);
111
        $this->assertTrue(preg_match('/^\d+\. \w+ \d{4}$/', $this->l->formatDateTime(time())));
112
    }
113
 
114
    /**
115
    * Regression test for I18Nv2_Locale.formatCurrency method
116
    *
117
    * @access public
118
    */
119
    function testformatCurrency()
120
    {
121
        $this->l->setLocale('de_AT');
122
        $this->assertEquals('EUR 2.000,00', $this->l->formatCurrency(2000));
123
        $this->l->setLocale($GLOBALS['____locale']);
124
    }
125
 
126
    /**
127
    * Regression test for I18Nv2_Locale.formatNumber method
128
    *
129
    * @access public
130
    */
131
    function testformatNumber()
132
    {
133
        $this->assertEquals('2.13', $this->l->formatNumber(2.1331994));
134
    }
135
 
136
    /**
137
    * Regression test for I18Nv2_Locale.formatDate method
138
    *
139
    * @access public
140
    */
141
    function testformatDate()
142
    {
143
        $this->assertEquals(strftime('%d-%b-%Y', $this->t), $this->l->formatDate($this->t));
144
    }
145
 
146
    /**
147
    * Regression test for I18Nv2_Locale.formatTime method
148
    *
149
    * @access public
150
    */
151
    function testformatTime()
152
    {
153
        $this->assertEquals(strftime('%H:%M:%S', $this->t), $this->l->formatTime($this->t));
154
    }
155
 
156
    /**
157
    * Regression test for I18Nv2_Locale.time method
158
    *
159
    * @access public
160
    */
161
    function testtime()
162
    {
163
        $this->assertEquals(strftime('%X', $this->t), $this->l->time($this->t));
164
    }
165
 
166
    /**
167
    * Regression test for I18Nv2_Locale.date method
168
    *
169
    * @access public
170
    */
171
    function testdate()
172
    {
173
        $this->assertEquals(strftime('%x', $this->t), $this->l->date($this->t));
174
    }
175
 
176
    /**
177
    * Regression test for I18Nv2_Locale.dayName method
178
    *
179
    * @access public
180
    */
181
    function testdayName()
182
    {
183
        $dayNum = strftime('%w', $this->t);
184
        $this->assertEquals(strftime('%A', $this->t), $this->l->dayName($dayNum));
185
        $this->assertEquals(strftime('%a', $this->t), $this->l->dayName($dayNum, true));
186
    }
187
 
188
    /**
189
    * Regression test for I18Nv2_Locale.monthName method
190
    *
191
    * @access public
192
    */
193
    function testmonthName()
194
    {
195
        $monthNum = strftime('%m', $this->t) -1;
196
        $this->assertEquals(strftime('%B', $this->t), $this->l->monthName($monthNum));
197
        $this->assertEquals(strftime('%b', $this->t), $this->l->monthName($monthNum, true));
198
    }
199
}
200
 
201
$ts = &new PHPUnit_TestSuite('I18Nv2_LocaleTest');
202
$rs = PHPUnit::run($ts);
203
echo $rs->toString();
204
?>