mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Refactoring tests in l10n that use object properties.
This commit is contained in:
parent
ae4a31f070
commit
317463096a
1 changed files with 25 additions and 81 deletions
|
@ -43,61 +43,33 @@ class L10nTest extends CakeTestCase {
|
|||
|
||||
// Catalog Entry
|
||||
$l10n->get('en');
|
||||
$result = $l10n->language;
|
||||
$expected = 'English';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->languagePath;
|
||||
$expected = array('eng', 'eng');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->locale;
|
||||
$expected = 'eng';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($l10n->language, 'English');
|
||||
$this->assertEqual($l10n->languagePath, array('eng', 'eng'));
|
||||
$this->assertEqual($l10n->locale, 'eng');
|
||||
|
||||
// Map Entry
|
||||
$l10n->get('eng');
|
||||
$result = $l10n->language;
|
||||
$expected = 'English';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->languagePath;
|
||||
$expected = array('eng', 'eng');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->locale;
|
||||
$expected = 'eng';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($l10n->language, 'English');
|
||||
$this->assertEqual($l10n->languagePath, array('eng', 'eng'));
|
||||
$this->assertEqual($l10n->locale, 'eng');
|
||||
|
||||
// Catalog Entry
|
||||
$l10n->get('en-ca');
|
||||
$result = $l10n->language;
|
||||
$expected = 'English (Canadian)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->languagePath;
|
||||
$expected = array('en_ca', 'eng');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->locale;
|
||||
$expected = 'en_ca';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($l10n->language, 'English (Canadian)');
|
||||
$this->assertEqual($l10n->languagePath, array('en_ca', 'eng'));
|
||||
$this->assertEqual($l10n->locale, 'en_ca');
|
||||
|
||||
// Default Entry
|
||||
define('DEFAULT_LANGUAGE', 'en-us');
|
||||
|
||||
$l10n->get('use_default');
|
||||
$result = $l10n->language;
|
||||
$expected = 'English (United States)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->languagePath;
|
||||
$expected = array('en_us', 'eng');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->locale;
|
||||
$expected = 'en_us';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($l10n->language, 'English (United States)');
|
||||
$this->assertEqual($l10n->languagePath, array('en_us', 'eng'));
|
||||
$this->assertEqual($l10n->locale, 'en_us');
|
||||
|
||||
$l10n->get('es');
|
||||
$l10n->get('');
|
||||
|
@ -106,18 +78,11 @@ class L10nTest extends CakeTestCase {
|
|||
|
||||
// Using $this->default
|
||||
$l10n = new L10n();
|
||||
|
||||
$l10n->get('use_default');
|
||||
$result = $l10n->language;
|
||||
$expected = 'English (United States)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->languagePath;
|
||||
$expected = array('en_us', 'eng', 'eng');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->locale;
|
||||
$expected = 'en_us';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($l10n->language, 'English (United States)');
|
||||
$this->assertEqual($l10n->languagePath, array('en_us', 'eng', 'eng'));
|
||||
$this->assertEqual($l10n->locale, 'en_us');
|
||||
}
|
||||
/**
|
||||
* testGetAutoLanguage method
|
||||
|
@ -131,45 +96,24 @@ class L10nTest extends CakeTestCase {
|
|||
|
||||
$l10n =& new L10n();
|
||||
$l10n->get();
|
||||
$result = $l10n->language;
|
||||
$expected = 'English (Canadian)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->languagePath;
|
||||
$expected = array('en_ca', 'eng', 'eng');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->locale;
|
||||
$expected = 'en_ca';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($l10n->language, 'English (Canadian)');
|
||||
$this->assertEqual($l10n->languagePath, array('en_ca', 'eng', 'eng'));
|
||||
$this->assertEqual($l10n->locale, 'en_ca');
|
||||
|
||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'es_mx';
|
||||
$l10n->get();
|
||||
$result = $l10n->language;
|
||||
$expected = 'Spanish (Mexican)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->languagePath;
|
||||
$expected = array('es_mx', 'spa', 'eng');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->locale;
|
||||
$expected = 'es_mx';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($l10n->language, 'Spanish (Mexican)');
|
||||
$this->assertEqual($l10n->languagePath, array('es_mx', 'spa', 'eng'));
|
||||
$this->assertEqual($l10n->locale, 'es_mx');
|
||||
|
||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en_xy,en_ca';
|
||||
$l10n->get();
|
||||
$result = $l10n->language;
|
||||
$expected = 'English';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->languagePath;
|
||||
$expected = array('eng', 'eng', 'eng');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $l10n->locale;
|
||||
$expected = 'eng';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($l10n->language, 'English');
|
||||
$this->assertEqual($l10n->languagePath, array('eng', 'eng', 'eng'));
|
||||
$this->assertEqual($l10n->locale, 'eng');
|
||||
|
||||
$_SERVER = $__SERVER;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue