Skip to content
Permalink
Browse files

Refactoring tests in l10n that use object properties.

  • Loading branch information...
markstory committed Jan 20, 2010
1 parent ae4a31f commit 317463096a4f22b624595568925c1c27aaecc95f
Showing with 25 additions and 81 deletions.
  1. +25 −81 cake/tests/cases/libs/l10n.test.php
@@ -43,61 +43,33 @@ function testGet() {
// 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 @@ function testGet() {
// 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);
$l10n->get('use_default');
$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 @@ function testGetAutoLanguage() {
$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;
}

0 comments on commit 3174630

Please sign in to comment.
You can’t perform that action at this time.