summaryrefslogtreecommitdiff
path: root/tests/unit/I18N/core/CultureInfoTest.php
blob: 6c1eda06d6955694daa18eee5b6f39ddba24eb7f (plain)
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
79
80
81
82
83
84
85
86
87
<?php


Prado::using('System.I18N.core.CultureInfo');

/**
 * @package System.I18N.core
 */
class CultureInfoTest extends PHPUnit_Framework_TestCase {
  protected $culture;
 
  function setUp() {
    $this->culture = CultureInfo::getInvariantCulture();
  }
  
  function testCultureName() {
    $name = 'en';
    
    $this->assertEquals($name, $this->culture->Name);
    
    //the default/invariant culture should be neutral
    $this->assertTrue($this->culture->IsNeutralCulture);
  }

  function testCultureList() {
    $allCultures = CultureInfo::getCultures();
    $neutralCultures = CultureInfo::getCultures(CultureInfo::NEUTRAL);
    $specificCultures = CultureInfo::getCultures(CultureInfo::SPECIFIC);
    
    //there should be 246 cultures all together.
    $this->assertEquals(count($allCultures),246);
    $this->assertEquals(count($neutralCultures),76);
    $this->assertEquals(count($specificCultures),170);  
  }

  function testParentCultures() {
    $zh_CN = new CultureInfo('zh_CN');
    $parent = $zh_CN->Parent;
    $grandparent = $parent->Parent;
    
    $this->assertEquals($zh_CN->Name, 'zh_CN');
    $this->assertEquals($parent->Name, 'zh');
    $this->assertEquals($grandparent->Name, 'en');
    $this->assertEquals($grandparent->Parent->Name, 'en');
  }

  function testCountryNames() {
    $culture = new CultureInfo('fr_FR');
    $this->assertEquals($culture->Countries['AE'], 'Émirats arabes unis');
  }

  function testCurrencies() {
    $culture = new CultureInfo('en_AU');
    $au = array('$', 'Australian Dollar');
    $this->assertEquals($au, $culture->Currencies['AUD']);
  }
  
  function testLanguages() {
    $culture = new CultureInfo('fr_BE');
    $this->assertEquals($culture->Languages['fr'], 'français');
  }
  
  function testScripts() {
    $culture = new CultureInfo('fr');
    $this->assertEquals($culture->Scripts['Armn'], 'arménien');
  }
  
  function testTimeZones() {
    $culture = new CultureInfo('fi');
    $zone = array(
		  "America/Los_Angeles",
		  "Tyynenmeren normaaliaika",
		  "PST",
		  "Tyynenmeren kesäaika",
		  "PDT",
		  "Los Angeles");
    $this->assertEquals($culture->TimeZones[1],$zone);
  }

  function test_missing_english_names_returns_culture_code()
  {
    $culture = new CultureInfo('iw');
    $this->assertEquals($culture->getEnglishName(), 'iw');
  }
}

?>