| | 65 | |
|---|
| | 66 | |
|---|
| | 67 | function testSimpleLocale(){ |
|---|
| | 68 | $this->assertEqual('ceci est une phrase fr_FR',jLocale::get('test1.first.locale')); |
|---|
| | 69 | $this->assertEqual('ceci est une phrase fr_FR',jLocale::get('test1.first.locale', null, 'fr_FR')); |
|---|
| | 70 | $this->assertEqual('ceci est une phrase fr_CA',jLocale::get('test1.first.locale', null, 'fr_CA')); |
|---|
| | 71 | $this->assertEqual('this is an en_US sentence',jLocale::get('test1.first.locale', null, 'en_US')); |
|---|
| | 72 | $this->assertEqual('this is an en_EN sentence',jLocale::get('test1.first.locale', null, 'en_EN')); |
|---|
| | 73 | } |
|---|
| | 74 | |
|---|
| | 75 | function testWithNoAskedLocale(){ |
|---|
| | 76 | // all this tests are made on an existing locale file |
|---|
| | 77 | |
|---|
| | 78 | $this->assertEqual('ceci est une phrase 2 fr_FR',jLocale::get('test1.second.locale')); |
|---|
| | 79 | // no test1.second.locale in fr_CA, so we should have the fr_FR one |
|---|
| | 80 | $this->assertEqual('ceci est une phrase 2 fr_FR',jLocale::get('test1.second.locale', null, 'fr_CA')); |
|---|
| | 81 | // no test1.third.locale in fr_CA, fr_FR, so we should have the en_EN one |
|---|
| | 82 | $this->assertEqual('this is an en_EN sentence',jLocale::get('test1.third.locale', null, 'fr_CA')); |
|---|
| | 83 | $this->assertEqual('this is an en_EN sentence',jLocale::get('test1.third.locale', null, 'fr_FR')); |
|---|
| | 84 | |
|---|
| | 85 | try{ |
|---|
| | 86 | jLocale::get('test1.fourth.locale', null, 'fr_FR') |
|---|
| | 87 | $this->fail('no exception when trying to get test1.fourth.locale locale'); |
|---|
| | 88 | }catch(jException $e){ |
|---|
| | 89 | $this->pass(); |
|---|
| | 90 | } |
|---|
| | 91 | } |
|---|
| | 92 | |
|---|
| | 93 | function testWithNoAskedLocaleFile(){ |
|---|
| | 94 | // all this tests are made on an non existing locale file |
|---|
| | 95 | |
|---|
| | 96 | $this->assertEqual('ceci est une phrase fr_FR test2',jLocale::get('test2.first.locale')); |
|---|
| | 97 | // no test2.properties file for fr_CA, so we should have the fr_FR one |
|---|
| | 98 | $this->assertEqual('ceci est une phrase fr_FR test2',jLocale::get('test2.first.locale', null, 'fr_CA')); |
|---|
| | 99 | // no test3.properties file for fr_CA and fr_FR, so we should have the en_EN one |
|---|
| | 100 | $this->assertEqual('this is an en_EN sentence test3',jLocale::get('test3.first.locale', null, 'fr_CA')); |
|---|
| | 101 | $this->assertEqual('this is an en_EN sentence test3',jLocale::get('test3.first.locale', null, 'fr_FR')); |
|---|
| | 102 | } |
|---|
| | 103 | |
|---|