From 317463096a4f22b624595568925c1c27aaecc95f Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 20 Jan 2010 14:53:57 -0500 Subject: [PATCH] Refactoring tests in l10n that use object properties. --- cake/tests/cases/libs/l10n.test.php | 106 +++++++--------------------- 1 file changed, 25 insertions(+), 81 deletions(-) diff --git a/cake/tests/cases/libs/l10n.test.php b/cake/tests/cases/libs/l10n.test.php index 1e99235ef..a11d1e031 100644 --- a/cake/tests/cases/libs/l10n.test.php +++ b/cake/tests/cases/libs/l10n.test.php @@ -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; }