@@ -112,7 +112,7 @@ |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | public function testGetCount() { |
| 115 | - $queue = new TQueue(); |
|
| 115 | + $queue = new TQueue(); |
|
| 116 | 116 | self::assertEquals(0, $queue->getCount()); |
| 117 | 117 | $queue = new TQueue(array(1, 2, 3)); |
| 118 | 118 | self::assertEquals(3, $queue->getCount()); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class ListItem { |
| 4 | - public $data='data'; |
|
| 4 | + public $data='data'; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -9,17 +9,17 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | class TListTest extends PHPUnit_Framework_TestCase { |
| 11 | 11 | |
| 12 | - protected $list; |
|
| 13 | - protected $item1, $item2, $item3, $item4; |
|
| 12 | + protected $list; |
|
| 13 | + protected $item1, $item2, $item3, $item4; |
|
| 14 | 14 | |
| 15 | 15 | public function setUp() { |
| 16 | - $this->list=new TList; |
|
| 17 | - $this->item1=new ListItem; |
|
| 18 | - $this->item2=new ListItem; |
|
| 19 | - $this->item3=new ListItem; |
|
| 20 | - $this->item4=new ListItem; |
|
| 21 | - $this->list->add($this->item1); |
|
| 22 | - $this->list->add($this->item2); |
|
| 16 | + $this->list=new TList; |
|
| 17 | + $this->item1=new ListItem; |
|
| 18 | + $this->item2=new ListItem; |
|
| 19 | + $this->item3=new ListItem; |
|
| 20 | + $this->item4=new ListItem; |
|
| 21 | + $this->list->add($this->item1); |
|
| 22 | + $this->list->add($this->item2); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function tearDown() { |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | class Collections_AllTests { |
| 16 | 16 | public static function main() { |
| 17 | - PHPUnit_TextUI_TestRunner::run(self::suite()); |
|
| 17 | + PHPUnit_TextUI_TestRunner::run(self::suite()); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public static function suite() { |
| 21 | - $suite = new PHPUnit_Framework_TestSuite('System.Collections'); |
|
| 21 | + $suite = new PHPUnit_Framework_TestSuite('System.Collections'); |
|
| 22 | 22 | |
| 23 | - $suite->addTestSuite('TListTest'); |
|
| 23 | + $suite->addTestSuite('TListTest'); |
|
| 24 | 24 | $suite->addTestSuite('TMapTest'); |
| 25 | 25 | $suite->addTestSuite('TQueueTest'); |
| 26 | 26 | $suite->addTestSuite('TStackTest'); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $suite->addTestSuite('TPagedListTest'); |
| 29 | 29 | $suite->addTestSuite('TPagedDataSourceTest'); |
| 30 | 30 | |
| 31 | - return $suite; |
|
| 31 | + return $suite; |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
@@ -14,16 +14,16 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public function setUp() { |
| 16 | 16 | // test that TPriorityMap complies with TMap |
| 17 | - $this->map=new TPriorityMap; |
|
| 18 | - $this->item1=new TPriorityMapTest_MapItem; |
|
| 19 | - $this->item2=new TPriorityMapTest_MapItem; |
|
| 20 | - $this->item3=new TPriorityMapTest_MapItem; |
|
| 21 | - $this->item4=new TPriorityMapTest_MapItem; |
|
| 22 | - $this->item5=new TPriorityMapTest_MapItem; |
|
| 23 | - $this->map->add('key1',$this->item1); |
|
| 24 | - $this->map->add('key2',$this->item2); |
|
| 25 | - |
|
| 26 | - //Test the priority capabilities |
|
| 17 | + $this->map=new TPriorityMap; |
|
| 18 | + $this->item1=new TPriorityMapTest_MapItem; |
|
| 19 | + $this->item2=new TPriorityMapTest_MapItem; |
|
| 20 | + $this->item3=new TPriorityMapTest_MapItem; |
|
| 21 | + $this->item4=new TPriorityMapTest_MapItem; |
|
| 22 | + $this->item5=new TPriorityMapTest_MapItem; |
|
| 23 | + $this->map->add('key1',$this->item1); |
|
| 24 | + $this->map->add('key2',$this->item2); |
|
| 25 | + |
|
| 26 | + //Test the priority capabilities |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function setUpPriorities() { |
@@ -33,24 +33,24 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function tearDown() { |
| 36 | - $this->map=null; |
|
| 37 | - $this->item1=null; |
|
| 38 | - $this->item2=null; |
|
| 39 | - $this->item3=null; |
|
| 36 | + $this->map=null; |
|
| 37 | + $this->item1=null; |
|
| 38 | + $this->item2=null; |
|
| 39 | + $this->item3=null; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function testConstruct() { |
| 43 | - $a=array(1,2,'key3'=>3); |
|
| 44 | - $map=new TPriorityMap($a); |
|
| 45 | - $this->assertEquals(3,$map->getCount()); |
|
| 46 | - $map2=new TPriorityMap($this->map); |
|
| 47 | - $this->assertEquals(2,$map2->getCount()); |
|
| 43 | + $a=array(1,2,'key3'=>3); |
|
| 44 | + $map=new TPriorityMap($a); |
|
| 45 | + $this->assertEquals(3,$map->getCount()); |
|
| 46 | + $map2=new TPriorityMap($this->map); |
|
| 47 | + $this->assertEquals(2,$map2->getCount()); |
|
| 48 | 48 | |
| 49 | 49 | /* Test the priority functionality of TPriorityMap */ |
| 50 | 50 | |
| 51 | - $map3=new TPriorityMap($this->map, false, 100, -1); |
|
| 52 | - $this->assertEquals(100,$map3->getDefaultPriority()); |
|
| 53 | - $this->assertEquals(-1,$map3->getPrecision()); |
|
| 51 | + $map3=new TPriorityMap($this->map, false, 100, -1); |
|
| 52 | + $this->assertEquals(100,$map3->getDefaultPriority()); |
|
| 53 | + $this->assertEquals(-1,$map3->getPrecision()); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /* Test that TPriorityMap complies with TMap */ |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function testGetCount() { |
| 67 | - $this->assertEquals(2,$this->map->getCount()); |
|
| 67 | + $this->assertEquals(2,$this->map->getCount()); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | public function testGetKeys() { |
| 71 | - $keys=$this->map->getKeys(); |
|
| 72 | - $this->assertTrue(count($keys)===2 && $keys[0]==='key1' && $keys[1]==='key2'); |
|
| 71 | + $keys=$this->map->getKeys(); |
|
| 72 | + $this->assertTrue(count($keys)===2 && $keys[0]==='key1' && $keys[1]==='key2'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public function testAdd() |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class Security_AllTests { |
| 14 | 14 | public static function main() { |
| 15 | - PHPUnit_TextUI_TestRunner::run(self::suite()); |
|
| 15 | + PHPUnit_TextUI_TestRunner::run(self::suite()); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public static function suite() { |
| 19 | - $suite = new PHPUnit_Framework_TestSuite('System.Security'); |
|
| 19 | + $suite = new PHPUnit_Framework_TestSuite('System.Security'); |
|
| 20 | 20 | |
| 21 | 21 | $suite->addTestSuite('TAuthManagerTest'); |
| 22 | 22 | $suite->addTestSuite('TAuthorizationRuleTest'); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $suite->addTestSuite('TUserManagerTest'); |
| 25 | 25 | $suite->addTestSuite('TUserTest'); |
| 26 | 26 | |
| 27 | - return $suite; |
|
| 27 | + return $suite; |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
@@ -11,196 +11,196 @@ |
||
| 11 | 11 | protected $format; |
| 12 | 12 | |
| 13 | 13 | function setUp() { |
| 14 | - $this->format = DateTimeFormatInfo::getInstance('en'); |
|
| 14 | + $this->format = DateTimeFormatInfo::getInstance('en'); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function testAbbreviatedDayNames() { |
| 18 | - $names = $this->format->AbbreviatedDayNames; |
|
| 19 | - $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 20 | - $this->assertEquals(count($names),7,'Must have 7 day names'); |
|
| 21 | - |
|
| 22 | - //assuming invariant culture. |
|
| 23 | - $days = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); |
|
| 24 | - $this->assertEquals($names, $days); |
|
| 25 | - |
|
| 26 | - //try to set the data |
|
| 27 | - $data = array('Hel', 'wor'); |
|
| 28 | - $this->format->AbbreviatedDayNames = $data; |
|
| 29 | - $newNames = $this->format->AbbreviatedDayNames; |
|
| 30 | - $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 31 | - $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 32 | - $this->assertEquals($newNames, $data); |
|
| 18 | + $names = $this->format->AbbreviatedDayNames; |
|
| 19 | + $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 20 | + $this->assertEquals(count($names),7,'Must have 7 day names'); |
|
| 21 | + |
|
| 22 | + //assuming invariant culture. |
|
| 23 | + $days = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); |
|
| 24 | + $this->assertEquals($names, $days); |
|
| 25 | + |
|
| 26 | + //try to set the data |
|
| 27 | + $data = array('Hel', 'wor'); |
|
| 28 | + $this->format->AbbreviatedDayNames = $data; |
|
| 29 | + $newNames = $this->format->AbbreviatedDayNames; |
|
| 30 | + $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 31 | + $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 32 | + $this->assertEquals($newNames, $data); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | function testNarrowDayNames() { |
| 36 | - $names = $this->format->NarrowDayNames; |
|
| 37 | - $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 38 | - $this->assertEquals(count($names),7,'Must have 7 day names'); |
|
| 39 | - |
|
| 40 | - //assuming invariant culture. |
|
| 41 | - $days = array("S", "M", "T", "W", "T", "F", "S"); |
|
| 42 | - $this->assertEquals($names, $days); |
|
| 43 | - |
|
| 44 | - //try to set the data |
|
| 45 | - $data = array('H', 'w'); |
|
| 46 | - $this->format->NarrowDayNames = $data; |
|
| 47 | - $newNames = $this->format->NarrowDayNames; |
|
| 48 | - $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 49 | - $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 50 | - $this->assertEquals($newNames, $data); |
|
| 36 | + $names = $this->format->NarrowDayNames; |
|
| 37 | + $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 38 | + $this->assertEquals(count($names),7,'Must have 7 day names'); |
|
| 39 | + |
|
| 40 | + //assuming invariant culture. |
|
| 41 | + $days = array("S", "M", "T", "W", "T", "F", "S"); |
|
| 42 | + $this->assertEquals($names, $days); |
|
| 43 | + |
|
| 44 | + //try to set the data |
|
| 45 | + $data = array('H', 'w'); |
|
| 46 | + $this->format->NarrowDayNames = $data; |
|
| 47 | + $newNames = $this->format->NarrowDayNames; |
|
| 48 | + $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 49 | + $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 50 | + $this->assertEquals($newNames, $data); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | function testDayNames() { |
| 54 | - $names = $this->format->DayNames; |
|
| 55 | - $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 56 | - $this->assertEquals(count($names),7,'Must have 7 day names'); |
|
| 57 | - |
|
| 58 | - //assuming invariant culture. |
|
| 59 | - $days = array( "Sunday","Monday", "Tuesday", "Wednesday", |
|
| 60 | - "Thursday", "Friday", "Saturday"); |
|
| 61 | - $this->assertEquals($names, $days); |
|
| 62 | - |
|
| 63 | - //try to set the data |
|
| 64 | - $data = array('Hello', 'world'); |
|
| 65 | - $this->format->DayNames = $data; |
|
| 66 | - $newNames = $this->format->DayNames; |
|
| 67 | - $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 68 | - $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 69 | - $this->assertEquals($newNames, $data); |
|
| 54 | + $names = $this->format->DayNames; |
|
| 55 | + $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 56 | + $this->assertEquals(count($names),7,'Must have 7 day names'); |
|
| 57 | + |
|
| 58 | + //assuming invariant culture. |
|
| 59 | + $days = array( "Sunday","Monday", "Tuesday", "Wednesday", |
|
| 60 | + "Thursday", "Friday", "Saturday"); |
|
| 61 | + $this->assertEquals($names, $days); |
|
| 62 | + |
|
| 63 | + //try to set the data |
|
| 64 | + $data = array('Hello', 'world'); |
|
| 65 | + $this->format->DayNames = $data; |
|
| 66 | + $newNames = $this->format->DayNames; |
|
| 67 | + $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 68 | + $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 69 | + $this->assertEquals($newNames, $data); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | function testMonthNames() { |
| 73 | - $names = $this->format->MonthNames; |
|
| 74 | - $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 75 | - $this->assertEquals(count($names),12,'Must have 12 month names'); |
|
| 76 | - |
|
| 77 | - //assuming invariant culture. |
|
| 78 | - $days = array( "January", "February", "March", "April", |
|
| 79 | - "May", "June", "July", "August", "September", |
|
| 80 | - "October", "November", "December"); |
|
| 81 | - $this->assertEquals($names, $days); |
|
| 82 | - |
|
| 83 | - //try to set the data |
|
| 84 | - $data = array('Hello', 'world'); |
|
| 85 | - $this->format->MonthNames = $data; |
|
| 86 | - $newNames = $this->format->MonthNames; |
|
| 87 | - $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 88 | - $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 89 | - $this->assertEquals($newNames, $data); |
|
| 73 | + $names = $this->format->MonthNames; |
|
| 74 | + $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 75 | + $this->assertEquals(count($names),12,'Must have 12 month names'); |
|
| 76 | + |
|
| 77 | + //assuming invariant culture. |
|
| 78 | + $days = array( "January", "February", "March", "April", |
|
| 79 | + "May", "June", "July", "August", "September", |
|
| 80 | + "October", "November", "December"); |
|
| 81 | + $this->assertEquals($names, $days); |
|
| 82 | + |
|
| 83 | + //try to set the data |
|
| 84 | + $data = array('Hello', 'world'); |
|
| 85 | + $this->format->MonthNames = $data; |
|
| 86 | + $newNames = $this->format->MonthNames; |
|
| 87 | + $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 88 | + $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 89 | + $this->assertEquals($newNames, $data); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | function testNarrowMonthNames() { |
| 93 | - $names = $this->format->NarrowMonthNames; |
|
| 94 | - $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 95 | - $this->assertEquals(count($names),12,'Must have 12 month names'); |
|
| 96 | - |
|
| 97 | - //assuming invariant culture. |
|
| 98 | - $days = array( "J", "F", "M", "A", "M", "J", "J", |
|
| 99 | - "A", "S", "O", "N", "D"); |
|
| 100 | - $this->assertEquals($names, $days); |
|
| 101 | - |
|
| 102 | - //try to set the data |
|
| 103 | - $data = array('Hello', 'world'); |
|
| 104 | - $this->format->NarrowMonthNames = $data; |
|
| 105 | - $newNames = $this->format->NarrowMonthNames; |
|
| 106 | - $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 107 | - $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 108 | - $this->assertEquals($newNames, $data); |
|
| 93 | + $names = $this->format->NarrowMonthNames; |
|
| 94 | + $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 95 | + $this->assertEquals(count($names),12,'Must have 12 month names'); |
|
| 96 | + |
|
| 97 | + //assuming invariant culture. |
|
| 98 | + $days = array( "J", "F", "M", "A", "M", "J", "J", |
|
| 99 | + "A", "S", "O", "N", "D"); |
|
| 100 | + $this->assertEquals($names, $days); |
|
| 101 | + |
|
| 102 | + //try to set the data |
|
| 103 | + $data = array('Hello', 'world'); |
|
| 104 | + $this->format->NarrowMonthNames = $data; |
|
| 105 | + $newNames = $this->format->NarrowMonthNames; |
|
| 106 | + $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 107 | + $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 108 | + $this->assertEquals($newNames, $data); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | function testAbbreviatedMonthNames() { |
| 112 | - $names = $this->format->AbbreviatedMonthNames; |
|
| 113 | - $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 114 | - $this->assertEquals(count($names),12,'Must have 12 month names'); |
|
| 115 | - |
|
| 116 | - //assuming invariant culture. |
|
| 117 | - $days = array( "Jan", "Feb", "Mar", "Apr", |
|
| 118 | - "May", "Jun", "Jul", "Aug", "Sep", |
|
| 119 | - "Oct", "Nov", "Dec"); |
|
| 120 | - $this->assertEquals($names, $days); |
|
| 121 | - |
|
| 122 | - //try to set the data |
|
| 123 | - $data = array('Hello', 'world'); |
|
| 124 | - $this->format->AbbreviatedMonthNames = $data; |
|
| 125 | - $newNames = $this->format->AbbreviatedMonthNames; |
|
| 126 | - $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 127 | - $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 128 | - $this->assertEquals($newNames, $data); |
|
| 112 | + $names = $this->format->AbbreviatedMonthNames; |
|
| 113 | + $this->assertTrue(is_array($names),'Must be an array!'); |
|
| 114 | + $this->assertEquals(count($names),12,'Must have 12 month names'); |
|
| 115 | + |
|
| 116 | + //assuming invariant culture. |
|
| 117 | + $days = array( "Jan", "Feb", "Mar", "Apr", |
|
| 118 | + "May", "Jun", "Jul", "Aug", "Sep", |
|
| 119 | + "Oct", "Nov", "Dec"); |
|
| 120 | + $this->assertEquals($names, $days); |
|
| 121 | + |
|
| 122 | + //try to set the data |
|
| 123 | + $data = array('Hello', 'world'); |
|
| 124 | + $this->format->AbbreviatedMonthNames = $data; |
|
| 125 | + $newNames = $this->format->AbbreviatedMonthNames; |
|
| 126 | + $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 127 | + $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 128 | + $this->assertEquals($newNames, $data); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | function testEra() { |
| 132 | - //era for invariant culture is assumed to have |
|
| 133 | - // 1 for AD and 0 for BC |
|
| 134 | - $this->assertEquals('AD', $this->format->getEra(1)); |
|
| 135 | - $this->assertEquals('BC', $this->format->getEra(0)); |
|
| 132 | + //era for invariant culture is assumed to have |
|
| 133 | + // 1 for AD and 0 for BC |
|
| 134 | + $this->assertEquals('AD', $this->format->getEra(1)); |
|
| 135 | + $this->assertEquals('BC', $this->format->getEra(0)); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | function testAMPMMarkers() { |
| 139 | - $am_pm = array('AM','PM'); |
|
| 140 | - $data = $this->format->AMPMMarkers; |
|
| 141 | - $this->assertTrue(is_array($data)); |
|
| 142 | - $this->assertEquals($am_pm, $data); |
|
| 143 | - $this->assertEquals('AM', $this->format->AMDesignator); |
|
| 144 | - $this->assertEquals('PM', $this->format->PMDesignator); |
|
| 145 | - |
|
| 146 | - //try to set the data |
|
| 147 | - $data = array('Hello', 'world'); |
|
| 148 | - $this->format->AMPMMarkers = $data; |
|
| 149 | - $newNames = $this->format->AMPMMarkers; |
|
| 150 | - $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 151 | - $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 152 | - $this->assertEquals($newNames, $data); |
|
| 153 | - |
|
| 154 | - $this->format->AMDesignator = 'TTTT'; |
|
| 155 | - $this->assertEquals('TTTT',$this->format->AMDesignator); |
|
| 156 | - |
|
| 157 | - $this->format->PMDesignator = 'SSS'; |
|
| 158 | - $this->assertEquals('SSS',$this->format->PMDesignator); |
|
| 139 | + $am_pm = array('AM','PM'); |
|
| 140 | + $data = $this->format->AMPMMarkers; |
|
| 141 | + $this->assertTrue(is_array($data)); |
|
| 142 | + $this->assertEquals($am_pm, $data); |
|
| 143 | + $this->assertEquals('AM', $this->format->AMDesignator); |
|
| 144 | + $this->assertEquals('PM', $this->format->PMDesignator); |
|
| 145 | + |
|
| 146 | + //try to set the data |
|
| 147 | + $data = array('Hello', 'world'); |
|
| 148 | + $this->format->AMPMMarkers = $data; |
|
| 149 | + $newNames = $this->format->AMPMMarkers; |
|
| 150 | + $this->assertTrue(is_array($newNames),'Must be an array!'); |
|
| 151 | + $this->assertEquals(count($newNames),2,'Must have 2 entries'); |
|
| 152 | + $this->assertEquals($newNames, $data); |
|
| 153 | + |
|
| 154 | + $this->format->AMDesignator = 'TTTT'; |
|
| 155 | + $this->assertEquals('TTTT',$this->format->AMDesignator); |
|
| 156 | + |
|
| 157 | + $this->format->PMDesignator = 'SSS'; |
|
| 158 | + $this->assertEquals('SSS',$this->format->PMDesignator); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | function testPatterns() { |
| 162 | - //patterns for invariant |
|
| 163 | - $patterns = array( |
|
| 164 | - 'FullTimePattern' => 'h:mm:ss a z', |
|
| 165 | - 'LongTimePattern' => 'h:mm:ss a z', |
|
| 166 | - 'MediumTimePattern' => 'h:mm:ss a', |
|
| 167 | - 'ShortTimePattern' => 'h:mm a', |
|
| 168 | - 'FullDatePattern' => 'EEEE, MMMM d, yyyy', |
|
| 169 | - 'LongDatePattern' => 'MMMM d, yyyy', |
|
| 170 | - 'MediumDatePattern' => 'MMM d, yyyy', |
|
| 171 | - 'ShortDatePattern' => 'M/d/yy', |
|
| 172 | - 'DateTimeOrderPattern' => '{1} {0}' |
|
| 173 | - ); |
|
| 174 | - |
|
| 175 | - foreach($patterns as $property => $pattern) { |
|
| 176 | - $this->assertEquals($pattern, $this->format->$property); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - $hello = 'Hello'; |
|
| 180 | - $world = 'world'; |
|
| 181 | - $expectedResult = $hello.' '.$world; |
|
| 182 | - $this->assertEquals($expectedResult, |
|
| 183 | - $this->format->formatDateTime($hello, $world)); |
|
| 162 | + //patterns for invariant |
|
| 163 | + $patterns = array( |
|
| 164 | + 'FullTimePattern' => 'h:mm:ss a z', |
|
| 165 | + 'LongTimePattern' => 'h:mm:ss a z', |
|
| 166 | + 'MediumTimePattern' => 'h:mm:ss a', |
|
| 167 | + 'ShortTimePattern' => 'h:mm a', |
|
| 168 | + 'FullDatePattern' => 'EEEE, MMMM d, yyyy', |
|
| 169 | + 'LongDatePattern' => 'MMMM d, yyyy', |
|
| 170 | + 'MediumDatePattern' => 'MMM d, yyyy', |
|
| 171 | + 'ShortDatePattern' => 'M/d/yy', |
|
| 172 | + 'DateTimeOrderPattern' => '{1} {0}' |
|
| 173 | + ); |
|
| 174 | + |
|
| 175 | + foreach($patterns as $property => $pattern) { |
|
| 176 | + $this->assertEquals($pattern, $this->format->$property); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + $hello = 'Hello'; |
|
| 180 | + $world = 'world'; |
|
| 181 | + $expectedResult = $hello.' '.$world; |
|
| 182 | + $this->assertEquals($expectedResult, |
|
| 183 | + $this->format->formatDateTime($hello, $world)); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | function testInvariantInfo() { |
| 187 | - $format = DateTimeFormatInfo::getInstance(); |
|
| 187 | + $format = DateTimeFormatInfo::getInstance(); |
|
| 188 | 188 | |
| 189 | - //the variant datetime format for medium date |
|
| 190 | - //should be the follow |
|
| 191 | - $pattern = 'MMM d, yyyy'; |
|
| 189 | + //the variant datetime format for medium date |
|
| 190 | + //should be the follow |
|
| 191 | + $pattern = 'MMM d, yyyy'; |
|
| 192 | 192 | |
| 193 | - $this->assertEquals($pattern, $format->MediumDatePattern); |
|
| 193 | + $this->assertEquals($pattern, $format->MediumDatePattern); |
|
| 194 | 194 | |
| 195 | - $invariant = $format->getInvariantInfo(); |
|
| 195 | + $invariant = $format->getInvariantInfo(); |
|
| 196 | 196 | |
| 197 | - $this->assertSame($format, $invariant); |
|
| 197 | + $this->assertSame($format, $invariant); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | function testGetInstance() { |
| 201 | - $format = DateTimeFormatInfo::getInstance('zh_CN'); |
|
| 201 | + $format = DateTimeFormatInfo::getInstance('zh_CN'); |
|
| 202 | 202 | |
| 203 | - $pattern = 'yyyy-M-d'; |
|
| 204 | - $this->assertEquals($pattern, $format->MediumDatePattern); |
|
| 203 | + $pattern = 'yyyy-M-d'; |
|
| 204 | + $this->assertEquals($pattern, $format->MediumDatePattern); |
|
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | \ No newline at end of file |
@@ -9,161 +9,161 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class NumberFormatTest extends PHPUnit_Framework_TestCase { |
| 11 | 11 | function testDefaultFormats() { |
| 12 | - $formatter = new NumberFormat(); |
|
| 13 | - $number = '123456789.125156'; |
|
| 14 | - $wanted = '123,456,789.125156'; |
|
| 12 | + $formatter = new NumberFormat(); |
|
| 13 | + $number = '123456789.125156'; |
|
| 14 | + $wanted = '123,456,789.125156'; |
|
| 15 | 15 | |
| 16 | - $this->assertEquals($wanted, $formatter->format($number)); |
|
| 16 | + $this->assertEquals($wanted, $formatter->format($number)); |
|
| 17 | 17 | |
| 18 | - //currency |
|
| 19 | - $wanted = 'US$123,456,789.13'; |
|
| 20 | - $this->assertEquals($wanted, $formatter->format($number,'c')); |
|
| 18 | + //currency |
|
| 19 | + $wanted = 'US$123,456,789.13'; |
|
| 20 | + $this->assertEquals($wanted, $formatter->format($number,'c')); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | function testLocalizedCurrencyFormats() { |
| 24 | - $fr = new NumberFormat('fr'); |
|
| 25 | - $de = new NumberFormat('de'); |
|
| 26 | - $ja = new NumberFormat('ja_JP'); |
|
| 27 | - $it = new NumberFormat('it_IT'); |
|
| 24 | + $fr = new NumberFormat('fr'); |
|
| 25 | + $de = new NumberFormat('de'); |
|
| 26 | + $ja = new NumberFormat('ja_JP'); |
|
| 27 | + $it = new NumberFormat('it_IT'); |
|
| 28 | 28 | |
| 29 | - $number = '123456789.125156'; |
|
| 29 | + $number = '123456789.125156'; |
|
| 30 | 30 | |
| 31 | - //french |
|
| 32 | - $wanted = '123 456 789,13 F'; |
|
| 33 | - $this->assertEquals($wanted, $fr->format($number,'c','FRF')); |
|
| 31 | + //french |
|
| 32 | + $wanted = '123 456 789,13 F'; |
|
| 33 | + $this->assertEquals($wanted, $fr->format($number,'c','FRF')); |
|
| 34 | 34 | |
| 35 | - //german |
|
| 36 | - $wanted = 'DES 123.456.789,13'; |
|
| 37 | - $this->assertEquals($wanted, $de->format($number,'c','DES')); |
|
| 35 | + //german |
|
| 36 | + $wanted = 'DES 123.456.789,13'; |
|
| 37 | + $this->assertEquals($wanted, $de->format($number,'c','DES')); |
|
| 38 | 38 | |
| 39 | - //japanese |
|
| 40 | - $wanted = '¥123,456,789'; |
|
| 41 | - $this->assertEquals($wanted, $ja->format($number,'c','JPY')); |
|
| 39 | + //japanese |
|
| 40 | + $wanted = '¥123,456,789'; |
|
| 41 | + $this->assertEquals($wanted, $ja->format($number,'c','JPY')); |
|
| 42 | 42 | |
| 43 | - //custom/unkown currency |
|
| 44 | - $wanted = 'DLL123,456,789'; |
|
| 45 | - $this->assertEquals($wanted, $ja->format($number,'c','DLL')); |
|
| 43 | + //custom/unkown currency |
|
| 44 | + $wanted = 'DLL123,456,789'; |
|
| 45 | + $this->assertEquals($wanted, $ja->format($number,'c','DLL')); |
|
| 46 | 46 | |
| 47 | - //italian |
|
| 48 | - $wanted = '€ 123.456.789,13'; |
|
| 49 | - $this->assertEquals($wanted, $it->format($number,'c','EUR')); |
|
| 47 | + //italian |
|
| 48 | + $wanted = '€ 123.456.789,13'; |
|
| 49 | + $this->assertEquals($wanted, $it->format($number,'c','EUR')); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function testCustomFormat() { |
| 53 | - $formatter = new NumberFormat(); |
|
| 54 | - $number = '123456789.125156'; |
|
| 55 | - |
|
| 56 | - //primay and secondary grouping test |
|
| 57 | - $pattern = '#,###,##.###'; |
|
| 58 | - $wanted = '1,234,567,89.125156'; |
|
| 59 | - $this->assertEquals($wanted, $formatter->format($number, $pattern)); |
|
| 60 | - |
|
| 61 | - //4 digits grouping test |
|
| 62 | - $pattern = '#,####.###'; |
|
| 63 | - $wanted = '1,2345,6789.125156'; |
|
| 64 | - $this->assertEquals($wanted, $formatter->format($number, $pattern)); |
|
| 65 | - |
|
| 66 | - //custom percentage |
|
| 67 | - $pattern = '#,###.00%'; |
|
| 68 | - $wanted = '123,456,789.13%'; |
|
| 69 | - $this->assertEquals($wanted, $formatter->format($number, $pattern)); |
|
| 53 | + $formatter = new NumberFormat(); |
|
| 54 | + $number = '123456789.125156'; |
|
| 55 | + |
|
| 56 | + //primay and secondary grouping test |
|
| 57 | + $pattern = '#,###,##.###'; |
|
| 58 | + $wanted = '1,234,567,89.125156'; |
|
| 59 | + $this->assertEquals($wanted, $formatter->format($number, $pattern)); |
|
| 60 | + |
|
| 61 | + //4 digits grouping test |
|
| 62 | + $pattern = '#,####.###'; |
|
| 63 | + $wanted = '1,2345,6789.125156'; |
|
| 64 | + $this->assertEquals($wanted, $formatter->format($number, $pattern)); |
|
| 65 | + |
|
| 66 | + //custom percentage |
|
| 67 | + $pattern = '#,###.00%'; |
|
| 68 | + $wanted = '123,456,789.13%'; |
|
| 69 | + $this->assertEquals($wanted, $formatter->format($number, $pattern)); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | function testPercentageFormat() { |
| 73 | - $formatter = new NumberFormat(); |
|
| 74 | - $number = '0.125156'; |
|
| 75 | - $wanted = '12%'; |
|
| 76 | - $this->assertEquals($wanted, $formatter->format($number, 'p')); |
|
| 73 | + $formatter = new NumberFormat(); |
|
| 74 | + $number = '0.125156'; |
|
| 75 | + $wanted = '12%'; |
|
| 76 | + $this->assertEquals($wanted, $formatter->format($number, 'p')); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | function testQuotes() { |
| 80 | - $formatter = new NumberFormat(); |
|
| 81 | - $number = '123456789.125156'; |
|
| 80 | + $formatter = new NumberFormat(); |
|
| 81 | + $number = '123456789.125156'; |
|
| 82 | 82 | |
| 83 | - $pattern = "# o'clock"; |
|
| 84 | - $wanted = "123456789 o'clock"; |
|
| 85 | - $this->assertEquals($wanted, $formatter->format($number, $pattern)); |
|
| 83 | + $pattern = "# o'clock"; |
|
| 84 | + $wanted = "123456789 o'clock"; |
|
| 85 | + $this->assertEquals($wanted, $formatter->format($number, $pattern)); |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | function testPadding() { |
| 90 | - $formatter = new NumberFormat(); |
|
| 91 | - $number = '5'; |
|
| 90 | + $formatter = new NumberFormat(); |
|
| 91 | + $number = '5'; |
|
| 92 | 92 | |
| 93 | - $pattern = '0000'; |
|
| 94 | - $wanted = '0005'; |
|
| 93 | + $pattern = '0000'; |
|
| 94 | + $wanted = '0005'; |
|
| 95 | 95 | |
| 96 | - $this->assertEquals($wanted, $formatter->format($number, $pattern)); |
|
| 96 | + $this->assertEquals($wanted, $formatter->format($number, $pattern)); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | function testFormatWithANegativeValue() { |
| 100 | - $formatter = new NumberFormat(); |
|
| 101 | - $number = "-1.2"; |
|
| 100 | + $formatter = new NumberFormat(); |
|
| 101 | + $number = "-1.2"; |
|
| 102 | 102 | |
| 103 | - $wanted = "-1.2"; |
|
| 104 | - $this->assertEquals($wanted, $formatter->format($number)); |
|
| 103 | + $wanted = "-1.2"; |
|
| 104 | + $this->assertEquals($wanted, $formatter->format($number)); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function testFormatWithAScientificPattern() { |
| 108 | - $formatter = new NumberFormat(); |
|
| 109 | - $number = "10"; |
|
| 110 | - $expected = "10E"; |
|
| 111 | - $this->assertEquals('10E', $formatter->format($number, 'e')); |
|
| 108 | + $formatter = new NumberFormat(); |
|
| 109 | + $number = "10"; |
|
| 110 | + $expected = "10E"; |
|
| 111 | + $this->assertEquals('10E', $formatter->format($number, 'e')); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | function testRounding() |
| 115 | 115 | { |
| 116 | - $formatter = new NumberFormat(); |
|
| 116 | + $formatter = new NumberFormat(); |
|
| 117 | 117 | |
| 118 | - $number = 349.999; |
|
| 119 | - $pattern = '#.00'; |
|
| 120 | - $expected = '350.00'; |
|
| 118 | + $number = 349.999; |
|
| 119 | + $pattern = '#.00'; |
|
| 120 | + $expected = '350.00'; |
|
| 121 | 121 | |
| 122 | - $this->assertEquals($expected, $formatter->format($number, $pattern)); |
|
| 122 | + $this->assertEquals($expected, $formatter->format($number, $pattern)); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | function testRounding2() |
| 126 | 126 | { |
| 127 | - $formatter = new NumberFormat(); |
|
| 127 | + $formatter = new NumberFormat(); |
|
| 128 | 128 | |
| 129 | - $number = 349.99; |
|
| 130 | - $pattern = '#.00'; |
|
| 131 | - $expected = '349.99'; |
|
| 129 | + $number = 349.99; |
|
| 130 | + $pattern = '#.00'; |
|
| 131 | + $expected = '349.99'; |
|
| 132 | 132 | |
| 133 | - $this->assertEquals($expected, $formatter->format($number, $pattern)); |
|
| 133 | + $this->assertEquals($expected, $formatter->format($number, $pattern)); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | function testLocalizedCurrencyFormats2() { |
| 137 | 137 | |
| 138 | - $it = new NumberFormat('it_IT'); |
|
| 138 | + $it = new NumberFormat('it_IT'); |
|
| 139 | 139 | |
| 140 | - $number = 12.41; |
|
| 141 | - $wanted = '12,41'; |
|
| 142 | - $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 140 | + $number = 12.41; |
|
| 141 | + $wanted = '12,41'; |
|
| 142 | + $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 143 | 143 | |
| 144 | - $number = 10.23; |
|
| 145 | - $wanted = '10,23'; |
|
| 146 | - $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 144 | + $number = 10.23; |
|
| 145 | + $wanted = '10,23'; |
|
| 146 | + $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 147 | 147 | |
| 148 | - $number = 10010.23; |
|
| 149 | - $wanted = '10.010,23'; |
|
| 150 | - $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 148 | + $number = 10010.23; |
|
| 149 | + $wanted = '10.010,23'; |
|
| 150 | + $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 151 | 151 | |
| 152 | - $old= setlocale(LC_ALL,"0"); |
|
| 153 | - setlocale(LC_ALL,"it_IT"); |
|
| 152 | + $old= setlocale(LC_ALL,"0"); |
|
| 153 | + setlocale(LC_ALL,"it_IT"); |
|
| 154 | 154 | |
| 155 | - $number = 12.41; |
|
| 156 | - $wanted = '12,41'; |
|
| 157 | - $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 155 | + $number = 12.41; |
|
| 156 | + $wanted = '12,41'; |
|
| 157 | + $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 158 | 158 | |
| 159 | - $number = 10.23; |
|
| 160 | - $wanted = '10,23'; |
|
| 161 | - $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 159 | + $number = 10.23; |
|
| 160 | + $wanted = '10,23'; |
|
| 161 | + $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 162 | 162 | |
| 163 | - $number = 10010.23; |
|
| 164 | - $wanted = '10.010,23'; |
|
| 165 | - $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 163 | + $number = 10010.23; |
|
| 164 | + $wanted = '10.010,23'; |
|
| 165 | + $this->assertEquals($wanted, $it->format($number,'d')); |
|
| 166 | 166 | |
| 167 | - setlocale(LC_ALL,$old); |
|
| 167 | + setlocale(LC_ALL,$old); |
|
| 168 | 168 | } |
| 169 | 169 | } |
@@ -10,76 +10,76 @@ |
||
| 10 | 10 | protected $culture; |
| 11 | 11 | |
| 12 | 12 | function setUp() { |
| 13 | - $this->culture = CultureInfo::getInvariantCulture(); |
|
| 13 | + $this->culture = CultureInfo::getInvariantCulture(); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function testCultureName() { |
| 17 | - $name = 'en'; |
|
| 17 | + $name = 'en'; |
|
| 18 | 18 | |
| 19 | - $this->assertEquals($name, $this->culture->Name); |
|
| 19 | + $this->assertEquals($name, $this->culture->Name); |
|
| 20 | 20 | |
| 21 | - //the default/invariant culture should be neutral |
|
| 22 | - $this->assertTrue($this->culture->IsNeutralCulture); |
|
| 21 | + //the default/invariant culture should be neutral |
|
| 22 | + $this->assertTrue($this->culture->IsNeutralCulture); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | function testCultureList() { |
| 26 | - $allCultures = CultureInfo::getCultures(); |
|
| 27 | - $neutralCultures = CultureInfo::getCultures(CultureInfo::NEUTRAL); |
|
| 28 | - $specificCultures = CultureInfo::getCultures(CultureInfo::SPECIFIC); |
|
| 29 | - |
|
| 30 | - //there should be 246 cultures all together. |
|
| 31 | - $this->assertEquals(count($allCultures),246); |
|
| 32 | - $this->assertEquals(count($neutralCultures),76); |
|
| 33 | - $this->assertEquals(count($specificCultures),170); |
|
| 26 | + $allCultures = CultureInfo::getCultures(); |
|
| 27 | + $neutralCultures = CultureInfo::getCultures(CultureInfo::NEUTRAL); |
|
| 28 | + $specificCultures = CultureInfo::getCultures(CultureInfo::SPECIFIC); |
|
| 29 | + |
|
| 30 | + //there should be 246 cultures all together. |
|
| 31 | + $this->assertEquals(count($allCultures),246); |
|
| 32 | + $this->assertEquals(count($neutralCultures),76); |
|
| 33 | + $this->assertEquals(count($specificCultures),170); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | function testParentCultures() { |
| 37 | - $zh_CN = new CultureInfo('zh_CN'); |
|
| 38 | - $parent = $zh_CN->Parent; |
|
| 39 | - $grandparent = $parent->Parent; |
|
| 40 | - |
|
| 41 | - $this->assertEquals($zh_CN->Name, 'zh_CN'); |
|
| 42 | - $this->assertEquals($parent->Name, 'zh'); |
|
| 43 | - $this->assertEquals($grandparent->Name, 'en'); |
|
| 44 | - $this->assertEquals($grandparent->Parent->Name, 'en'); |
|
| 37 | + $zh_CN = new CultureInfo('zh_CN'); |
|
| 38 | + $parent = $zh_CN->Parent; |
|
| 39 | + $grandparent = $parent->Parent; |
|
| 40 | + |
|
| 41 | + $this->assertEquals($zh_CN->Name, 'zh_CN'); |
|
| 42 | + $this->assertEquals($parent->Name, 'zh'); |
|
| 43 | + $this->assertEquals($grandparent->Name, 'en'); |
|
| 44 | + $this->assertEquals($grandparent->Parent->Name, 'en'); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | function testCountryNames() { |
| 48 | - $culture = new CultureInfo('fr_FR'); |
|
| 49 | - $this->assertEquals($culture->Countries['AE'], 'Émirats arabes unis'); |
|
| 48 | + $culture = new CultureInfo('fr_FR'); |
|
| 49 | + $this->assertEquals($culture->Countries['AE'], 'Émirats arabes unis'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function testCurrencies() { |
| 53 | - $culture = new CultureInfo('en_AU'); |
|
| 54 | - $au = array('$', 'Australian Dollar'); |
|
| 55 | - $this->assertEquals($au, $culture->Currencies['AUD']); |
|
| 53 | + $culture = new CultureInfo('en_AU'); |
|
| 54 | + $au = array('$', 'Australian Dollar'); |
|
| 55 | + $this->assertEquals($au, $culture->Currencies['AUD']); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function testLanguages() { |
| 59 | - $culture = new CultureInfo('fr_BE'); |
|
| 60 | - $this->assertEquals($culture->Languages['fr'], 'français'); |
|
| 59 | + $culture = new CultureInfo('fr_BE'); |
|
| 60 | + $this->assertEquals($culture->Languages['fr'], 'français'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | function testScripts() { |
| 64 | - $culture = new CultureInfo('fr'); |
|
| 65 | - $this->assertEquals($culture->Scripts['Armn'], 'arménien'); |
|
| 64 | + $culture = new CultureInfo('fr'); |
|
| 65 | + $this->assertEquals($culture->Scripts['Armn'], 'arménien'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | function testTimeZones() { |
| 69 | - $culture = new CultureInfo('fi'); |
|
| 70 | - $zone = array( |
|
| 69 | + $culture = new CultureInfo('fi'); |
|
| 70 | + $zone = array( |
|
| 71 | 71 | "America/Los_Angeles", |
| 72 | 72 | "Tyynenmeren normaaliaika", |
| 73 | 73 | "PST", |
| 74 | 74 | "Tyynenmeren kesäaika", |
| 75 | 75 | "PDT", |
| 76 | 76 | "Los Angeles"); |
| 77 | - $this->assertEquals($culture->TimeZones[1],$zone); |
|
| 77 | + $this->assertEquals($culture->TimeZones[1],$zone); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | function test_missing_english_names_returns_culture_code() |
| 81 | 81 | { |
| 82 | - $culture = new CultureInfo('iw'); |
|
| 83 | - $this->assertEquals($culture->getEnglishName(), 'iw'); |
|
| 82 | + $culture = new CultureInfo('iw'); |
|
| 83 | + $this->assertEquals($culture->getEnglishName(), 'iw'); |
|
| 84 | 84 | } |
| 85 | 85 | } |
@@ -10,77 +10,77 @@ |
||
| 10 | 10 | class NumberFormatInfoTest extends PHPUnit_Framework_TestCase { |
| 11 | 11 | |
| 12 | 12 | function testCurrencyPatterns() { |
| 13 | - $numberInfo = NumberFormatInfo::getCurrencyInstance(); |
|
| 14 | - |
|
| 15 | - //there should be 2 decimal places. |
|
| 16 | - $this->assertEquals($numberInfo->DecimalDigits,2); |
|
| 17 | - $this->assertEquals($numberInfo->DecimalSeparator,'.'); |
|
| 18 | - $this->assertEquals($numberInfo->GroupSeparator,','); |
|
| 19 | - |
|
| 20 | - //there should be only 1 grouping of size 3 |
|
| 21 | - $groupsize = array(3,false); |
|
| 22 | - $this->assertEquals($numberInfo->GroupSizes, $groupsize); |
|
| 23 | - |
|
| 24 | - //the default negative pattern prefix and postfix |
|
| 25 | - $negPattern = array('-¤',''); |
|
| 26 | - $this->assertEquals($numberInfo->NegativePattern, $negPattern); |
|
| 27 | - |
|
| 28 | - //the default positive pattern prefix and postfix |
|
| 29 | - $negPattern = array('¤',''); |
|
| 30 | - $this->assertEquals($numberInfo->PositivePattern, $negPattern); |
|
| 31 | - |
|
| 32 | - //the default currency symbol |
|
| 33 | - $this->assertEquals($numberInfo->CurrencySymbol, 'US$'); |
|
| 34 | - $this->assertEquals($numberInfo->getCurrencySymbol('JPY'), '¥'); |
|
| 35 | - $this->assertEquals($numberInfo->NegativeInfinitySymbol, '-∞'); |
|
| 36 | - $this->assertEquals($numberInfo->PositiveInfinitySymbol, '+∞'); |
|
| 37 | - $this->assertEquals($numberInfo->NegativeSign, '-'); |
|
| 38 | - $this->assertEquals($numberInfo->PositiveSign, '+'); |
|
| 39 | - $this->assertEquals($numberInfo->NaNSymbol, '�'); |
|
| 40 | - $this->assertEquals($numberInfo->PercentSymbol, '%'); |
|
| 41 | - $this->assertEquals($numberInfo->PerMilleSymbol, '‰'); |
|
| 13 | + $numberInfo = NumberFormatInfo::getCurrencyInstance(); |
|
| 14 | + |
|
| 15 | + //there should be 2 decimal places. |
|
| 16 | + $this->assertEquals($numberInfo->DecimalDigits,2); |
|
| 17 | + $this->assertEquals($numberInfo->DecimalSeparator,'.'); |
|
| 18 | + $this->assertEquals($numberInfo->GroupSeparator,','); |
|
| 19 | + |
|
| 20 | + //there should be only 1 grouping of size 3 |
|
| 21 | + $groupsize = array(3,false); |
|
| 22 | + $this->assertEquals($numberInfo->GroupSizes, $groupsize); |
|
| 23 | + |
|
| 24 | + //the default negative pattern prefix and postfix |
|
| 25 | + $negPattern = array('-¤',''); |
|
| 26 | + $this->assertEquals($numberInfo->NegativePattern, $negPattern); |
|
| 27 | + |
|
| 28 | + //the default positive pattern prefix and postfix |
|
| 29 | + $negPattern = array('¤',''); |
|
| 30 | + $this->assertEquals($numberInfo->PositivePattern, $negPattern); |
|
| 31 | + |
|
| 32 | + //the default currency symbol |
|
| 33 | + $this->assertEquals($numberInfo->CurrencySymbol, 'US$'); |
|
| 34 | + $this->assertEquals($numberInfo->getCurrencySymbol('JPY'), '¥'); |
|
| 35 | + $this->assertEquals($numberInfo->NegativeInfinitySymbol, '-∞'); |
|
| 36 | + $this->assertEquals($numberInfo->PositiveInfinitySymbol, '+∞'); |
|
| 37 | + $this->assertEquals($numberInfo->NegativeSign, '-'); |
|
| 38 | + $this->assertEquals($numberInfo->PositiveSign, '+'); |
|
| 39 | + $this->assertEquals($numberInfo->NaNSymbol, '�'); |
|
| 40 | + $this->assertEquals($numberInfo->PercentSymbol, '%'); |
|
| 41 | + $this->assertEquals($numberInfo->PerMilleSymbol, '‰'); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | function testPatternsSet() { |
| 45 | - $numberInfo = NumberFormatInfo::getInstance(); |
|
| 45 | + $numberInfo = NumberFormatInfo::getInstance(); |
|
| 46 | 46 | |
| 47 | - $numberInfo->DecimalDigits = 0; |
|
| 48 | - $this->assertEquals($numberInfo->DecimalDigits,0); |
|
| 47 | + $numberInfo->DecimalDigits = 0; |
|
| 48 | + $this->assertEquals($numberInfo->DecimalDigits,0); |
|
| 49 | 49 | |
| 50 | - $numberInfo->DecimalSeparator = ','; |
|
| 51 | - $this->assertEquals($numberInfo->DecimalSeparator,','); |
|
| 50 | + $numberInfo->DecimalSeparator = ','; |
|
| 51 | + $this->assertEquals($numberInfo->DecimalSeparator,','); |
|
| 52 | 52 | |
| 53 | - $numberInfo->GroupSeparator = ' '; |
|
| 54 | - $this->assertEquals($numberInfo->GroupSeparator,' '); |
|
| 53 | + $numberInfo->GroupSeparator = ' '; |
|
| 54 | + $this->assertEquals($numberInfo->GroupSeparator,' '); |
|
| 55 | 55 | |
| 56 | - $numberInfo->GroupSizes = array(2,3); |
|
| 57 | - $groupsize = array(2,3); |
|
| 58 | - $this->assertEquals($numberInfo->GroupSizes, $groupsize); |
|
| 56 | + $numberInfo->GroupSizes = array(2,3); |
|
| 57 | + $groupsize = array(2,3); |
|
| 58 | + $this->assertEquals($numberInfo->GroupSizes, $groupsize); |
|
| 59 | 59 | |
| 60 | - $numberInfo->NegativePattern = array('-$$','.'); |
|
| 61 | - $negPattern = array('-$$','.'); |
|
| 62 | - $this->assertEquals($numberInfo->NegativePattern, $negPattern); |
|
| 60 | + $numberInfo->NegativePattern = array('-$$','.'); |
|
| 61 | + $negPattern = array('-$$','.'); |
|
| 62 | + $this->assertEquals($numberInfo->NegativePattern, $negPattern); |
|
| 63 | 63 | |
| 64 | - $numberInfo->PositivePattern = array('YY','.'); |
|
| 65 | - $negPattern = array('YY','.'); |
|
| 66 | - $this->assertEquals($numberInfo->PositivePattern, $negPattern); |
|
| 64 | + $numberInfo->PositivePattern = array('YY','.'); |
|
| 65 | + $negPattern = array('YY','.'); |
|
| 66 | + $this->assertEquals($numberInfo->PositivePattern, $negPattern); |
|
| 67 | 67 | |
| 68 | - //the default CurrencySymbol symbol |
|
| 69 | - $numberInfo->CurrencySymbol = '$$$'; |
|
| 70 | - $this->assertEquals($numberInfo->CurrencySymbol, '$$$'); |
|
| 68 | + //the default CurrencySymbol symbol |
|
| 69 | + $numberInfo->CurrencySymbol = '$$$'; |
|
| 70 | + $this->assertEquals($numberInfo->CurrencySymbol, '$$$'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | function testLocalizedPatterns() { |
| 74 | - $fr = NumberFormatInfo::getInstance('fr'); |
|
| 75 | - $de = NumberFormatInfo::getInstance('de'); |
|
| 76 | - $en = NumberFormatInfo::getInstance('en_US'); |
|
| 74 | + $fr = NumberFormatInfo::getInstance('fr'); |
|
| 75 | + $de = NumberFormatInfo::getInstance('de'); |
|
| 76 | + $en = NumberFormatInfo::getInstance('en_US'); |
|
| 77 | 77 | |
| 78 | - $this->assertEquals($fr->DecimalSeparator, ','); |
|
| 79 | - $this->assertEquals($de->DecimalSeparator, ','); |
|
| 80 | - $this->assertEquals($en->DecimalSeparator, '.'); |
|
| 78 | + $this->assertEquals($fr->DecimalSeparator, ','); |
|
| 79 | + $this->assertEquals($de->DecimalSeparator, ','); |
|
| 80 | + $this->assertEquals($en->DecimalSeparator, '.'); |
|
| 81 | 81 | |
| 82 | - $this->assertEquals($fr->GroupSeparator, ' '); |
|
| 83 | - $this->assertEquals($de->GroupSeparator, '.'); |
|
| 84 | - $this->assertEquals($en->GroupSeparator, ','); |
|
| 82 | + $this->assertEquals($fr->GroupSeparator, ' '); |
|
| 83 | + $this->assertEquals($de->GroupSeparator, '.'); |
|
| 84 | + $this->assertEquals($en->GroupSeparator, ','); |
|
| 85 | 85 | } |
| 86 | 86 | } |