From 886cd9e719beae718b4f6aadbcb0f7ffc5eec367 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 27 Dec 2009 23:09:26 -0500 Subject: [PATCH 001/137] Adding Router::reverse and basic test case. --- cake/libs/router.php | 21 +++++++++++++++ cake/tests/cases/libs/router.test.php | 39 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/cake/libs/router.php b/cake/libs/router.php index 61b5b2a77..c3894ea36 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -981,6 +981,27 @@ class Router { return $out; } +/** + * Reverses a parsed parameter array into a string. Works similarily to Router::url(), but + * Since parsed URL's contain additional 'pass' and 'named' as well as 'url.url' keys. + * Those keys need to be specially handled in order to reverse a params array into a string url. + * + * @param array $param The params array that needs to be reversed. + * @return string The string that is the reversed result of the array + * @access public + */ + function reverse($params) { + $pass = $params['pass']; + $named = $params['named']; + $url = $params['url']; + unset($params['pass'], $params['named'], $params['url'], $url['url']); + $params = array_merge($params, $pass, $named); + if (!empty($url)) { + $params['q'] = $url; + } + return Router::url($params); + } + /** * Normalizes a URL for purposes of comparison * diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index d6a18a59c..02d590c3a 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1942,6 +1942,45 @@ class RouterTest extends CakeTestCase { $result = Router::parse('/test'); $this->assertEqual($result, $expected); } + +/** + * test reversing parameter arrays back into strings. + * + * @return void + */ + function testRouterReverse() { + $params = array( + 'controller' => 'posts', + 'action' => 'view', + 'pass' => array(1), + 'named' => array(), + 'url' => array() + ); + $result = Router::reverse($params); + $this->assertEqual($result, '/posts/view/1'); + + $params = array( + 'controller' => 'posts', + 'action' => 'index', + 'pass' => array(1), + 'named' => array('page' => 1, 'sort' => 'Article.title', 'direction' => 'desc'), + 'url' => array() + ); + $result = Router::reverse($params); + $this->assertEqual($result, '/posts/index/1/page:1/sort:Article.title/direction:desc'); + + Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[a-z]{3}')); + $params = array( + 'lang' => 'eng', + 'controller' => 'posts', + 'action' => 'view', + 'pass' => array(1), + 'named' => array(), + 'url' => array('url' => 'eng/posts/view/1') + ); + $result = Router::reverse($params); + $this->assertEqual($result, '/eng/posts/view/1'); + } } /** From 5b78a662e805b15308530362286d1529f8d5bf13 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 27 Dec 2009 23:10:29 -0500 Subject: [PATCH 002/137] Adding tests for querystring reversal. --- cake/libs/router.php | 2 +- cake/tests/cases/libs/router.test.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index c3894ea36..cb4c00a3c 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -997,7 +997,7 @@ class Router { unset($params['pass'], $params['named'], $params['url'], $url['url']); $params = array_merge($params, $pass, $named); if (!empty($url)) { - $params['q'] = $url; + $params['?'] = $url; } return Router::url($params); } diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 02d590c3a..61329565a 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1980,6 +1980,17 @@ class RouterTest extends CakeTestCase { ); $result = Router::reverse($params); $this->assertEqual($result, '/eng/posts/view/1'); + + $params = array( + 'lang' => 'eng', + 'controller' => 'posts', + 'action' => 'view', + 'pass' => array(1), + 'named' => array(), + 'url' => array('url' => 'eng/posts/view/1', 'foo' => 'bar', 'baz' => 'quu') + ); + $result = Router::reverse($params); + $this->assertEqual($result, '/eng/posts/view/1?foo=bar&baz=quu'); } } From df8914b2e4151f88f7f2c046bbaa897cc4ed0cb6 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 28 Dec 2009 13:34:05 -0500 Subject: [PATCH 003/137] Router::reverse now removes models and paging keys that controllers can insert into params arrays. --- cake/libs/router.php | 2 +- cake/tests/cases/libs/router.test.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index cb4c00a3c..92193b429 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -994,7 +994,7 @@ class Router { $pass = $params['pass']; $named = $params['named']; $url = $params['url']; - unset($params['pass'], $params['named'], $params['url'], $url['url']); + unset($params['pass'], $params['named'], $params['paging'], $params['models'], $params['url'], $url['url']); $params = array_merge($params, $pass, $named); if (!empty($url)) { $params['?'] = $url; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 61329565a..552d5d05b 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1987,7 +1987,9 @@ class RouterTest extends CakeTestCase { 'action' => 'view', 'pass' => array(1), 'named' => array(), - 'url' => array('url' => 'eng/posts/view/1', 'foo' => 'bar', 'baz' => 'quu') + 'url' => array('url' => 'eng/posts/view/1', 'foo' => 'bar', 'baz' => 'quu'), + 'paging' => array(), + 'models' => array() ); $result = Router::reverse($params); $this->assertEqual($result, '/eng/posts/view/1?foo=bar&baz=quu'); From 45a3eb250f6323123ec0718d18447ac5713dc8a3 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 28 Dec 2009 13:38:36 -0500 Subject: [PATCH 004/137] Starting refactoring of cachehelper to use Router::reverse to generate check/match strings. Removing dead code as well. --- cake/libs/view/helpers/cache.php | 36 ++-------- .../cases/libs/view/helpers/cache.test.php | 69 ++++++++++++++++++- 2 files changed, 74 insertions(+), 31 deletions(-) diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 718784a27..60c1a9eae 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -67,25 +67,10 @@ class CacheHelper extends AppHelper { $cacheTime = 0; $useCallbacks = false; if (is_array($this->cacheAction)) { - $controller = Inflector::underscore($this->controllerName); - $controllerAlternate = Inflector::variable($this->controllerName); - - $check = str_replace('/', '_', $this->here); - $basePath = str_replace('/', '_', $this->base); - - $match = str_replace($this->base, '', $this->here); - $match = str_replace('//', '/', $match); - $match = str_replace('/' . $controller . '/', '', $match); - $match = str_replace('/' . $controllerAlternate . '/', '', $match); - $match = str_replace('/' . $this->controllerName . '/', '', $match); - - $check = str_replace($basePath, '', $check); - $check = str_replace('_' . $controller . '_', '', $check); - $check = str_replace('_' . $this->controllerName . '_', '', $check); - $check = str_replace('_' . $controllerAlternate . '_', '', $match); - - $check = Inflector::slug($check); - $check = trim($check, '_'); + $check = Inflector::slug(Router::reverse($this->params)); + $base = trim(str_replace('/', '_', $this->base), '_'); + $check = trim(str_replace($base, '', $check), '_'); + $match = $check; $keys = str_replace('/', '_', array_keys($this->cacheAction)); $found = array_keys($this->cacheAction); @@ -93,23 +78,14 @@ class CacheHelper extends AppHelper { $count = 0; foreach ($keys as $key => $value) { - if (strpos($check, rtrim($value, '_')) === 0) { + if (strpos($check, rtrim($value, '_')) !== false) { $index = $found[$count]; break; } $count++; } - if (isset($index)) { - $pos1 = strrpos($match, '/'); - $char = strlen($match) - 1; - - if ($pos1 == $char) { - $match = substr($match, 0, $char); - } - - $key = $match; - } elseif ($this->action == 'index') { + if (!isset($index) && $this->action == 'index') { $index = 'index'; } diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index abcc7c192..3cc5966c6 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -127,6 +127,13 @@ class CacheHelperTest extends CakeTestCase { */ function testLayoutCacheParsingNoTagsInView() { $this->Controller->cache_parsing(); + $this->Controller->params = array( + 'controller' => 'cache_test', + 'action' => 'cache_parsing', + 'url' => array(), + 'pass' => array(), + 'named' => array() + ); $this->Controller->cacheAction = 21600; $this->Controller->here = '/cacheTest/cache_parsing'; $this->Controller->action = 'cache_parsing'; @@ -155,6 +162,13 @@ class CacheHelperTest extends CakeTestCase { */ function testCacheNonLatinCharactersInRoute() { $this->Controller->cache_parsing(); + $this->Controller->params = array( + 'controller' => 'cache_test', + 'action' => 'cache_parsing', + 'url' => array(), + 'pass' => array('風街ろまん'), + 'named' => array() + ); $this->Controller->cacheAction = 21600; $this->Controller->here = '/posts/view/風街ろまん'; $this->Controller->action = 'view'; @@ -175,6 +189,13 @@ class CacheHelperTest extends CakeTestCase { */ function testLayoutCacheParsingWithTagsInView() { $this->Controller->cache_parsing(); + $this->Controller->params = array( + 'controller' => 'cache_test', + 'action' => 'cache_parsing', + 'url' => array(), + 'pass' => array(), + 'named' => array() + ); $this->Controller->cacheAction = 21600; $this->Controller->here = '/cacheTest/cache_parsing'; $this->Controller->action = 'cache_parsing'; @@ -203,6 +224,13 @@ class CacheHelperTest extends CakeTestCase { */ function testMultipleNoCacheTagsInViewfile() { $this->Controller->cache_parsing(); + $this->Controller->params = array( + 'controller' => 'cache_test', + 'action' => 'cache_parsing', + 'url' => array(), + 'pass' => array(), + 'named' => array() + ); $this->Controller->cacheAction = 21600; $this->Controller->here = '/cacheTest/cache_parsing'; $this->Controller->action = 'cache_parsing'; @@ -229,6 +257,13 @@ class CacheHelperTest extends CakeTestCase { */ function testComplexNoCache () { $this->Controller->cache_parsing(); + $this->Controller->params = array( + 'controller' => 'cache_test', + 'action' => 'cache_complex', + 'url' => array(), + 'pass' => array(), + 'named' => array() + ); $this->Controller->cacheAction = array('cache_complex' => 21600); $this->Controller->here = '/cacheTest/cache_complex'; $this->Controller->action = 'cache_complex'; @@ -283,6 +318,13 @@ class CacheHelperTest extends CakeTestCase { */ function testCacheActionArray() { $this->Controller->cache_parsing(); + $this->Controller->params = array( + 'controller' => 'cache_test', + 'action' => 'cache_parsing', + 'url' => array(), + 'pass' => array(), + 'named' => array() + ); $this->Controller->cacheAction = array( 'cache_parsing' => 21600 ); @@ -319,6 +361,13 @@ class CacheHelperTest extends CakeTestCase { $this->Controller->cache_parsing(); + $this->Controller->params = array( + 'controller' => 'cache_test', + 'action' => 'cache_parsing', + 'url' => array(), + 'pass' => array(33), + 'named' => array() + ); $this->Controller->cacheAction = array( 'cache_parsing/33' => 21600 ); @@ -334,8 +383,15 @@ class CacheHelperTest extends CakeTestCase { $filename = CACHE . 'views' . DS . 'cachetest_cache_parsing_33.php'; $this->assertTrue(file_exists($filename)); @unlink($filename); - + $this->Controller->cache_parsing(); + $this->Controller->params = array( + 'controller' => 'cache_test', + 'action' => 'cache_parsing', + 'url' => array(), + 'pass' => array(), + 'named' => array() + ); $this->Controller->cacheAction = array( 'cache_parsing/33' => 21600 ); @@ -351,6 +407,17 @@ class CacheHelperTest extends CakeTestCase { $filename = CACHE . 'views' . DS . 'cachetest_cache_parsing.php'; $this->assertFalse(file_exists($filename)); } + +/** + * test that custom routes are respected when generating cache files. + * + * @return void + */ + function testCacheWithCustomRoutes() { + Router::reload(); + Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[a-z]{3}')); + + } /** * testCacheEmptySections method * From 6749e1166bfd2067fcb5ba8a1e542887b8a811fc Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 28 Dec 2009 21:26:51 -0500 Subject: [PATCH 005/137] Making cacheAction array settings use action names instead of url paths. This removes the ability to set different durations for specific passed arguments. However, makes passed args, named params, and querystring params all behave the same in regard to cacheAction. Test cases updated. --- cake/libs/view/helpers/cache.php | 20 +++---- .../cases/libs/view/helpers/cache.test.php | 55 +++++++++---------- 2 files changed, 33 insertions(+), 42 deletions(-) diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 60c1a9eae..59baef793 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -70,19 +70,15 @@ class CacheHelper extends AppHelper { $check = Inflector::slug(Router::reverse($this->params)); $base = trim(str_replace('/', '_', $this->base), '_'); $check = trim(str_replace($base, '', $check), '_'); - $match = $check; - $keys = str_replace('/', '_', array_keys($this->cacheAction)); - $found = array_keys($this->cacheAction); + $keys = array_keys($this->cacheAction); $index = null; - $count = 0; - foreach ($keys as $key => $value) { - if (strpos($check, rtrim($value, '_')) !== false) { - $index = $found[$count]; + foreach ($keys as $action) { + if ($action == $this->params['action']) { + $index = $action; break; } - $count++; } if (!isset($index) && $this->action == 'index') { @@ -92,19 +88,17 @@ class CacheHelper extends AppHelper { $options = $this->cacheAction; if (isset($this->cacheAction[$index])) { if (is_array($this->cacheAction[$index])) { - $options = array_merge(array('duration'=> 0, 'callbacks' => false), $this->cacheAction[$index]); + $options = array_merge(array('duration' => 0, 'callbacks' => false), $this->cacheAction[$index]); } else { $cacheTime = $this->cacheAction[$index]; } } - - if (array_key_exists('duration', $options)) { + if (isset($options['duration'])) { $cacheTime = $options['duration']; } - if (array_key_exists('callbacks', $options)) { + if (isset($options['callbacks'])) { $useCallbacks = $options['callbacks']; } - } else { $cacheTime = $this->cacheAction; } diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index 3cc5966c6..d804e2f1d 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -17,9 +17,6 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ -if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { - define('CAKEPHP_UNIT_TEST_EXECUTION', 1); -} App::import('Core', array('Controller', 'Model', 'View')); App::import('Helper', 'Cache'); @@ -344,7 +341,7 @@ class CacheHelperTest extends CakeTestCase { $this->Controller->cache_parsing(); $this->Controller->cacheAction = array( - 'cache_parsing/' => 21600 + 'cache_parsing' => 21600 ); $this->Controller->here = '/cacheTest/cache_parsing'; $this->Controller->action = 'cache_parsing'; @@ -360,30 +357,6 @@ class CacheHelperTest extends CakeTestCase { @unlink($filename); - $this->Controller->cache_parsing(); - $this->Controller->params = array( - 'controller' => 'cache_test', - 'action' => 'cache_parsing', - 'url' => array(), - 'pass' => array(33), - 'named' => array() - ); - $this->Controller->cacheAction = array( - 'cache_parsing/33' => 21600 - ); - $this->Controller->here = '/cacheTest/cache_parsing/33'; - $this->Controller->action = 'cache_parsing'; - - $View = new View($this->Controller); - $result = $View->render('index'); - - $this->assertNoPattern('/cake:nocache/', $result); - $this->assertNoPattern('/php echo/', $result); - - $filename = CACHE . 'views' . DS . 'cachetest_cache_parsing_33.php'; - $this->assertTrue(file_exists($filename)); - @unlink($filename); - $this->Controller->cache_parsing(); $this->Controller->params = array( 'controller' => 'cache_test', @@ -393,7 +366,7 @@ class CacheHelperTest extends CakeTestCase { 'named' => array() ); $this->Controller->cacheAction = array( - 'cache_parsing/33' => 21600 + 'some_other_action' => 21600 ); $this->Controller->here = '/cacheTest/cache_parsing'; $this->Controller->action = 'cache_parsing'; @@ -416,7 +389,31 @@ class CacheHelperTest extends CakeTestCase { function testCacheWithCustomRoutes() { Router::reload(); Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[a-z]{3}')); + + $this->Controller->cache_parsing(); + $this->Controller->params = array( + 'lang' => 'en', + 'controller' => 'cache_test', + 'action' => 'cache_parsing', + 'url' => array(), + 'pass' => array(), + 'named' => array() + ); + $this->Controller->cacheAction = array( + 'cache_parsing' => 21600 + ); + $this->Controller->here = '/en/cache_test/cache_parsing'; + $this->Controller->action = 'cache_parsing'; + $View = new View($this->Controller); + $result = $View->render('index'); + + $this->assertNoPattern('/cake:nocache/', $result); + $this->assertNoPattern('/php echo/', $result); + + $filename = CACHE . 'views' . DS . 'en_cache_test_cache_parsing.php'; + $this->assertTrue(file_exists($filename)); + @unlink($filename); } /** * testCacheEmptySections method From 2db479dc90ac74c72beaa70d00f3c881e60ad754 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 28 Dec 2009 21:58:56 -0500 Subject: [PATCH 006/137] Making CacheHelper create $this->Html style helper references. --- cake/libs/view/helpers/cache.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 59baef793..98989942c 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -256,6 +256,7 @@ class CacheHelper extends AppHelper { $camelBackedHelper = Inflector::variable($helper); ${$camelBackedHelper} =& $loadedHelpers[$helper]; $this->loaded[$camelBackedHelper] =& ${$camelBackedHelper}; + $this->{$helper} =& $loadedHelpers[$helper]; } ?>'; $content = preg_replace("/(<\\?xml)/", "",$content); From 3ad4dd63bff2a8a7e2528f988c904139e58a4728 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 28 Dec 2009 22:15:07 -0500 Subject: [PATCH 007/137] Removing unused variables from CacheHelper::cache() Removing non-existant variable output from generated cache files. --- cake/libs/view/helpers/cache.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 98989942c..0d8357ae9 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -67,10 +67,6 @@ class CacheHelper extends AppHelper { $cacheTime = 0; $useCallbacks = false; if (is_array($this->cacheAction)) { - $check = Inflector::slug(Router::reverse($this->params)); - $base = trim(str_replace('/', '_', $this->base), '_'); - $check = trim(str_replace($base, '', $check), '_'); - $keys = array_keys($this->cacheAction); $index = null; @@ -233,8 +229,6 @@ class CacheHelper extends AppHelper { $controller->layout = $this->layout = \'' . $this->layout. '\'; $controller->webroot = $this->webroot = \'' . $this->webroot . '\'; $controller->here = $this->here = \'' . $this->here . '\'; - $controller->namedArgs = $this->namedArgs = \'' . $this->namedArgs . '\'; - $controller->argSeparator = $this->argSeparator = \'' . $this->argSeparator . '\'; $controller->params = $this->params = unserialize(stripslashes(\'' . addslashes(serialize($this->params)) . '\')); $controller->action = $this->action = unserialize(\'' . serialize($this->action) . '\'); $controller->data = $this->data = unserialize(stripslashes(\'' . addslashes(serialize($this->data)) . '\')); From a9e1d0d7ff26aa51a9a6b04242ea8e9f7ac91532 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 28 Dec 2009 22:56:21 -0500 Subject: [PATCH 008/137] Optimizing Sanitize::html() to use str_replace instead of preg_replace. --- cake/libs/sanitize.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index ef3d7dbaf..8edb7b8d4 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -90,9 +90,9 @@ class Sanitize { if ($remove) { $string = strip_tags($string); } else { - $patterns = array("/\&/", "/%/", "//", '/"/', "/'/", "/\(/", "/\)/", "/\+/", "/-/"); + $patterns = array('&', '%', '<', '>', '"', "'", '(', ')', '+', '-'); $replacements = array("&", "%", "<", ">", """, "'", "(", ")", "+", "-"); - $string = preg_replace($patterns, $replacements, $string); + $string = str_replace($patterns, $replacements, $string); } return $string; } From b37790574173eaa4e9ca274c3dd7b6d48fe7d2a3 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 28 Dec 2009 23:00:38 -0500 Subject: [PATCH 009/137] Fixing whitespacing and formatting of doc blocks. --- cake/tests/cases/libs/sanitize.test.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/cake/tests/cases/libs/sanitize.test.php b/cake/tests/cases/libs/sanitize.test.php index 683592ed1..49b023b77 100644 --- a/cake/tests/cases/libs/sanitize.test.php +++ b/cake/tests/cases/libs/sanitize.test.php @@ -194,7 +194,8 @@ class SanitizeTest extends CakeTestCase { $result = Sanitize::clean($string); $this->assertEqual($string, $expected); } - /** + +/** * testHtml method * * @access public @@ -211,7 +212,8 @@ class SanitizeTest extends CakeTestCase { $result = Sanitize::html($string); $this->assertEqual($result, $expected); } - /** + +/** * testStripWhitespace method * * @access public @@ -223,7 +225,8 @@ class SanitizeTest extends CakeTestCase { $result = Sanitize::stripWhitespace($string); $this->assertEqual($result, $expected); } - /** + +/** * testParanoid method * * @access public @@ -264,7 +267,8 @@ class SanitizeTest extends CakeTestCase { $result = Sanitize::paranoid($string); $this->assertEqual($result, $expected); } - /** + +/** * testStripImages method * * @access public @@ -291,7 +295,8 @@ class SanitizeTest extends CakeTestCase { $result = Sanitize::stripImages($string); $this->assertEqual($result, $expected); } - /** + +/** * testStripScripts method * * @access public @@ -328,7 +333,8 @@ class SanitizeTest extends CakeTestCase { $result = Sanitize::stripScripts($string); $this->assertEqual($result, $expected); } - /** + +/** * testStripAll method * * @access public @@ -359,7 +365,8 @@ class SanitizeTest extends CakeTestCase { $this->assertEqual($result, $expected); } - /** + +/** * testStripTags method * * @access public @@ -401,7 +408,8 @@ class SanitizeTest extends CakeTestCase { $result = Sanitize::stripTags($string, 'h2', 'a', 'img'); $this->assertEqual($result, $expected); } - /** + +/** * testFormatColumns method * * @access public From 1216884a308572f96bf93e82aec8275df98a7bfe Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 17 Dec 2009 01:02:20 -0500 Subject: [PATCH 010/137] Starting work on bake template redesign. --- app/webroot/css/cake.generic.css | 27 ++++++++++++++----- cake/console/templates/default/views/form.ctp | 1 + .../console/templates/default/views/index.ctp | 11 ++++---- cake/console/templates/default/views/view.ctp | 1 + 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index 77ca75e80..8136c5f22 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -45,31 +45,27 @@ a img { } h1, h2, h3, h4 { font-weight: normal; + margin-bottom:0.5em; } h1 { background:#fff; color: #003d4c; font-size: 100%; - margin: 0.1em 0; } h2 { background:#fff; color: #e32; font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; font-size: 190%; - margin: 0.3em 0; - padding-top: 0.8em; } h3 { color: #993; font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; font-size: 165%; - padding-top: 1.5em; } h4 { color: #993; font-weight: normal; - padding-top: 0.5em; } ul, li { margin: 0 12px; @@ -112,6 +108,24 @@ ul, li { text-align: right; } +div.form, +div.index, +div.view { + float:right; + width:81%; + border-left:1px solid #666; + padding:10px 2%; +} +div.actions { + float:left; + width:9.5%; + padding:10px 2%; +} +div.actions h3 { + padding-top:0; +} + + /* Tables */ table { background: #fff; @@ -170,6 +184,7 @@ div.paging { background:#fff; color: #ccc; margin-bottom: 2em; + clear:both; } div.paging div.disabled { color: #ddd; @@ -212,7 +227,7 @@ form { } fieldset { border: 1px solid #ccc; - margin-top: 30px; + margin-bottom: 1em; padding: 16px 20px; } fieldset legend { diff --git a/cake/console/templates/default/views/form.ctp b/cake/console/templates/default/views/form.ctp index a86f034cc..4438f9487 100644 --- a/cake/console/templates/default/views/form.ctp +++ b/cake/console/templates/default/views/form.ctp @@ -43,6 +43,7 @@ ?>
+

  • Html->link(__('Delete', true), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?', true), \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>";?>
  • diff --git a/cake/console/templates/default/views/index.ctp b/cake/console/templates/default/views/index.ctp index a539c57e5..a1ddce926 100644 --- a/cake/console/templates/default/views/index.ctp +++ b/cake/console/templates/default/views/index.ctp @@ -69,13 +69,14 @@ foreach (\${$pluralVar} as \${$singularVar}): echo "\n"; ?> -
-
-Paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>\n";?> - | Paginator->numbers();?>\n"?> -Paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>\n";?> +
+ Paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>\n";?> + | Paginator->numbers();?>\n"?> + Paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>\n";?> +
+

  • Html->link(sprintf(__('New %s', true), __('{$singularHumanName}', true)), array('action' => 'add')); ?>";?>
+

    Html->link(sprintf(__('Edit %s', true), __('{$singularHumanName}', true)), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> \n"; From b0a50e10b7a21e044fdda8a021328b4f6011f757 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 17 Dec 2009 23:17:15 -0500 Subject: [PATCH 011/137] Updating bake templates and default css file. --- app/webroot/css/cake.generic.css | 8 +-- .../console/templates/default/views/index.ctp | 57 ++++++++++--------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index 8136c5f22..66945e208 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -183,17 +183,15 @@ td.actions a { div.paging { background:#fff; color: #ccc; - margin-bottom: 2em; + margin-top: 1em; clear:both; } -div.paging div.disabled { +div.paging span.disabled { color: #ddd; display: inline; } -div.paging span { -} div.paging span.current { - color: #000; + color: #993; } div.paging span a { } diff --git a/cake/console/templates/default/views/index.ctp b/cake/console/templates/default/views/index.ctp index a1ddce926..c0e7222ed 100644 --- a/cake/console/templates/default/views/index.ctp +++ b/cake/console/templates/default/views/index.ctp @@ -18,30 +18,23 @@ */ ?>
    -

    ";?>

    -

    -Paginator->counter(array( -'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) -)); -?>";?> -

    - - - - - - - -\n"; +

    ";?>

    +
    Paginator->sort('{$field}');?>";?>";?>
    + + + + + + + \n"; echo "\t>\n"; foreach ($fields as $field) { $isKey = false; @@ -66,12 +59,20 @@ foreach (\${$pluralVar} as \${$singularVar}): echo "\t\t\n"; echo "\t\n"; -echo "\n"; -?> -
    Paginator->sort('{$field}');?>";?>";?>
    + echo "\n"; + ?> + +

    + Paginator->counter(array( + 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) + )); + ?>";?> +

    +
    Paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>\n";?> - | Paginator->numbers();?>\n"?> + | Paginator->numbers();?>\n"?> | Paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>\n";?>
    From 183e358fbe949ce962f07f8b8486b77ef5cd4c92 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 17 Dec 2009 23:56:02 -0500 Subject: [PATCH 012/137] Updating CSS file and making a nicer cake icon. --- app/webroot/css/cake.generic.css | 64 ++++++++++++++++++++----------- app/webroot/img/cake.icon.gif | Bin 233 -> 0 bytes app/webroot/img/cake.icon.png | Bin 0 -> 943 bytes 3 files changed, 41 insertions(+), 23 deletions(-) delete mode 100644 app/webroot/img/cake.icon.gif create mode 100644 app/webroot/img/cake.icon.png diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index 66945e208..bf868e5c5 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -80,7 +80,8 @@ ul, li { padding: 10px 20px; } #header h1 { - background: #003d4c url('../img/cake.icon.gif') no-repeat left; + line-height:20px; + background: #003d4c url('../img/cake.icon.png') no-repeat left; color: #fff; padding: 0px 30px; } @@ -108,6 +109,7 @@ ul, li { text-align: right; } +/** containers **/ div.form, div.index, div.view { @@ -118,7 +120,7 @@ div.view { } div.actions { float:left; - width:9.5%; + width:11%; padding:10px 2%; } div.actions h3 { @@ -129,7 +131,6 @@ div.actions h3 { /* Tables */ table { background: #fff; - border:1px solid #ccc; border-right:0; clear: both; color: #333; @@ -137,29 +138,32 @@ table { width: 100%; } th { - background: #f2f2f2; - border:1px solid #bbb; - border-top: 1px solid #fff; - border-left: 1px solid #fff; + border:0; + border-bottom:2px solid #555; text-align: center; + padding:4px; } th a { - background:#f2f2f2; display: block; padding: 2px 4px; text-decoration: none; } th a:hover { - background: #ccc; - color: #333; + color: #00cdff; text-decoration: none; } +th a.asc:after { + content: ' ⇣'; +} +th a.desc:after { + content: ' ⇡'; +} table tr td { background: #fff; - border-right: 1px solid #ccc; - padding: 4px; + padding: 6px; text-align: center; vertical-align: top; + border-bottom:1px solid #ddd; } table tr.altrow td { background: #f4f4f4; @@ -168,8 +172,9 @@ td.actions { text-align: center; white-space: nowrap; } -td.actions a { +table td.actions a { margin: 0px 6px; + padding:2px 5px; } .cake-sql-log table { background: #f4f4f4; @@ -191,7 +196,7 @@ div.paging span.disabled { display: inline; } div.paging span.current { - color: #993; + color: #c73e14; } div.paging span a { } @@ -307,9 +312,7 @@ div.radio label { input[type=submit] { display: inline; font-size: 110%; - padding: 2px 5px; width: auto; - vertical-align: bottom; } /* Notices and Errors */ @@ -360,22 +363,37 @@ div.actions ul { padding: 0; } div.actions li { - display: inline; + margin:0 0 0.5em 0; list-style-type: none; - line-height: 2em; - margin: 0 2em 0 0; white-space: nowrap; } div.actions ul li a { - background:#fff; - color: #003d4c; - text-decoration: none; + font-weight:normal; + display:block; } div.actions ul li a:hover { - color: #333; text-decoration: underline; } +input[type=submit], +div.actions ul li a, +td.actions a { + font-weight:normal; + padding: 4px 8px; + background:#f0f09a; + background: -webkit-gradient(linear, left top, left bottom, from(#f1f1d4), to(#e6e49f)); + text-shadow: #fff 0px 1px 0px; + color:#333; + border:1px solid #aaac62; + -webkit-border-radius:8px; + text-decoration:none; +} +input[type=submit]:hover, +div.actions ul li a:hover, +td.actions a:hover { + background: -webkit-gradient(linear, left top, left bottom, from(#f7f7e1), to(#eeeca9)); +} + /* Related */ div.related { clear: both; diff --git a/app/webroot/img/cake.icon.gif b/app/webroot/img/cake.icon.gif deleted file mode 100644 index f29f72ebef20ce39a1e3721d31b76d9054b1dc90..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 233 zcmVOrfx~(a*Br=IF!2lMFyj!pzT(o0Foa zdn-*>Om~4(V_pR~MF2EGA^8La000jFEC2ui02BZe000D*@X1N5t>>`K@|6NJ6h&YL z1u`%~wUB3glC5+ga)976a!3oFOhFu(2DMubr5G5VhQ{x4NGt;hD1iW&9tgW!0iZB! z6O)6HG-waF&;)>@C@r&FLW6?XF3Wfe6jmrIZUbdo27(g_16K`ZTZ}-3IRcmfa});+ jCL}5ZNSK%y0t-u|r5FwZRfnys7YD7i0<9mpxe)+6uKiOz diff --git a/app/webroot/img/cake.icon.png b/app/webroot/img/cake.icon.png new file mode 100644 index 0000000000000000000000000000000000000000..394fa42d5131cdc7b0b1246af93b92179f3c887e GIT binary patch literal 943 zcmV;g15o^lP)9q)cr7> zIGsQFGn3| zCzs2iP$-yfVPOGVTU&6sT(-5fwHb2tVsLP9#{Vr9Ct?R7q(rf?v2A5#W$OI=e1YUJ zQ1YRnA&iWSQ1XYAm__>aYb6XIhMiYVD+-z8_pYi6+CsH{*^m;vOjqvbr=H&DFkeqxHQBh$Scsoy0Glw(T zsaSG*ok62V;~yXYNgP*DUw;o98^+0@vGFb{HC+As}XJ=;xg=B7N_;-mKbHH{|lXs_o+aPcs5~J?s%^P2Odb)Uz z$GvY6^!N9(C2-h?28B$qx7%_yHnt2eU%nQ0qThbl6a_+b)EirjBgQ`g1_07Fr&6R? RzIgxu002ovPDHLkV1mdlwUYn< literal 0 HcmV?d00001 From fbb3d3dcfa164dd56b74c2c6a1830bd489cfdad9 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 18 Dec 2009 00:46:00 -0500 Subject: [PATCH 013/137] Updating CSS including mozilla gradients. --- app/webroot/css/cake.generic.css | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index bf868e5c5..e63613c1c 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -36,8 +36,7 @@ a { font-weight: bold; } a:hover { - background:#fff; - color: #003d4c; + color: #367889; text-decoration:none; } a img { @@ -121,7 +120,7 @@ div.view { div.actions { float:left; width:11%; - padding:10px 2%; + padding:10px 1.5%; } div.actions h3 { padding-top:0; @@ -148,10 +147,6 @@ th a { padding: 2px 4px; text-decoration: none; } -th a:hover { - color: #00cdff; - text-decoration: none; -} th a.asc:after { content: ' ⇣'; } @@ -165,8 +160,9 @@ table tr td { vertical-align: top; border-bottom:1px solid #ddd; } +table tr:nth-child(2n) td, table tr.altrow td { - background: #f4f4f4; + background: #fafafa; } td.actions { text-align: center; @@ -380,17 +376,21 @@ div.actions ul li a, td.actions a { font-weight:normal; padding: 4px 8px; - background:#f0f09a; + background:#e6e49f; background: -webkit-gradient(linear, left top, left bottom, from(#f1f1d4), to(#e6e49f)); - text-shadow: #fff 0px 1px 0px; + background-image: -moz-linear-gradient(top, #f1f1d4, #e6e49f); color:#333; border:1px solid #aaac62; -webkit-border-radius:8px; + -moz-border-radius:8px; + border-radius:8px; text-decoration:none; + text-shadow: #fff 0px 1px 0px; } input[type=submit]:hover, div.actions ul li a:hover, td.actions a:hover { + background: #f0f09a; background: -webkit-gradient(linear, left top, left bottom, from(#f7f7e1), to(#eeeca9)); } From e067552b255fc22a29cc3a445977f6384d32f113 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 28 Dec 2009 23:53:22 -0500 Subject: [PATCH 014/137] Updating generic css file to include changes to flash messages (knockout text) submit buttons (green gradient) and required fields (*). --- app/webroot/css/cake.generic.css | 40 +++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index e63613c1c..48920bf25 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -30,7 +30,6 @@ body { margin: 0; } a { - background:#fff; color: #003d4c; text-decoration: underline; font-weight: bold; @@ -54,12 +53,12 @@ h1 { h2 { background:#fff; color: #e32; - font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; + font-family:'Gill Sans','lucida grande', helvetica, arial, sans-serif; font-size: 190%; } h3 { color: #993; - font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; + font-family:'Gill Sans','lucida grande', helvetica, arial, sans-serif; font-size: 165%; } h4 { @@ -124,6 +123,7 @@ div.actions { } div.actions h3 { padding-top:0; + color:#777; } @@ -178,6 +178,7 @@ table td.actions a { .cake-sql-log td { padding: 4px 8px; text-align: left; + font-family: Monaco, Consolas, "Courier New", monospaced; } /* Paging */ @@ -254,23 +255,26 @@ form div { padding: .5em; vertical-align: text-top; } -form div.input { +form .input { color: #444; } -form div.required { - color: #333; +form .required { font-weight: bold; } +form .required label:after { + color: #e32; + content: '*'; + display:inline; +} form div.submit { border: 0; clear: both; margin-top: 10px; - margin-left: 140px; } label { display: block; font-size: 110%; - padding-right: 20px; + margin-bottom:3px; } input, textarea { clear: both; @@ -310,19 +314,33 @@ input[type=submit] { font-size: 110%; width: auto; } +form .submit input[type=submit] { + background:#889a0d; + background: -webkit-gradient(linear, left top, left bottom, from(#a8ea9c), to(#62af56)); + background-image: -moz-linear-gradient(top, #9bcc66, #3da86a); + border-color: #2d6324; + color: #111; + text-shadow: #8cee7c 0px 1px 0px; +} +form .submit input[type=submit]:hover { + background: -webkit-gradient(linear, left top, left bottom, from(#85e573), to(#4ca83d)); +} /* Notices and Errors */ div.message { clear: both; - color: #900; + color: #fff; font-size: 140%; font-weight: bold; - margin: 1em 0; + margin: 0 0 1em 0; + background: #c73e14; + padding: 5px; } div.error-message { clear: both; - color: #900; + color: #fff; font-weight: bold; + background: #c73e14; } p.error { background-color: #e32; From cb0e63c2fd5938a2c9065fba62b3157798c4428d Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 28 Dec 2009 23:54:37 -0500 Subject: [PATCH 015/137] Updating CSS for firefox gradients, no gradients. --- app/webroot/css/cake.generic.css | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index 48920bf25..87b9684af 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -315,15 +315,17 @@ input[type=submit] { width: auto; } form .submit input[type=submit] { - background:#889a0d; + background:#62af56; background: -webkit-gradient(linear, left top, left bottom, from(#a8ea9c), to(#62af56)); - background-image: -moz-linear-gradient(top, #9bcc66, #3da86a); + background-image: -moz-linear-gradient(top, #a8ea9c, #62af56); border-color: #2d6324; color: #111; text-shadow: #8cee7c 0px 1px 0px; } form .submit input[type=submit]:hover { + background:#4ca83d; background: -webkit-gradient(linear, left top, left bottom, from(#85e573), to(#4ca83d)); + background-image: -moz-linear-gradient(top, #85e573, #4ca83d); } /* Notices and Errors */ From cd661126ae196f45301d6270e739848f6ce36a55 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 28 Dec 2009 23:57:44 -0500 Subject: [PATCH 016/137] Updating form field widths, so error messages align better. --- app/webroot/css/cake.generic.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index 87b9684af..c4b754233 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -280,8 +280,8 @@ input, textarea { clear: both; font-size: 140%; font-family: "frutiger linotype", "lucida grande", "verdana", sans-serif; - padding: 2px; - width: 100%; + padding: 1%; + width:98%; } select { clear: both; From 0e8f83e103d2b4e0aeca0f91f7a18b99632ce67f Mon Sep 17 00:00:00 2001 From: Ali Farhadi Date: Tue, 29 Dec 2009 22:26:00 +0330 Subject: [PATCH 017/137] Adding direction var and __l10nCatalog key to L10n class, fixes #4 --- cake/libs/l10n.php | 287 +++++++++++++++++++++++---------------------- 1 file changed, 148 insertions(+), 139 deletions(-) diff --git a/cake/libs/l10n.php b/cake/libs/l10n.php index 20064c83f..cff50caba 100644 --- a/cake/libs/l10n.php +++ b/cake/libs/l10n.php @@ -76,6 +76,14 @@ class L10n extends Object { */ var $charset = 'utf-8'; +/** + * Text direction for current locale + * + * @var string + * @access public + */ + var $direction = 'ltr'; + /** * Set to true if a locale is found * @@ -176,145 +184,145 @@ class L10n extends Object { * @var array * @access private */ - var $__l10nCatalog = array('af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8'), - 'ar' => array('language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-ae' => array('language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-bh' => array('language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-dz' => array('language' => 'Arabic (Algeria)', 'locale' => 'ar_dz', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-eg' => array('language' => 'Arabic (Egypt)', 'locale' => 'ar_eg', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-iq' => array('language' => 'Arabic (Iraq)', 'locale' => 'ar_iq', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-jo' => array('language' => 'Arabic (Jordan)', 'locale' => 'ar_jo', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-kw' => array('language' => 'Arabic (Kuwait)', 'locale' => 'ar_kw', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-lb' => array('language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-ly' => array('language' => 'Arabic (Libya)', 'locale' => 'ar_ly', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-ma' => array('language' => 'Arabic (Morocco)', 'locale' => 'ar_ma', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-om' => array('language' => 'Arabic (Oman)', 'locale' => 'ar_om', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-qa' => array('language' => 'Arabic (Qatar)', 'locale' => 'ar_qa', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-sa' => array('language' => 'Arabic (Saudi Arabia)', 'locale' => 'ar_sa', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-sy' => array('language' => 'Arabic (Syria)', 'locale' => 'ar_sy', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-tn' => array('language' => 'Arabic (Tunisia)', 'locale' => 'ar_tn', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-ye' => array('language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'be' => array('language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8'), - 'bg' => array('language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8'), - 'bs' => array('language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8'), - 'ca' => array('language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8'), - 'cs' => array('language' => 'Czech', 'locale' => 'cze', 'localeFallback' => 'cze', 'charset' => 'utf-8'), - 'da' => array('language' => 'Danish', 'locale' => 'dan', 'localeFallback' => 'dan', 'charset' => 'utf-8'), - 'de' => array('language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'de-at' => array('language' => 'German (Austria)', 'locale' => 'de_at', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'de-ch' => array('language' => 'German (Swiss)', 'locale' => 'de_ch', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'de-de' => array('language' => 'German (Germany)', 'locale' => 'de_de', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'de-li' => array('language' => 'German (Liechtenstein)', 'locale' => 'de_li', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'de-lu' => array('language' => 'German (Luxembourg)', 'locale' => 'de_lu', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'e' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8'), - 'el' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8'), - 'en' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-au' => array('language' => 'English (Australian)', 'locale' => 'en_au', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-bz' => array('language' => 'English (Belize)', 'locale' => 'en_bz', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-ca' => array('language' => 'English (Canadian)', 'locale' => 'en_ca', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-gb' => array('language' => 'English (British)', 'locale' => 'en_gb', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-ie' => array('language' => 'English (Ireland)', 'locale' => 'en_ie', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-jm' => array('language' => 'English (Jamaica)', 'locale' => 'en_jm', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-nz' => array('language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-tt' => array('language' => 'English (Trinidad)', 'locale' => 'en_tt', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-us' => array('language' => 'English (United States)', 'locale' => 'en_us', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-za' => array('language' => 'English (South Africa)', 'locale' => 'en_za', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'es' => array('language' => 'Spanish (Spain - Traditional)', 'locale' => 'spa', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-ar' => array('language' => 'Spanish (Argentina)', 'locale' => 'es_ar', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-bo' => array('language' => 'Spanish (Bolivia)', 'locale' => 'es_bo', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-cl' => array('language' => 'Spanish (Chile)', 'locale' => 'es_cl', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-co' => array('language' => 'Spanish (Colombia)', 'locale' => 'es_co', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-cr' => array('language' => 'Spanish (Costa Rica)', 'locale' => 'es_cr', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-do' => array('language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-ec' => array('language' => 'Spanish (Ecuador)', 'locale' => 'es_ec', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-es' => array('language' => 'Spanish (Spain)', 'locale' => 'es_es', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-gt' => array('language' => 'Spanish (Guatemala)', 'locale' => 'es_gt', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-hn' => array('language' => 'Spanish (Honduras)', 'locale' => 'es_hn', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-mx' => array('language' => 'Spanish (Mexican)', 'locale' => 'es_mx', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-ni' => array('language' => 'Spanish (Nicaragua)', 'locale' => 'es_ni', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-pa' => array('language' => 'Spanish (Panama)', 'locale' => 'es_pa', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-pe' => array('language' => 'Spanish (Peru)', 'locale' => 'es_pe', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-pr' => array('language' => 'Spanish (Puerto Rico)', 'locale' => 'es_pr', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-py' => array('language' => 'Spanish (Paraguay)', 'locale' => 'es_py', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-sv' => array('language' => 'Spanish (El Salvador)', 'locale' => 'es_sv', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-uy' => array('language' => 'Spanish (Uruguay)', 'locale' => 'es_uy', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-ve' => array('language' => 'Spanish (Venezuela)', 'locale' => 'es_ve', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'et' => array('language' => 'Estonian', 'locale' => 'est', 'localeFallback' => 'est', 'charset' => 'utf-8'), - 'eu' => array('language' => 'Basque', 'locale' => 'baq', 'localeFallback' => 'baq', 'charset' => 'utf-8'), - 'fa' => array('language' => 'Farsi', 'locale' => 'per', 'localeFallback' => 'per', 'charset' => 'utf-8'), - 'fi' => array('language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8'), - 'fo' => array('language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8'), - 'fr' => array('language' => 'French (Standard)', 'locale' => 'fre', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'fr-be' => array('language' => 'French (Belgium)', 'locale' => 'fr_be', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'fr-ca' => array('language' => 'French (Canadian)', 'locale' => 'fr_ca', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'fr-ch' => array('language' => 'French (Swiss)', 'locale' => 'fr_ch', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'fr-fr' => array('language' => 'French (France)', 'locale' => 'fr_fr', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'fr-lu' => array('language' => 'French (Luxembourg)', 'locale' => 'fr_lu', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'ga' => array('language' => 'Irish', 'locale' => 'gle', 'localeFallback' => 'gle', 'charset' => 'utf-8'), - 'gd' => array('language' => 'Gaelic (Scots)', 'locale' => 'gla', 'localeFallback' => 'gla', 'charset' => 'utf-8'), - 'gd-ie' => array('language' => 'Gaelic (Irish)', 'locale' => 'gd_ie', 'localeFallback' => 'gla', 'charset' => 'utf-8'), - 'gl' => array('language' => 'Galician', 'locale' => 'glg', 'localeFallback' => 'glg', 'charset' => 'utf-8'), - 'he' => array('language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8'), - 'hi' => array('language' => 'Hindi', 'locale' => 'hin', 'localeFallback' => 'hin', 'charset' => 'utf-8'), - 'hr' => array('language' => 'Croatian', 'locale' => 'hrv', 'localeFallback' => 'hrv', 'charset' => 'utf-8'), - 'hu' => array('language' => 'Hungarian', 'locale' => 'hun', 'localeFallback' => 'hun', 'charset' => 'utf-8'), - 'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8'), - 'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8'), - 'in' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8'), - 'is' => array('language' => 'Icelandic', 'locale' => 'ice', 'localeFallback' => 'ice', 'charset' => 'utf-8'), - 'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8'), - 'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8'), - 'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8'), - 'ko' => array('language' => 'Korean', 'locale' => 'kor', 'localeFallback' => 'kor', 'charset' => 'kr'), - 'ko-kp' => array('language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr'), - 'ko-kr' => array('language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr'), - 'koi8-r' => array('language' => 'Russian', 'locale' => 'koi8_r', 'localeFallback' => 'rus', 'charset' => 'koi8-r'), - 'lt' => array('language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8'), - 'lv' => array('language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8'), - 'mk' => array('language' => 'FYRO Macedonian', 'locale' => 'mk', 'localeFallback' => 'mac', 'charset' => 'utf-8'), - 'mk-mk' => array('language' => 'Macedonian', 'locale' => 'mk_mk', 'localeFallback' => 'mac', 'charset' => 'utf-8'), - 'ms' => array('language' => 'Malaysian', 'locale' => 'may', 'localeFallback' => 'may', 'charset' => 'utf-8'), - 'mt' => array('language' => 'Maltese', 'locale' => 'mlt', 'localeFallback' => 'mlt', 'charset' => 'utf-8'), - 'n' => array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8'), - 'nb' => array('language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8'), - 'nl' => array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8'), - 'nl-be' => array('language' => 'Dutch (Belgium)', 'locale' => 'nl_be', 'localeFallback' => 'dut', 'charset' => 'utf-8'), - 'nn' => array('language' => 'Norwegian Nynorsk', 'locale' => 'nno', 'localeFallback' => 'nor', 'charset' => 'utf-8'), - 'no' => array('language' => 'Norwegian', 'locale' => 'nor', 'localeFallback' => 'nor', 'charset' => 'utf-8'), - 'p' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8'), - 'pl' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8'), - 'pt' => array('language' => 'Portuguese (Portugal)', 'locale' => 'por', 'localeFallback' => 'por', 'charset' => 'utf-8'), - 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8'), - 'rm' => array('language' => 'Rhaeto-Romanic', 'locale' => 'roh', 'localeFallback' => 'roh', 'charset' => 'utf-8'), - 'ro' => array('language' => 'Romanian', 'locale' => 'rum', 'localeFallback' => 'rum', 'charset' => 'utf-8'), - 'ro-mo' => array('language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'rum', 'charset' => 'utf-8'), - 'ru' => array('language' => 'Russian', 'locale' => 'rus', 'localeFallback' => 'rus', 'charset' => 'utf-8'), - 'ru-mo' => array('language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8'), - 'sb' => array('language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8'), - 'sk' => array('language' => 'Slovak', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8'), - 'sl' => array('language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8'), - 'sq' => array('language' => 'Albanian', 'locale' => 'alb', 'localeFallback' => 'alb', 'charset' => 'utf-8'), - 'sr' => array('language' => 'Serbian', 'locale' => 'scc', 'localeFallback' => 'scc', 'charset' => 'utf-8'), - 'sv' => array('language' => 'Swedish', 'locale' => 'swe', 'localeFallback' => 'swe', 'charset' => 'utf-8'), - 'sv-fi' => array('language' => 'Swedish (Findland)', 'locale' => 'sv_fi', 'localeFallback' => 'swe', 'charset' => 'utf-8'), - 'sx' => array('language' => 'Sutu', 'locale' => 'sx', 'localeFallback' => 'sx', 'charset' => 'utf-8'), - 'sz' => array('language' => 'Sami (Lappish)', 'locale' => 'smi', 'localeFallback' => 'smi', 'charset' => 'utf-8'), - 'th' => array('language' => 'Thai', 'locale' => 'tha', 'localeFallback' => 'tha', 'charset' => 'utf-8'), - 'tn' => array('language' => 'Tswana', 'locale' => 'tsn', 'localeFallback' => 'tsn', 'charset' => 'utf-8'), - 'tr' => array('language' => 'Turkish', 'locale' => 'tur', 'localeFallback' => 'tur', 'charset' => 'utf-8'), - 'ts' => array('language' => 'Tsonga', 'locale' => 'tso', 'localeFallback' => 'tso', 'charset' => 'utf-8'), - 'uk' => array('language' => 'Ukrainian', 'locale' => 'ukr', 'localeFallback' => 'ukr', 'charset' => 'utf-8'), - 'ur' => array('language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8'), - 've' => array('language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8'), - 'vi' => array('language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8'), - 'xh' => array('language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8'), - 'yi' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8'), - 'zh' => array('language' => 'Chinese', 'locale' => 'chi', 'localeFallback' => 'chi', 'charset' => 'utf-8'), - 'zh-cn' => array('language' => 'Chinese (PRC)', 'locale' => 'zh_cn', 'localeFallback' => 'chi', 'charset' => 'GB2312'), - 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'chi', 'charset' => 'utf-8'), - 'zh-sg' => array('language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'chi', 'charset' => 'utf-8'), - 'zh-tw' => array('language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'chi', 'charset' => 'utf-8'), - 'zu' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8')); + var $__l10nCatalog = array('af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ar' => array('language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-ae' => array('language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-bh' => array('language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-dz' => array('language' => 'Arabic (Algeria)', 'locale' => 'ar_dz', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-eg' => array('language' => 'Arabic (Egypt)', 'locale' => 'ar_eg', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-iq' => array('language' => 'Arabic (Iraq)', 'locale' => 'ar_iq', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-jo' => array('language' => 'Arabic (Jordan)', 'locale' => 'ar_jo', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-kw' => array('language' => 'Arabic (Kuwait)', 'locale' => 'ar_kw', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-lb' => array('language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-ly' => array('language' => 'Arabic (Libya)', 'locale' => 'ar_ly', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-ma' => array('language' => 'Arabic (Morocco)', 'locale' => 'ar_ma', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-om' => array('language' => 'Arabic (Oman)', 'locale' => 'ar_om', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-qa' => array('language' => 'Arabic (Qatar)', 'locale' => 'ar_qa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-sa' => array('language' => 'Arabic (Saudi Arabia)', 'locale' => 'ar_sa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-sy' => array('language' => 'Arabic (Syria)', 'locale' => 'ar_sy', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-tn' => array('language' => 'Arabic (Tunisia)', 'locale' => 'ar_tn', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-ye' => array('language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'be' => array('language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'bg' => array('language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'bs' => array('language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ca' => array('language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'cs' => array('language' => 'Czech', 'locale' => 'cze', 'localeFallback' => 'cze', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'da' => array('language' => 'Danish', 'locale' => 'dan', 'localeFallback' => 'dan', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de' => array('language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de-at' => array('language' => 'German (Austria)', 'locale' => 'de_at', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de-ch' => array('language' => 'German (Swiss)', 'locale' => 'de_ch', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de-de' => array('language' => 'German (Germany)', 'locale' => 'de_de', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de-li' => array('language' => 'German (Liechtenstein)', 'locale' => 'de_li', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de-lu' => array('language' => 'German (Luxembourg)', 'locale' => 'de_lu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'e' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'el' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-au' => array('language' => 'English (Australian)', 'locale' => 'en_au', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-bz' => array('language' => 'English (Belize)', 'locale' => 'en_bz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-ca' => array('language' => 'English (Canadian)', 'locale' => 'en_ca', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-gb' => array('language' => 'English (British)', 'locale' => 'en_gb', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-ie' => array('language' => 'English (Ireland)', 'locale' => 'en_ie', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-jm' => array('language' => 'English (Jamaica)', 'locale' => 'en_jm', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-nz' => array('language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-tt' => array('language' => 'English (Trinidad)', 'locale' => 'en_tt', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-us' => array('language' => 'English (United States)', 'locale' => 'en_us', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-za' => array('language' => 'English (South Africa)', 'locale' => 'en_za', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es' => array('language' => 'Spanish (Spain - Traditional)', 'locale' => 'spa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-ar' => array('language' => 'Spanish (Argentina)', 'locale' => 'es_ar', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-bo' => array('language' => 'Spanish (Bolivia)', 'locale' => 'es_bo', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-cl' => array('language' => 'Spanish (Chile)', 'locale' => 'es_cl', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-co' => array('language' => 'Spanish (Colombia)', 'locale' => 'es_co', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-cr' => array('language' => 'Spanish (Costa Rica)', 'locale' => 'es_cr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-do' => array('language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-ec' => array('language' => 'Spanish (Ecuador)', 'locale' => 'es_ec', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-es' => array('language' => 'Spanish (Spain)', 'locale' => 'es_es', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-gt' => array('language' => 'Spanish (Guatemala)', 'locale' => 'es_gt', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-hn' => array('language' => 'Spanish (Honduras)', 'locale' => 'es_hn', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-mx' => array('language' => 'Spanish (Mexican)', 'locale' => 'es_mx', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-ni' => array('language' => 'Spanish (Nicaragua)', 'locale' => 'es_ni', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-pa' => array('language' => 'Spanish (Panama)', 'locale' => 'es_pa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-pe' => array('language' => 'Spanish (Peru)', 'locale' => 'es_pe', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-pr' => array('language' => 'Spanish (Puerto Rico)', 'locale' => 'es_pr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-py' => array('language' => 'Spanish (Paraguay)', 'locale' => 'es_py', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-sv' => array('language' => 'Spanish (El Salvador)', 'locale' => 'es_sv', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-uy' => array('language' => 'Spanish (Uruguay)', 'locale' => 'es_uy', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-ve' => array('language' => 'Spanish (Venezuela)', 'locale' => 'es_ve', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'et' => array('language' => 'Estonian', 'locale' => 'est', 'localeFallback' => 'est', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'eu' => array('language' => 'Basque', 'locale' => 'baq', 'localeFallback' => 'baq', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fa' => array('language' => 'Farsi', 'locale' => 'per', 'localeFallback' => 'per', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'fi' => array('language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fo' => array('language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr' => array('language' => 'French (Standard)', 'locale' => 'fre', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr-be' => array('language' => 'French (Belgium)', 'locale' => 'fr_be', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr-ca' => array('language' => 'French (Canadian)', 'locale' => 'fr_ca', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr-ch' => array('language' => 'French (Swiss)', 'locale' => 'fr_ch', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr-fr' => array('language' => 'French (France)', 'locale' => 'fr_fr', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr-lu' => array('language' => 'French (Luxembourg)', 'locale' => 'fr_lu', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ga' => array('language' => 'Irish', 'locale' => 'gle', 'localeFallback' => 'gle', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'gd' => array('language' => 'Gaelic (Scots)', 'locale' => 'gla', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'gd-ie' => array('language' => 'Gaelic (Irish)', 'locale' => 'gd_ie', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'gl' => array('language' => 'Galician', 'locale' => 'glg', 'localeFallback' => 'glg', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'he' => array('language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'hi' => array('language' => 'Hindi', 'locale' => 'hin', 'localeFallback' => 'hin', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'hr' => array('language' => 'Croatian', 'locale' => 'hrv', 'localeFallback' => 'hrv', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'hu' => array('language' => 'Hungarian', 'locale' => 'hun', 'localeFallback' => 'hun', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'in' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'is' => array('language' => 'Icelandic', 'locale' => 'ice', 'localeFallback' => 'ice', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ko' => array('language' => 'Korean', 'locale' => 'kor', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), + 'ko-kp' => array('language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), + 'ko-kr' => array('language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), + 'koi8-r' => array('language' => 'Russian', 'locale' => 'koi8_r', 'localeFallback' => 'rus', 'charset' => 'koi8-r', 'direction' => 'ltr'), + 'lt' => array('language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'lv' => array('language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'mk' => array('language' => 'FYRO Macedonian', 'locale' => 'mk', 'localeFallback' => 'mac', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'mk-mk' => array('language' => 'Macedonian', 'locale' => 'mk_mk', 'localeFallback' => 'mac', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ms' => array('language' => 'Malaysian', 'locale' => 'may', 'localeFallback' => 'may', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'mt' => array('language' => 'Maltese', 'locale' => 'mlt', 'localeFallback' => 'mlt', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'n' => array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'nb' => array('language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'nl' => array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'nl-be' => array('language' => 'Dutch (Belgium)', 'locale' => 'nl_be', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'nn' => array('language' => 'Norwegian Nynorsk', 'locale' => 'nno', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'no' => array('language' => 'Norwegian', 'locale' => 'nor', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'p' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'pl' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'pt' => array('language' => 'Portuguese (Portugal)', 'locale' => 'por', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'rm' => array('language' => 'Rhaeto-Romanic', 'locale' => 'roh', 'localeFallback' => 'roh', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ro' => array('language' => 'Romanian', 'locale' => 'rum', 'localeFallback' => 'rum', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ro-mo' => array('language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'rum', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ru' => array('language' => 'Russian', 'locale' => 'rus', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ru-mo' => array('language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sb' => array('language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sk' => array('language' => 'Slovak', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sl' => array('language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sq' => array('language' => 'Albanian', 'locale' => 'alb', 'localeFallback' => 'alb', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sr' => array('language' => 'Serbian', 'locale' => 'scc', 'localeFallback' => 'scc', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sv' => array('language' => 'Swedish', 'locale' => 'swe', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sv-fi' => array('language' => 'Swedish (Findland)', 'locale' => 'sv_fi', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sx' => array('language' => 'Sutu', 'locale' => 'sx', 'localeFallback' => 'sx', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sz' => array('language' => 'Sami (Lappish)', 'locale' => 'smi', 'localeFallback' => 'smi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'th' => array('language' => 'Thai', 'locale' => 'tha', 'localeFallback' => 'tha', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'tn' => array('language' => 'Tswana', 'locale' => 'tsn', 'localeFallback' => 'tsn', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'tr' => array('language' => 'Turkish', 'locale' => 'tur', 'localeFallback' => 'tur', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ts' => array('language' => 'Tsonga', 'locale' => 'tso', 'localeFallback' => 'tso', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'uk' => array('language' => 'Ukrainian', 'locale' => 'ukr', 'localeFallback' => 'ukr', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ur' => array('language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8', 'direction' => 'rtl'), + 've' => array('language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'vi' => array('language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'xh' => array('language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'yi' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'zh' => array('language' => 'Chinese', 'locale' => 'chi', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'zh-cn' => array('language' => 'Chinese (PRC)', 'locale' => 'zh_cn', 'localeFallback' => 'chi', 'charset' => 'GB2312', 'direction' => 'ltr'), + 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'zh-sg' => array('language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'zh-tw' => array('language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'zu' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr')); /** * Class constructor @@ -368,6 +376,7 @@ class L10n extends Object { $this->lang = $language; $this->locale = $this->__l10nCatalog[$langKey]['locale']; $this->charset = $this->__l10nCatalog[$langKey]['charset']; + $this->direction = $this->__l10nCatalog[$langKey]['direction']; } else { $this->lang = $language; $this->languagePath = array($language); From f86a80ac9e73501592117f85203eaddca26dbe09 Mon Sep 17 00:00:00 2001 From: Ali Farhadi Date: Tue, 29 Dec 2009 23:03:25 +0330 Subject: [PATCH 018/137] Fixing failing tests caused by changes in L10n class, and removal of duplicate test. --- cake/tests/cases/libs/l10n.test.php | 308 ++++++++++++++-------------- 1 file changed, 151 insertions(+), 157 deletions(-) diff --git a/cake/tests/cases/libs/l10n.test.php b/cake/tests/cases/libs/l10n.test.php index 969cbf372..415f0d64e 100644 --- a/cake/tests/cases/libs/l10n.test.php +++ b/cake/tests/cases/libs/l10n.test.php @@ -498,490 +498,484 @@ class L10nTest extends CakeTestCase { $result = $l10n->catalog(array('af')); $expected = array( - 'af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8') + 'af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('ar', 'ar-ae', 'ar-bh', 'ar-dz', 'ar-eg', 'ar-iq', 'ar-jo', 'ar-kw', 'ar-lb', 'ar-ly', 'ar-ma', 'ar-om', 'ar-qa', 'ar-sa', 'ar-sy', 'ar-tn', 'ar-ye')); $expected = array( - 'ar' => array('language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-ae' => array('language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-bh' => array('language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-dz' => array('language' => 'Arabic (Algeria)', 'locale' => 'ar_dz', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-eg' => array('language' => 'Arabic (Egypt)', 'locale' => 'ar_eg', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-iq' => array('language' => 'Arabic (Iraq)', 'locale' => 'ar_iq', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-jo' => array('language' => 'Arabic (Jordan)', 'locale' => 'ar_jo', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-kw' => array('language' => 'Arabic (Kuwait)', 'locale' => 'ar_kw', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-lb' => array('language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-ly' => array('language' => 'Arabic (Libya)', 'locale' => 'ar_ly', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-ma' => array('language' => 'Arabic (Morocco)', 'locale' => 'ar_ma', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-om' => array('language' => 'Arabic (Oman)', 'locale' => 'ar_om', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-qa' => array('language' => 'Arabic (Qatar)', 'locale' => 'ar_qa', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-sa' => array('language' => 'Arabic (Saudi Arabia)', 'locale' => 'ar_sa', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-sy' => array('language' => 'Arabic (Syria)', 'locale' => 'ar_sy', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-tn' => array('language' => 'Arabic (Tunisia)', 'locale' => 'ar_tn', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'ar-ye' => array('language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8') + 'ar' => array('language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-ae' => array('language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-bh' => array('language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-dz' => array('language' => 'Arabic (Algeria)', 'locale' => 'ar_dz', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-eg' => array('language' => 'Arabic (Egypt)', 'locale' => 'ar_eg', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-iq' => array('language' => 'Arabic (Iraq)', 'locale' => 'ar_iq', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-jo' => array('language' => 'Arabic (Jordan)', 'locale' => 'ar_jo', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-kw' => array('language' => 'Arabic (Kuwait)', 'locale' => 'ar_kw', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-lb' => array('language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-ly' => array('language' => 'Arabic (Libya)', 'locale' => 'ar_ly', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-ma' => array('language' => 'Arabic (Morocco)', 'locale' => 'ar_ma', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-om' => array('language' => 'Arabic (Oman)', 'locale' => 'ar_om', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-qa' => array('language' => 'Arabic (Qatar)', 'locale' => 'ar_qa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-sa' => array('language' => 'Arabic (Saudi Arabia)', 'locale' => 'ar_sa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-sy' => array('language' => 'Arabic (Syria)', 'locale' => 'ar_sy', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-tn' => array('language' => 'Arabic (Tunisia)', 'locale' => 'ar_tn', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'ar-ye' => array('language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('be')); $expected = array( - 'be' => array('language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8') + 'be' => array('language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('bg')); $expected = array( - 'bg' => array('language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8') + 'bg' => array('language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('bs')); $expected = array( - 'bs' => array('language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8') + 'bs' => array('language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('ca')); $expected = array( - 'ca' => array('language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8') + 'ca' => array('language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('cs')); $expected = array( - 'cs' => array('language' => 'Czech', 'locale' => 'cze', 'localeFallback' => 'cze', 'charset' => 'utf-8') + 'cs' => array('language' => 'Czech', 'locale' => 'cze', 'localeFallback' => 'cze', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('da')); $expected = array( - 'da' => array('language' => 'Danish', 'locale' => 'dan', 'localeFallback' => 'dan', 'charset' => 'utf-8') + 'da' => array('language' => 'Danish', 'locale' => 'dan', 'localeFallback' => 'dan', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('de', 'de-at', 'de-ch', 'de-de', 'de-li', 'de-lu')); $expected = array( - 'de' => array('language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'de-at' => array('language' => 'German (Austria)', 'locale' => 'de_at', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'de-ch' => array('language' => 'German (Swiss)', 'locale' => 'de_ch', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'de-de' => array('language' => 'German (Germany)', 'locale' => 'de_de', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'de-li' => array('language' => 'German (Liechtenstein)', 'locale' => 'de_li', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'de-lu' => array('language' => 'German (Luxembourg)', 'locale' => 'de_lu', 'localeFallback' => 'deu', 'charset' => 'utf-8') + 'de' => array('language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de-at' => array('language' => 'German (Austria)', 'locale' => 'de_at', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de-ch' => array('language' => 'German (Swiss)', 'locale' => 'de_ch', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de-de' => array('language' => 'German (Germany)', 'locale' => 'de_de', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de-li' => array('language' => 'German (Liechtenstein)', 'locale' => 'de_li', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'de-lu' => array('language' => 'German (Luxembourg)', 'locale' => 'de_lu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('e', 'el')); $expected = array( - 'e' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8'), - 'el' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8') + 'e' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'el' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('en', 'en-au', 'en-bz', 'en-ca', 'en-gb', 'en-ie', 'en-jm', 'en-nz', 'en-tt', 'en-us', 'en-za')); $expected = array( - 'en' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-au' => array('language' => 'English (Australian)', 'locale' => 'en_au', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-bz' => array('language' => 'English (Belize)', 'locale' => 'en_bz', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-ca' => array('language' => 'English (Canadian)', 'locale' => 'en_ca', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-gb' => array('language' => 'English (British)', 'locale' => 'en_gb', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-ie' => array('language' => 'English (Ireland)', 'locale' => 'en_ie', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-jm' => array('language' => 'English (Jamaica)', 'locale' => 'en_jm', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-nz' => array('language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-tt' => array('language' => 'English (Trinidad)', 'locale' => 'en_tt', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-us' => array('language' => 'English (United States)', 'locale' => 'en_us', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'en-za' => array('language' => 'English (South Africa)', 'locale' => 'en_za', 'localeFallback' => 'eng', 'charset' => 'utf-8') + 'en' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-au' => array('language' => 'English (Australian)', 'locale' => 'en_au', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-bz' => array('language' => 'English (Belize)', 'locale' => 'en_bz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-ca' => array('language' => 'English (Canadian)', 'locale' => 'en_ca', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-gb' => array('language' => 'English (British)', 'locale' => 'en_gb', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-ie' => array('language' => 'English (Ireland)', 'locale' => 'en_ie', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-jm' => array('language' => 'English (Jamaica)', 'locale' => 'en_jm', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-nz' => array('language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-tt' => array('language' => 'English (Trinidad)', 'locale' => 'en_tt', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-us' => array('language' => 'English (United States)', 'locale' => 'en_us', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'en-za' => array('language' => 'English (South Africa)', 'locale' => 'en_za', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('es', 'es-ar', 'es-bo', 'es-cl', 'es-co', 'es-cr', 'es-do', 'es-ec', 'es-es', 'es-gt', 'es-hn', 'es-mx', 'es-ni', 'es-pa', 'es-pe', 'es-pr', 'es-py', 'es-sv', 'es-uy', 'es-ve')); $expected = array( - 'es' => array('language' => 'Spanish (Spain - Traditional)', 'locale' => 'spa', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-ar' => array('language' => 'Spanish (Argentina)', 'locale' => 'es_ar', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-bo' => array('language' => 'Spanish (Bolivia)', 'locale' => 'es_bo', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-cl' => array('language' => 'Spanish (Chile)', 'locale' => 'es_cl', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-co' => array('language' => 'Spanish (Colombia)', 'locale' => 'es_co', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-cr' => array('language' => 'Spanish (Costa Rica)', 'locale' => 'es_cr', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-do' => array('language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-ec' => array('language' => 'Spanish (Ecuador)', 'locale' => 'es_ec', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-es' => array('language' => 'Spanish (Spain)', 'locale' => 'es_es', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-gt' => array('language' => 'Spanish (Guatemala)', 'locale' => 'es_gt', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-hn' => array('language' => 'Spanish (Honduras)', 'locale' => 'es_hn', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-mx' => array('language' => 'Spanish (Mexican)', 'locale' => 'es_mx', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-ni' => array('language' => 'Spanish (Nicaragua)', 'locale' => 'es_ni', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-pa' => array('language' => 'Spanish (Panama)', 'locale' => 'es_pa', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-pe' => array('language' => 'Spanish (Peru)', 'locale' => 'es_pe', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-pr' => array('language' => 'Spanish (Puerto Rico)', 'locale' => 'es_pr', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-py' => array('language' => 'Spanish (Paraguay)', 'locale' => 'es_py', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-sv' => array('language' => 'Spanish (El Salvador)', 'locale' => 'es_sv', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-uy' => array('language' => 'Spanish (Uruguay)', 'locale' => 'es_uy', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'es-ve' => array('language' => 'Spanish (Venezuela)', 'locale' => 'es_ve', 'localeFallback' => 'spa', 'charset' => 'utf-8') + 'es' => array('language' => 'Spanish (Spain - Traditional)', 'locale' => 'spa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-ar' => array('language' => 'Spanish (Argentina)', 'locale' => 'es_ar', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-bo' => array('language' => 'Spanish (Bolivia)', 'locale' => 'es_bo', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-cl' => array('language' => 'Spanish (Chile)', 'locale' => 'es_cl', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-co' => array('language' => 'Spanish (Colombia)', 'locale' => 'es_co', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-cr' => array('language' => 'Spanish (Costa Rica)', 'locale' => 'es_cr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-do' => array('language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-ec' => array('language' => 'Spanish (Ecuador)', 'locale' => 'es_ec', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-es' => array('language' => 'Spanish (Spain)', 'locale' => 'es_es', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-gt' => array('language' => 'Spanish (Guatemala)', 'locale' => 'es_gt', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-hn' => array('language' => 'Spanish (Honduras)', 'locale' => 'es_hn', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-mx' => array('language' => 'Spanish (Mexican)', 'locale' => 'es_mx', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-ni' => array('language' => 'Spanish (Nicaragua)', 'locale' => 'es_ni', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-pa' => array('language' => 'Spanish (Panama)', 'locale' => 'es_pa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-pe' => array('language' => 'Spanish (Peru)', 'locale' => 'es_pe', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-pr' => array('language' => 'Spanish (Puerto Rico)', 'locale' => 'es_pr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-py' => array('language' => 'Spanish (Paraguay)', 'locale' => 'es_py', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-sv' => array('language' => 'Spanish (El Salvador)', 'locale' => 'es_sv', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-uy' => array('language' => 'Spanish (Uruguay)', 'locale' => 'es_uy', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-ve' => array('language' => 'Spanish (Venezuela)', 'locale' => 'es_ve', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('et')); $expected = array( - 'et' => array('language' => 'Estonian', 'locale' => 'est', 'localeFallback' => 'est', 'charset' => 'utf-8') + 'et' => array('language' => 'Estonian', 'locale' => 'est', 'localeFallback' => 'est', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('eu')); $expected = array( - 'eu' => array('language' => 'Basque', 'locale' => 'baq', 'localeFallback' => 'baq', 'charset' => 'utf-8') + 'eu' => array('language' => 'Basque', 'locale' => 'baq', 'localeFallback' => 'baq', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('fa')); $expected = array( - 'fa' => array('language' => 'Farsi', 'locale' => 'per', 'localeFallback' => 'per', 'charset' => 'utf-8') + 'fa' => array('language' => 'Farsi', 'locale' => 'per', 'localeFallback' => 'per', 'charset' => 'utf-8', 'direction' => 'rtl') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('fi')); $expected = array( - 'fi' => array('language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8') + 'fi' => array('language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('fo')); $expected = array( - 'fo' => array('language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8') + 'fo' => array('language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('fr', 'fr-be', 'fr-ca', 'fr-ch', 'fr-fr', 'fr-lu')); $expected = array( - 'fr' => array('language' => 'French (Standard)', 'locale' => 'fre', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'fr-be' => array('language' => 'French (Belgium)', 'locale' => 'fr_be', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'fr-ca' => array('language' => 'French (Canadian)', 'locale' => 'fr_ca', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'fr-ch' => array('language' => 'French (Swiss)', 'locale' => 'fr_ch', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'fr-fr' => array('language' => 'French (France)', 'locale' => 'fr_fr', 'localeFallback' => 'fre', 'charset' => 'utf-8'), - 'fr-lu' => array('language' => 'French (Luxembourg)', 'locale' => 'fr_lu', 'localeFallback' => 'fre', 'charset' => 'utf-8') + 'fr' => array('language' => 'French (Standard)', 'locale' => 'fre', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr-be' => array('language' => 'French (Belgium)', 'locale' => 'fr_be', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr-ca' => array('language' => 'French (Canadian)', 'locale' => 'fr_ca', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr-ch' => array('language' => 'French (Swiss)', 'locale' => 'fr_ch', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr-fr' => array('language' => 'French (France)', 'locale' => 'fr_fr', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'fr-lu' => array('language' => 'French (Luxembourg)', 'locale' => 'fr_lu', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('ga')); $expected = array( - 'ga' => array('language' => 'Irish', 'locale' => 'gle', 'localeFallback' => 'gle', 'charset' => 'utf-8') + 'ga' => array('language' => 'Irish', 'locale' => 'gle', 'localeFallback' => 'gle', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('gd', 'gd-ie')); $expected = array( - 'gd' => array('language' => 'Gaelic (Scots)', 'locale' => 'gla', 'localeFallback' => 'gla', 'charset' => 'utf-8'), - 'gd-ie' => array('language' => 'Gaelic (Irish)', 'locale' => 'gd_ie', 'localeFallback' => 'gla', 'charset' => 'utf-8') + 'gd' => array('language' => 'Gaelic (Scots)', 'locale' => 'gla', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'gd-ie' => array('language' => 'Gaelic (Irish)', 'locale' => 'gd_ie', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('gl')); $expected = array( - 'gl' => array('language' => 'Galician', 'locale' => 'glg', 'localeFallback' => 'glg', 'charset' => 'utf-8') + 'gl' => array('language' => 'Galician', 'locale' => 'glg', 'localeFallback' => 'glg', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('he')); $expected = array( - 'he' => array('language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8') - ); - $this->assertEqual($result, $expected); - - $result = $l10n->catalog(array('he')); - $expected = array( - 'he' => array('language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8') + 'he' => array('language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8', 'direction' => 'rtl') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('hi')); $expected = array( - 'hi' => array('language' => 'Hindi', 'locale' => 'hin', 'localeFallback' => 'hin', 'charset' => 'utf-8') + 'hi' => array('language' => 'Hindi', 'locale' => 'hin', 'localeFallback' => 'hin', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('hr')); $expected = array( - 'hr' => array('language' => 'Croatian', 'locale' => 'hrv', 'localeFallback' => 'hrv', 'charset' => 'utf-8') + 'hr' => array('language' => 'Croatian', 'locale' => 'hrv', 'localeFallback' => 'hrv', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('hu')); $expected = array( - 'hu' => array('language' => 'Hungarian', 'locale' => 'hun', 'localeFallback' => 'hun', 'charset' => 'utf-8') + 'hu' => array('language' => 'Hungarian', 'locale' => 'hun', 'localeFallback' => 'hun', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('hy')); $expected = array( - 'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8') + 'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('id', 'in')); $expected = array( - 'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8'), - 'in' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8') + 'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'in' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('is')); $expected = array( - 'is' => array('language' => 'Icelandic', 'locale' => 'ice', 'localeFallback' => 'ice', 'charset' => 'utf-8') + 'is' => array('language' => 'Icelandic', 'locale' => 'ice', 'localeFallback' => 'ice', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('it', 'it-ch')); $expected = array( - 'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8'), - 'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8') + 'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('ja')); $expected = array( - 'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8') + 'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('ko', 'ko-kp', 'ko-kr')); $expected = array( - 'ko' => array('language' => 'Korean', 'locale' => 'kor', 'localeFallback' => 'kor', 'charset' => 'kr'), - 'ko-kp' => array('language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr'), - 'ko-kr' => array('language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr') + 'ko' => array('language' => 'Korean', 'locale' => 'kor', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), + 'ko-kp' => array('language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), + 'ko-kr' => array('language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('koi8-r', 'ru', 'ru-mo')); $expected = array( - 'koi8-r' => array('language' => 'Russian', 'locale' => 'koi8_r', 'localeFallback' => 'rus', 'charset' => 'koi8-r'), - 'ru' => array('language' => 'Russian', 'locale' => 'rus', 'localeFallback' => 'rus', 'charset' => 'utf-8'), - 'ru-mo' => array('language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8') + 'koi8-r' => array('language' => 'Russian', 'locale' => 'koi8_r', 'localeFallback' => 'rus', 'charset' => 'koi8-r', 'direction' => 'ltr'), + 'ru' => array('language' => 'Russian', 'locale' => 'rus', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ru-mo' => array('language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('lt')); $expected = array( - 'lt' => array('language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8') + 'lt' => array('language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('lv')); $expected = array( - 'lv' => array('language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8') + 'lv' => array('language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('mk', 'mk-mk')); $expected = array( - 'mk' => array('language' => 'FYRO Macedonian', 'locale' => 'mk', 'localeFallback' => 'mac', 'charset' => 'utf-8'), - 'mk-mk' => array('language' => 'Macedonian', 'locale' => 'mk_mk', 'localeFallback' => 'mac', 'charset' => 'utf-8') + 'mk' => array('language' => 'FYRO Macedonian', 'locale' => 'mk', 'localeFallback' => 'mac', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'mk-mk' => array('language' => 'Macedonian', 'locale' => 'mk_mk', 'localeFallback' => 'mac', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('ms')); $expected = array( - 'ms' => array('language' => 'Malaysian', 'locale' => 'may', 'localeFallback' => 'may', 'charset' => 'utf-8') + 'ms' => array('language' => 'Malaysian', 'locale' => 'may', 'localeFallback' => 'may', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('mt')); $expected = array( - 'mt' => array('language' => 'Maltese', 'locale' => 'mlt', 'localeFallback' => 'mlt', 'charset' => 'utf-8') + 'mt' => array('language' => 'Maltese', 'locale' => 'mlt', 'localeFallback' => 'mlt', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('n', 'nl', 'nl-be')); $expected = array( - 'n' => array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8'), - 'nl' => array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8'), - 'nl-be' => array('language' => 'Dutch (Belgium)', 'locale' => 'nl_be', 'localeFallback' => 'dut', 'charset' => 'utf-8') + 'n' => array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'nl' => array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'nl-be' => array('language' => 'Dutch (Belgium)', 'locale' => 'nl_be', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('nb')); $expected = array( - 'nb' => array('language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8') + 'nb' => array('language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('nn', 'no')); $expected = array( - 'nn' => array('language' => 'Norwegian Nynorsk', 'locale' => 'nno', 'localeFallback' => 'nor', 'charset' => 'utf-8'), - 'no' => array('language' => 'Norwegian', 'locale' => 'nor', 'localeFallback' => 'nor', 'charset' => 'utf-8') + 'nn' => array('language' => 'Norwegian Nynorsk', 'locale' => 'nno', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'no' => array('language' => 'Norwegian', 'locale' => 'nor', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('p', 'pl')); $expected = array( - 'p' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8'), - 'pl' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8') + 'p' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'pl' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('pt', 'pt-br')); $expected = array( - 'pt' => array('language' => 'Portuguese (Portugal)', 'locale' => 'por', 'localeFallback' => 'por', 'charset' => 'utf-8'), - 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8') + 'pt' => array('language' => 'Portuguese (Portugal)', 'locale' => 'por', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('rm')); $expected = array( - 'rm' => array('language' => 'Rhaeto-Romanic', 'locale' => 'roh', 'localeFallback' => 'roh', 'charset' => 'utf-8') + 'rm' => array('language' => 'Rhaeto-Romanic', 'locale' => 'roh', 'localeFallback' => 'roh', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('ro', 'ro-mo')); $expected = array( - 'ro' => array('language' => 'Romanian', 'locale' => 'rum', 'localeFallback' => 'rum', 'charset' => 'utf-8'), - 'ro-mo' => array('language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'rum', 'charset' => 'utf-8') + 'ro' => array('language' => 'Romanian', 'locale' => 'rum', 'localeFallback' => 'rum', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ro-mo' => array('language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'rum', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('sb')); $expected = array( - 'sb' => array('language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8') + 'sb' => array('language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('sk')); $expected = array( - 'sk' => array('language' => 'Slovak', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8') + 'sk' => array('language' => 'Slovak', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('sl')); $expected = array( - 'sl' => array('language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8') + 'sl' => array('language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('sq')); $expected = array( - 'sq' => array('language' => 'Albanian', 'locale' => 'alb', 'localeFallback' => 'alb', 'charset' => 'utf-8') + 'sq' => array('language' => 'Albanian', 'locale' => 'alb', 'localeFallback' => 'alb', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('sr')); $expected = array( - 'sr' => array('language' => 'Serbian', 'locale' => 'scc', 'localeFallback' => 'scc', 'charset' => 'utf-8') + 'sr' => array('language' => 'Serbian', 'locale' => 'scc', 'localeFallback' => 'scc', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('sv', 'sv-fi')); $expected = array( - 'sv' => array('language' => 'Swedish', 'locale' => 'swe', 'localeFallback' => 'swe', 'charset' => 'utf-8'), - 'sv-fi' => array('language' => 'Swedish (Findland)', 'locale' => 'sv_fi', 'localeFallback' => 'swe', 'charset' => 'utf-8') + 'sv' => array('language' => 'Swedish', 'locale' => 'swe', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sv-fi' => array('language' => 'Swedish (Findland)', 'locale' => 'sv_fi', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('sx')); $expected = array( - 'sx' => array('language' => 'Sutu', 'locale' => 'sx', 'localeFallback' => 'sx', 'charset' => 'utf-8') + 'sx' => array('language' => 'Sutu', 'locale' => 'sx', 'localeFallback' => 'sx', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('sz')); $expected = array( - 'sz' => array('language' => 'Sami (Lappish)', 'locale' => 'smi', 'localeFallback' => 'smi', 'charset' => 'utf-8') + 'sz' => array('language' => 'Sami (Lappish)', 'locale' => 'smi', 'localeFallback' => 'smi', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('th')); $expected = array( - 'th' => array('language' => 'Thai', 'locale' => 'tha', 'localeFallback' => 'tha', 'charset' => 'utf-8') + 'th' => array('language' => 'Thai', 'locale' => 'tha', 'localeFallback' => 'tha', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('tn')); $expected = array( - 'tn' => array('language' => 'Tswana', 'locale' => 'tsn', 'localeFallback' => 'tsn', 'charset' => 'utf-8') + 'tn' => array('language' => 'Tswana', 'locale' => 'tsn', 'localeFallback' => 'tsn', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('tr')); $expected = array( - 'tr' => array('language' => 'Turkish', 'locale' => 'tur', 'localeFallback' => 'tur', 'charset' => 'utf-8') + 'tr' => array('language' => 'Turkish', 'locale' => 'tur', 'localeFallback' => 'tur', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('ts')); $expected = array( - 'ts' => array('language' => 'Tsonga', 'locale' => 'tso', 'localeFallback' => 'tso', 'charset' => 'utf-8') + 'ts' => array('language' => 'Tsonga', 'locale' => 'tso', 'localeFallback' => 'tso', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('uk')); $expected = array( - 'uk' => array('language' => 'Ukrainian', 'locale' => 'ukr', 'localeFallback' => 'ukr', 'charset' => 'utf-8') + 'uk' => array('language' => 'Ukrainian', 'locale' => 'ukr', 'localeFallback' => 'ukr', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('ur')); $expected = array( - 'ur' => array('language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8') + 'ur' => array('language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8', 'direction' => 'rtl') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('ve')); $expected = array( - 've' => array('language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8') + 've' => array('language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('vi')); $expected = array( - 'vi' => array('language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8') + 'vi' => array('language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('xh')); $expected = array( - 'xh' => array('language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8') + 'xh' => array('language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('yi')); $expected = array( - 'yi' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8') + 'yi' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('zh', 'zh-cn', 'zh-hk', 'zh-sg', 'zh-tw')); $expected = array( - 'zh' => array('language' => 'Chinese', 'locale' => 'chi', 'localeFallback' => 'chi', 'charset' => 'utf-8'), - 'zh-cn' => array('language' => 'Chinese (PRC)', 'locale' => 'zh_cn', 'localeFallback' => 'chi', 'charset' => 'GB2312'), - 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'chi', 'charset' => 'utf-8'), - 'zh-sg' => array('language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'chi', 'charset' => 'utf-8'), - 'zh-tw' => array('language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'chi', 'charset' => 'utf-8') + 'zh' => array('language' => 'Chinese', 'locale' => 'chi', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'zh-cn' => array('language' => 'Chinese (PRC)', 'locale' => 'zh_cn', 'localeFallback' => 'chi', 'charset' => 'GB2312', 'direction' => 'ltr'), + 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'zh-sg' => array('language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'zh-tw' => array('language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('zu')); $expected = array( - 'zu' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8') + 'zu' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('en-nz', 'es-do', 'sz', 'ar-lb', 'zh-hk', 'pt-br')); $expected = array( - 'en-nz' => array('language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'es-do' => array('language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8'), - 'sz' => array('language' => 'Sami (Lappish)', 'locale' => 'smi', 'localeFallback' => 'smi', 'charset' => 'utf-8'), - 'ar-lb' => array('language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8'), - 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'chi', 'charset' => 'utf-8'), - 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8') + 'en-nz' => array('language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'es-do' => array('language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'sz' => array('language' => 'Sami (Lappish)', 'locale' => 'smi', 'localeFallback' => 'smi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'ar-lb' => array('language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), + 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); $result = $l10n->catalog(array('eng', 'deu', 'zho', 'rum', 'zul', 'yid')); $expected = array( - 'eng' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8'), - 'deu' => array('language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8'), - 'zho' => array('language' => 'Chinese', 'locale' => 'chi', 'localeFallback' => 'chi', 'charset' => 'utf-8'), - 'rum' => array('language' => 'Romanian', 'locale' => 'rum', 'localeFallback' => 'rum', 'charset' => 'utf-8'), - 'zul' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8'), - 'yid' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8') + 'eng' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'deu' => array('language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'zho' => array('language' => 'Chinese', 'locale' => 'chi', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'rum' => array('language' => 'Romanian', 'locale' => 'rum', 'localeFallback' => 'rum', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'zul' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'yid' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr') ); $this->assertEqual($result, $expected); } From ec88bd9c8c4fa385b94d07b8100413f81c98e627 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 29 Dec 2009 22:23:03 -0500 Subject: [PATCH 019/137] Forcing ModelTask to always reload schema for models when baking. Also setting the dbo's cacheSources = false so table listings are always fresh as well. --- cake/console/libs/tasks/model.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cake/console/libs/tasks/model.php b/cake/console/libs/tasks/model.php index 9be466056..08ddb3b97 100644 --- a/cake/console/libs/tasks/model.php +++ b/cake/console/libs/tasks/model.php @@ -186,7 +186,7 @@ class ModelTask extends Shell { if (in_array($useTable, $this->__tables)) { $tempModel = new Model(array('name' => $currentModelName, 'table' => $useTable, 'ds' => $this->connection)); - $fields = $tempModel->schema(); + $fields = $tempModel->schema(true); if (!array_key_exists('id', $fields)) { $primaryKey = $this->findPrimaryKey($fields); } @@ -447,7 +447,7 @@ class ModelTask extends Shell { $this->out(__('One moment while the associations are detected.', true)); } - $fields = $model->schema(); + $fields = $model->schema(true); if (empty($fields)) { return false; } @@ -487,7 +487,7 @@ class ModelTask extends Shell { * @return array $associations with belongsTo added in. */ function findBelongsTo(&$model, $associations) { - $fields = $model->schema(); + $fields = $model->schema(true); foreach ($fields as $fieldName => $field) { $offset = strpos($fieldName, '_id'); if ($fieldName != $model->primaryKey && $fieldName != 'parent_id' && $offset !== false) { @@ -562,7 +562,7 @@ class ModelTask extends Shell { $foreignKey = $this->_modelKey($model->name); foreach ($this->__tables as $otherTable) { $tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable); - $modelFieldsTemp = $tempOtherModel->schema(); + $modelFieldsTemp = $tempOtherModel->schema(true); $offset = strpos($otherTable, $model->table . '_'); $otherOffset = strpos($otherTable, '_' . $model->table); @@ -695,7 +695,7 @@ class ModelTask extends Shell { $possible = array(); foreach ($this->__tables as $otherTable) { $tempOtherModel = & new Model(array('table' => $otherTable, 'ds' => $this->connection)); - $modelFieldsTemp = $tempOtherModel->schema(); + $modelFieldsTemp = $tempOtherModel->schema(true); foreach ($modelFieldsTemp as $fieldName => $field) { if ($field['type'] == 'integer' || $field['type'] == 'string') { $possible[$otherTable][] = $fieldName; @@ -821,6 +821,7 @@ class ModelTask extends Shell { $tables = array(); $db =& ConnectionManager::getDataSource($useDbConfig); + $db->cacheSources = false; $usePrefix = empty($db->config['prefix']) ? '' : $db->config['prefix']; if ($usePrefix) { foreach ($db->listSources() as $table) { From 31fff5e390a6566e222ca2dad46d4a5e23b2734a Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 29 Dec 2009 22:23:52 -0500 Subject: [PATCH 020/137] Making ViewTask always refresh model schema so baked views reflect current schema. --- cake/console/libs/tasks/view.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php index 62cb1c82c..fc0a69e42 100644 --- a/cake/console/libs/tasks/view.php +++ b/cake/console/libs/tasks/view.php @@ -283,7 +283,7 @@ class ViewTask extends Shell { $displayField = $modelObj->displayField; $singularVar = Inflector::variable($modelClass); $singularHumanName = $this->_singularHumanName($modelClass); - $schema = $modelObj->schema(); + $schema = $modelObj->schema(true); $fields = array_keys($schema); $associations = $this->__associations($modelObj); } else { @@ -469,7 +469,7 @@ class ViewTask extends Shell { $associations[$type][$assocKey]['displayField'] = $model->{$assocKey}->displayField; $associations[$type][$assocKey]['foreignKey'] = $assocData['foreignKey']; $associations[$type][$assocKey]['controller'] = Inflector::pluralize(Inflector::underscore($assocData['className'])); - $associations[$type][$assocKey]['fields'] = array_keys($model->{$assocKey}->schema()); + $associations[$type][$assocKey]['fields'] = array_keys($model->{$assocKey}->schema(true)); } } return $associations; From fdd8cf013806dab3f2ba053ea4832a0efaf8fc83 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 29 Dec 2009 22:39:49 -0500 Subject: [PATCH 021/137] Making FixtureTask always refresh schema for models. --- cake/console/libs/tasks/fixture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/console/libs/tasks/fixture.php b/cake/console/libs/tasks/fixture.php index 82dec5869..eb33c138e 100644 --- a/cake/console/libs/tasks/fixture.php +++ b/cake/console/libs/tasks/fixture.php @@ -378,7 +378,7 @@ class FixtureTask extends Shell { 'recursive' => -1 )); $db =& ConnectionManager::getDataSource($modelObject->useDbConfig); - $schema = $modelObject->schema(); + $schema = $modelObject->schema(true); $out = array(); foreach ($records as $record) { $row = array(); From a9a8c0b0e4ca3cea5ad0970df1b537f879703c58 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 29 Dec 2009 22:50:43 -0500 Subject: [PATCH 022/137] Adding access tags and additional param/return docs. --- cake/console/libs/tasks/fixture.php | 13 +++++++-- cake/console/libs/tasks/test.php | 44 +++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/cake/console/libs/tasks/fixture.php b/cake/console/libs/tasks/fixture.php index eb33c138e..195392d1c 100644 --- a/cake/console/libs/tasks/fixture.php +++ b/cake/console/libs/tasks/fixture.php @@ -54,6 +54,7 @@ class FixtureTask extends Shell { * The db connection being used for baking * * @var string + * @access public */ var $connection = null; @@ -61,6 +62,7 @@ class FixtureTask extends Shell { * Schema instance * * @var object + * @access protected */ var $_Schema = null; @@ -140,6 +142,7 @@ class FixtureTask extends Shell { * * @param string $modelName Name of model you are dealing with. * @return array Array of import options. + * @access public */ function importOptions($modelName) { $options = array(); @@ -167,8 +170,8 @@ class FixtureTask extends Shell { * @param string $model Name of model to bake. * @param string $useTable Name of table to use. * @param array $importOptions Options for var $import - * @return string Baked fixture - * @access private + * @return string Baked fixture content + * @access public */ function bake($model, $useTable = false, $importOptions = array()) { if (!class_exists('CakeSchema')) { @@ -228,8 +231,8 @@ class FixtureTask extends Shell { * * @param string $model name of the model being generated * @param string $fixture Contents of the fixture file. + * @return string Content saved into fixture file. * @access public - * @return void */ function generateFixtureFile($model, $otherVars) { $defaults = array('table' => null, 'schema' => null, 'records' => null, 'import' => null, 'fields' => null); @@ -255,6 +258,7 @@ class FixtureTask extends Shell { * * @param array $table Table schema array * @return string fields definitions + * @access protected */ function _generateSchema($tableInfo) { $schema = $this->_Schema->generateTable('f', $tableInfo); @@ -266,6 +270,7 @@ class FixtureTask extends Shell { * * @param array $table Table schema array * @return array Array of records to use in the fixture. + * @access protected */ function _generateRecords($tableInfo, $recordCount = 1) { $records = array(); @@ -337,6 +342,7 @@ class FixtureTask extends Shell { * * @param array $records Array of records to be converted to string * @return string A string value of the $records array. + * @access protected */ function _makeRecordString($records) { $out = "array(\n"; @@ -360,6 +366,7 @@ class FixtureTask extends Shell { * @param string $modelName name of the model to take records from. * @param string $useTable Name of table to use. * @return array Array of records. + * @access protected */ function _getRecordsFromTable($modelName, $useTable = null) { if ($this->interactive) { diff --git a/cake/console/libs/tasks/test.php b/cake/console/libs/tasks/test.php index 06cf9c5bb..5c1cb7e1c 100644 --- a/cake/console/libs/tasks/test.php +++ b/cake/console/libs/tasks/test.php @@ -46,6 +46,7 @@ class TestTask extends Shell { * Tasks used. * * @var array + * @access public */ var $tasks = array('Template'); @@ -53,6 +54,7 @@ class TestTask extends Shell { * class types that methods can be generated for * * @var array + * @access public */ var $classTypes = array('Model', 'Controller', 'Component', 'Behavior', 'Helper'); @@ -60,6 +62,7 @@ class TestTask extends Shell { * Internal list of fixtures that have been added so far. * * @var string + * @access protected */ var $_fixtures = array(); @@ -164,6 +167,7 @@ class TestTask extends Shell { * Interact with the user and get their chosen type. Can exit the script. * * @return string Users chosen type. + * @access public */ function getObjectType() { $this->hr(); @@ -188,6 +192,7 @@ class TestTask extends Shell { * * @param string $objectType Type of object to list classes for i.e. Model, Controller. * @return string Class name the user chose. + * @access public */ function getClassName($objectType) { $options = App::objects(strtolower($objectType)); @@ -207,8 +212,11 @@ class TestTask extends Shell { /** * Checks whether the chosen type can find its own fixtures. * Currently only model, and controller are supported - * + * + * @param string $type The Type of object you are generating tests for eg. controller + * @param string $className the Classname of the class the test is being generated for. * @return boolean + * @access public */ function typeCanDetectFixtures($type) { $type = strtolower($type); @@ -218,7 +226,10 @@ class TestTask extends Shell { /** * Check if a class with the given type is loaded or can be loaded. * + * @param string $type The Type of object you are generating tests for eg. controller + * @param string $className the Classname of the class the test is being generated for. * @return boolean + * @access public */ function isLoadableClass($type, $class) { return App::import($type, $class); @@ -228,7 +239,10 @@ class TestTask extends Shell { * Construct an instance of the class to be tested. * So that fixtures can be detected * - * @return object + * @param string $type The Type of object you are generating tests for eg. controller + * @param string $class the Classname of the class the test is being generated for. + * @return object And instance of the class that is going to be tested. + * @access public */ function &buildTestSubject($type, $class) { ClassRegistry::flush(); @@ -245,7 +259,10 @@ class TestTask extends Shell { /** * Gets the real class name from the cake short form. * + * @param string $type The Type of object you are generating tests for eg. controller + * @param string $class the Classname of the class the test is being generated for. * @return string Real classname + * @access public */ function getRealClassName($type, $class) { if (strtolower($type) == 'model') { @@ -260,6 +277,7 @@ class TestTask extends Shell { * * @param string $className Name of class to look at. * @return array Array of method names. + * @access public */ function getTestableMethods($className) { $classMethods = get_class_methods($className); @@ -278,8 +296,9 @@ class TestTask extends Shell { * Generate the list of fixtures that will be required to run this test based on * loaded models. * - * @param object The object you want to generate fixtures for. + * @param object $subject The object you want to generate fixtures for. * @return array Array of fixtures to be included in the test. + * @access public */ function generateFixtureList(&$subject) { $this->_fixtures = array(); @@ -295,6 +314,7 @@ class TestTask extends Shell { * Process a model recursively and pull out all the * model names converting them to fixture names. * + * @param Model $subject A Model class to scan for associations and pull fixtures off of. * @return void * @access protected */ @@ -319,6 +339,7 @@ class TestTask extends Shell { * Process all the models attached to a controller * and generate a fixture list. * + * @param Controller $subject A controller to pull model names off of. * @return void * @access protected */ @@ -337,6 +358,7 @@ class TestTask extends Shell { * Add classname to the fixture list. * Sets the app. or plugin.plugin_name. prefix. * + * @param string $name Name of the Model class that a fixture might be required for. * @return void * @access protected */ @@ -354,7 +376,8 @@ class TestTask extends Shell { /** * Interact with the user to get additional fixtures they want to use. * - * @return void + * @return array Array of fixtures the user wants to add. + * @access public */ function getUserFixtures() { $proceed = $this->in(__('Bake could not detect fixtures, would you like to add some?', true), array('y','n'), 'n'); @@ -372,7 +395,9 @@ class TestTask extends Shell { * Is a mock class required for this type of test? * Controllers require a mock class. * + * @param string $type The type of object tests are being generated for eg. controller. * @return boolean + * @access public */ function hasMockClass($type) { $type = strtolower($type); @@ -382,7 +407,10 @@ class TestTask extends Shell { /** * Generate a constructor code snippet for the type and classname * + * @param string $type The Type of object you are generating tests for eg. controller + * @param string $className the Classname of the class the test is being generated for. * @return string Constructor snippet for the thing you are building. + * @access public */ function generateConstructor($type, $fullClassName) { $type = strtolower($type); @@ -397,10 +425,13 @@ class TestTask extends Shell { } /** - * make the filename for the test case. resolve the suffixes for controllers + * Make the filename for the test case. resolve the suffixes for controllers * and get the plugin path if needed. * - * @return string filename the test should be created on + * @param string $type The Type of object you are generating tests for eg. controller + * @param string $className the Classname of the class the test is being generated for. + * @return string filename the test should be created on. + * @access public */ function testCaseFileName($type, $className) { $path = $this->path; @@ -418,6 +449,7 @@ class TestTask extends Shell { * Show help file. * * @return void + * @access public */ function help() { $this->hr(); From 5f987a4996ac83b0db58d308493af36f8e145fe9 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 31 Dec 2009 17:36:58 +0530 Subject: [PATCH 023/137] Controller data is now set to an array instead of Xml object if request content type is 'application/xml' --- cake/libs/controller/components/request_handler.php | 6 +++--- .../libs/controller/components/request_handler.test.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index 70ef9b20c..fbbf01afa 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -219,10 +219,10 @@ class RequestHandlerComponent extends Object { } $xml = new Xml(trim(file_get_contents('php://input'))); - if (is_object($xml->child('data')) && count($xml->children) == 1) { - $controller->data = $xml->child('data'); + if (count($xml->children) == 1 && is_object($dataNode = $xml->child('data'))) { + $controller->data = $dataNode->toArray(); } else { - $controller->data = $xml; + $controller->data = $xml->toArray(); } } } diff --git a/cake/tests/cases/libs/controller/components/request_handler.test.php b/cake/tests/cases/libs/controller/components/request_handler.test.php index 9f979c323..a05bd2177 100644 --- a/cake/tests/cases/libs/controller/components/request_handler.test.php +++ b/cake/tests/cases/libs/controller/components/request_handler.test.php @@ -241,8 +241,8 @@ class RequestHandlerComponentTest extends CakeTestCase { $_SERVER['REQUEST_METHOD'] = 'PUT'; $_SERVER['CONTENT_TYPE'] = 'application/xml'; $this->RequestHandler->startup($this->Controller); - $this->assertTrue(is_object($this->Controller->data)); - $this->assertEqual(strtolower(get_class($this->Controller->data)), 'xml'); + $this->assertTrue(is_array($this->Controller->data)); + $this->assertFalse(is_object($this->Controller->data)); } /** @@ -254,8 +254,8 @@ class RequestHandlerComponentTest extends CakeTestCase { $_SERVER['REQUEST_METHOD'] = 'PUT'; $_SERVER['CONTENT_TYPE'] = 'application/xml; charset=UTF-8'; $this->RequestHandler->startup($this->Controller); - $this->assertTrue(is_object($this->Controller->data)); - $this->assertEqual(strtolower(get_class($this->Controller->data)), 'xml'); + $this->assertTrue(is_array($this->Controller->data)); + $this->assertFalse(is_object($this->Controller->data)); } /** From eab706e77216e0ea600e0cd2f1a4925c435cab28 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 1 Jan 2010 23:58:07 -0500 Subject: [PATCH 024/137] Correcting and improving doc block for Model::__construct. --- cake/libs/model/model.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 6cdd3ad8c..0a565ff21 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -387,9 +387,34 @@ class Model extends Overloadable { /** * Constructor. Binds the model's database table to the object. * - * @param integer $id Set this ID for this model on startup + * If `$id` is an array it can be used to pass several options into the model. + * + * - id - The id to start the model on. + * - table - The table to use for this model. + * - ds - The connection name this model is connected to. + * - name - The name of the model eg. Post. + * - alias - The alias of the model, this is used for registering the instance in the `ClassRegistry`. + * eg. `ParentThread` + * + * ### Overriding Model's __construct method. + * + * When overriding Model::__construct() be careful to include and pass in all 3 of the + * arguments to `parent::__construct($id, $table, $ds);` + * + * ### Dynamically creating models + * + * You can dynamically create model instances using the the $id array syntax. + * + * {{{ + * $Post = new Model(array('table' => 'posts', 'name' => 'Post', 'ds' => 'connection2')); + * }}} + * + * Would create a model attached to the posts table on connection2. Dynamic model creation is useful + * when you want a model object that contains no associations or attached behaviors. + * + * @param mixed $id Set this ID for this model on startup, can also be an array of options, see above. * @param string $table Name of database table to use. - * @param object $ds DataSource connection object. + * @param string $ds DataSource connection name. */ function __construct($id = false, $table = null, $ds = null) { parent::__construct(); From 7dcf66dd956afe526f98b1c68f1ab1f6e663fcab Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 2 Jan 2010 00:07:31 -0500 Subject: [PATCH 025/137] Removing dynamic calling of setTablePrefix(). tableprefix should be with the tablePrefix property, and any other custom construction behavior should be done in an overridden Model::__construct. --- cake/libs/model/model.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 0a565ff21..37b81245e 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -487,9 +487,6 @@ class Model extends Overloadable { if ($this->useTable === null) { $this->useTable = Inflector::tableize($this->name); } - if (method_exists($this, 'setTablePrefix')) { - $this->setTablePrefix(); - } $this->setSource($this->useTable); if ($this->displayField == null) { From 18f58c41aecb47fee5e74cda3448b072a9f57429 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 2 Jan 2010 00:27:44 -0500 Subject: [PATCH 026/137] Fixing datasource title display. Removing borders from debug output. --- app/webroot/css/cake.generic.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index c4b754233..b12e450bb 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -180,6 +180,9 @@ table td.actions a { text-align: left; font-family: Monaco, Consolas, "Courier New", monospaced; } +.cake-sql-log caption { + color:#fff; +} /* Paging */ div.paging { @@ -436,7 +439,6 @@ pre.cake-debug { } div.cake-stack-trace { background: #fff; - border: 4px dotted #ffcc00; color: #333; margin: 0px; padding: 6px; From 0311ddb609d467c5f3ead74ec52cc5bd08b0c5c3 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 00:26:19 -0500 Subject: [PATCH 027/137] Fixing alignment of text in tables. --- app/webroot/css/cake.generic.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index b12e450bb..ff38ae761 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -156,7 +156,7 @@ th a.desc:after { table tr td { background: #fff; padding: 6px; - text-align: center; + text-align: left; vertical-align: top; border-bottom:1px solid #ddd; } From 2ace6bb0b1e804e60d862c15b01828e5d3c96132 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 23:51:31 -0500 Subject: [PATCH 028/137] Updating Controllers used to test full page caching to reflect changes in CacheHelper's functionality. --- cake/tests/cases/dispatcher.test.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 0d9e86235..2b99cd827 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -449,8 +449,9 @@ class TestCachedPagesController extends AppController { * @access public */ var $cacheAction = array( - 'index'=> '+2 sec', 'test_nocache_tags'=>'+2 sec', - 'view/' => '+2 sec' + 'index' => '+2 sec', + 'test_nocache_tags' => '+2 sec', + 'view' => '+2 sec' ); /** @@ -2097,9 +2098,8 @@ class DispatcherTest extends CakeTestCase { $filename = $this->__cachePath($dispatcher->here); $this->assertTrue(file_exists($filename)); unlink($filename); - - $url = 'TestCachedPages/test_nocache_tags'; } + /** * test that cached() registers a view and un-registers it. Tests * that helpers using ClassRegistry::getObject('view'); don't fail @@ -2139,7 +2139,6 @@ class DispatcherTest extends CakeTestCase { $this->assertEqual($result, $expected); $filename = $this->__cachePath($dispatcher->here); - unlink($filename); ClassRegistry::flush(); } From 9d5015882fca967cf8f135ed2dd76b6725212c28 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 5 Jan 2010 03:04:46 +0530 Subject: [PATCH 029/137] Updating deep email validation to check and use 'getmxrr' or 'checkdnsrr' if either function exists --- cake/libs/validation.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cake/libs/validation.php b/cake/libs/validation.php index 88a641d1b..7aecc7138 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -501,8 +501,13 @@ class Validation extends Object { } if ($return === true && preg_match('/@(' . $_this->__pattern['hostname'] . ')$/i', $_this->check, $regs)) { - $host = gethostbynamel($regs[1]); - return is_array($host); + if (function_exists('getmxrr')) { + return getmxrr($regs[1], $mxhosts); + } + if (function_exists('checkdnsrr')) { + return checkdnsrr($regs[1], 'MX'); + } + return is_array(gethostbynamel($regs[1])); } return false; } From 2aee4b6e43b02ac7c3be2030b54e920a5421d033 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 4 Jan 2010 23:25:23 -0500 Subject: [PATCH 030/137] Adding sql dump back into test suite. Fixes #157 --- cake/tests/lib/footer.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cake/tests/lib/footer.php b/cake/tests/lib/footer.php index 15cafdbfe..fb5b8ae79 100644 --- a/cake/tests/lib/footer.php +++ b/cake/tests/lib/footer.php @@ -24,6 +24,12 @@ CakePHP(tm) :: Rapid Development Framework

+ element('sql_dump'); + ?> \ No newline at end of file From 3d608d6fd74801a2851c71dcf5b46655c17651d8 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 00:33:17 -0500 Subject: [PATCH 031/137] Adding doc blocks to CakeHtmlReporter --- cake/tests/lib/cake_reporter.php | 38 ++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/cake_reporter.php b/cake/tests/lib/cake_reporter.php index 7d396ad44..9f0ada202 100644 --- a/cake/tests/lib/cake_reporter.php +++ b/cake/tests/lib/cake_reporter.php @@ -23,14 +23,46 @@ * in an HTML format / context. * * @package cake - * @subpackage cake.cake.tests.lib + * @subpackage cake.tests.lib */ class CakeHtmlReporter extends SimpleReporter { + +/** + * Character set for the output of test reporting. + * + * @var string + */ var $_character_set; +/** + * Toggle to show passes in output. + * + * @var boolean + * @access protected + */ var $_show_passes = false; +/** + * Time the test runs started. + * + * @var integer + * @access protected + */ var $_timeStart = 0; + +/** + * Time the test runs ended + * + * @var integer + * @access protected + */ var $_timeEnd = 0; + +/** + * Duration of all test methods. + * + * @var integer + * @access protected + */ var $_timeDuration = 0; /** @@ -52,7 +84,8 @@ class CakeHtmlReporter extends SimpleReporter { * Signals / Paints the beginning of a TestSuite executing. * Starts the timer for the TestSuite execution time. * - * @param + * @param string $test_name Name of the test that is being run. + * @param integer $size * @return void */ function paintGroupStart($test_name, $size) { @@ -66,6 +99,7 @@ class CakeHtmlReporter extends SimpleReporter { * Signals/Paints the end of a TestSuite. All test cases have run * and timers are stopped. * + * @param string $test_name Name of the test that is being run. * @return void */ function paintGroupEnd($test_name) { From 4d74dc6bda2ad5e9703d41859c0a263da88ac19b Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 22:03:49 -0500 Subject: [PATCH 032/137] Adding CakeTestMenu to clear up some global methods. --- cake/tests/lib/cake_test_menu.php | 197 ++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 cake/tests/lib/cake_test_menu.php diff --git a/cake/tests/lib/cake_test_menu.php b/cake/tests/lib/cake_test_menu.php new file mode 100644 index 000000000..6eb9bf2bb --- /dev/null +++ b/cake/tests/lib/cake_test_menu.php @@ -0,0 +1,197 @@ + + * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @package cake + * @subpackage cake.cake.tests.lib + * @since CakePHP(tm) v 1.3 + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ +class CakeTestMenu { +/** + * Provides the "Run More" links in the testsuite interface + * + * @return void + * @access public + */ + function runMore() { + switch (CAKE_TEST_OUTPUT) { + case CAKE_TEST_OUTPUT_HTML: + if (isset($_GET['group'])) { + if (isset($_GET['app'])) { + $show = '?show=groups&app=true'; + } else if (isset($_GET['plugin'])) { + $show = '?show=groups&plugin=' . $_GET['plugin']; + } else { + $show = '?show=groups'; + } + $query = '?group='.$_GET['group']; + if (isset($_GET['app'])) { + $query .= '&app=true'; + } elseif (isset($_GET['plugin'])) { + $query .= '&plugin=' . $_GET['plugin']; + } + } + if (isset($_GET['case'])) { + if (isset($_GET['app'])) { + $show = '?show=cases&app=true'; + } else if (isset($_GET['plugin'])) { + $show = '?show=cases&plugin=' . $_GET['plugin']; + } else { + $show = '?show=cases'; + } + $query = '?case='.$_GET['case']; + if (isset($_GET['app'])) { + $query .= '&app=true'; + } elseif (isset($_GET['plugin'])) { + $query .= '&plugin=' . $_GET['plugin']; + } + } + ob_start(); + echo "

Run more tests | Show Passes | \n"; + + break; + } + } + +/** + * Provides the links to analyzing code coverage + * + * @return void + * @access public + */ + function analyzeCodeCoverage() { + switch (CAKE_TEST_OUTPUT) { + case CAKE_TEST_OUTPUT_HTML: + if (isset($_GET['case'])) { + $query = '?case='.$_GET['case']; + if (isset($_GET['app'])) { + $query .= '&app=true'; + } elseif (isset($_GET['plugin'])) { + $query .= '&plugin=' . $_GET['plugin']; + } + } else { + $query = '?group='.$_GET['group']; + if (isset($_GET['app'])) { + $query .= '&app=true'; + } elseif (isset($_GET['plugin'])) { + $query .= '&plugin=' . $_GET['plugin']; + } + } + $query .= '&code_coverage=true'; + ob_start(); + echo " Analyze Code Coverage

\n"; + + break; + } + } + +/** + * Prints a list of test cases + * + * @return void + * @access public + */ + function testCaseList() { + switch (CAKE_TEST_OUTPUT) { + case CAKE_TEST_OUTPUT_HTML: + ob_start(); + echo HtmlTestManager::getTestCaseList(); + break; + case CAKE_TEST_OUTPUT_TEXT: + default: + echo TextTestManager::getTestCaseList(); + break; + } + } + +/** + * Prints a list of group tests + * + * @return void + * @access public + */ + function groupTestList() { + switch (CAKE_TEST_OUTPUT) { + case CAKE_TEST_OUTPUT_HTML: + echo HtmlTestManager::getGroupTestList(); + break; + case CAKE_TEST_OUTPUT_TEXT: + default: + echo TextTestManager::getGroupTestList(); + break; + } + } + +/** + * Includes the Testsuite Header + * + * @return void + * @access public + */ + function testHeader() { + switch (CAKE_TEST_OUTPUT) { + case CAKE_TEST_OUTPUT_HTML: + ob_start(); + if (!class_exists('dispatcher')) { + require CAKE . 'dispatcher.php'; + } + $dispatch =& new Dispatcher(); + $dispatch->baseUrl(); + define('BASE', $dispatch->webroot); + $baseUrl = BASE; + $characterSet = 'charset=utf-8'; + include CAKE_TESTS_LIB . 'header.php'; + + break; + case CAKE_TEST_OUTPUT_TEXT: + default: + header('content-type: text/plain'); + break; + } + } + +/** + * Provides the left hand navigation for the testsuite + * + * @return void + * @access public + */ + function testSuiteHeader() { + switch (CAKE_TEST_OUTPUT) { + case CAKE_TEST_OUTPUT_HTML: + ob_start(); + $groups = $_SERVER['PHP_SELF'].'?show=groups'; + $cases = $_SERVER['PHP_SELF'].'?show=cases'; + $plugins = App::objects('plugin'); + include CAKE_TESTS_LIB . 'content.php'; + break; + } + } + +/** + * Provides the testsuite footer text + * + * @return void + * @access public + */ + function footer() { + switch ( CAKE_TEST_OUTPUT) { + case CAKE_TEST_OUTPUT_HTML: + ob_start(); + $baseUrl = BASE; + include CAKE_TESTS_LIB . 'footer.php'; + break; + } + } +} \ No newline at end of file From 397bdaf3e1e2f79f3d578606cb5b26cd090dd062 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 22:05:45 -0500 Subject: [PATCH 033/137] Removing global functions moved to CakeTestMenu --- cake/tests/lib/test_manager.php | 175 -------------------------------- 1 file changed, 175 deletions(-) diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 1745469ed..01aa4cc8e 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -637,181 +637,6 @@ if (function_exists('caketestsgetreporter')) { return $Reporter; } -/** - * Provides the "Run More" links in the testsuite interface - * - * @return void - * @access public - */ - function CakePHPTestRunMore() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - if (isset($_GET['group'])) { - if (isset($_GET['app'])) { - $show = '?show=groups&app=true'; - } else if (isset($_GET['plugin'])) { - $show = '?show=groups&plugin=' . $_GET['plugin']; - } else { - $show = '?show=groups'; - } - $query = '?group='.$_GET['group']; - if (isset($_GET['app'])) { - $query .= '&app=true'; - } elseif (isset($_GET['plugin'])) { - $query .= '&plugin=' . $_GET['plugin']; - } - } - if (isset($_GET['case'])) { - if (isset($_GET['app'])) { - $show = '?show=cases&app=true'; - } else if (isset($_GET['plugin'])) { - $show = '?show=cases&plugin=' . $_GET['plugin']; - } else { - $show = '?show=cases'; - } - $query = '?case='.$_GET['case']; - if (isset($_GET['app'])) { - $query .= '&app=true'; - } elseif (isset($_GET['plugin'])) { - $query .= '&plugin=' . $_GET['plugin']; - } - } - ob_start(); - echo "

Run more tests | Show Passes | \n"; - break; - } - } - -/** - * Provides the links to analyzing code coverage - * - * @return void - * @access public - */ - function CakePHPTestAnalyzeCodeCoverage() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - if (isset($_GET['case'])) { - $query = '?case='.$_GET['case']; - if (isset($_GET['app'])) { - $query .= '&app=true'; - } elseif (isset($_GET['plugin'])) { - $query .= '&plugin=' . $_GET['plugin']; - } - } else { - $query = '?group='.$_GET['group']; - if (isset($_GET['app'])) { - $query .= '&app=true'; - } elseif (isset($_GET['plugin'])) { - $query .= '&plugin=' . $_GET['plugin']; - } - } - $query .= '&code_coverage=true'; - ob_start(); - echo " Analyze Code Coverage

\n"; - - break; - } - } - -/** - * Prints a list of test cases - * - * @return void - * @access public - */ - function CakePHPTestCaseList() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - ob_start(); - echo HtmlTestManager::getTestCaseList(); - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - echo TextTestManager::getTestCaseList(); - break; - } - } - -/** - * Prints a list of group tests - * - * @return void - * @access public - */ - function CakePHPTestGroupTestList() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - echo HtmlTestManager::getGroupTestList(); - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - echo TextTestManager::getGroupTestList(); - break; - } - } - -/** - * Includes the Testsuite Header - * - * @return void - * @access public - */ - function CakePHPTestHeader() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - ob_start(); - if (!class_exists('dispatcher')) { - require CAKE . 'dispatcher.php'; - } - $dispatch =& new Dispatcher(); - $dispatch->baseUrl(); - define('BASE', $dispatch->webroot); - $baseUrl = BASE; - $characterSet = 'charset=utf-8'; - include CAKE_TESTS_LIB . 'header.php'; - - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - header('content-type: text/plain'); - break; - } - } - -/** - * Provides the left hand navigation for the testsuite - * - * @return void - * @access public - */ - function CakePHPTestSuiteHeader() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - ob_start(); - $groups = $_SERVER['PHP_SELF'].'?show=groups'; - $cases = $_SERVER['PHP_SELF'].'?show=cases'; - $plugins = App::objects('plugin'); - include CAKE_TESTS_LIB . 'content.php'; - break; - } - } - -/** - * Provides the testsuite footer text - * - * @return void - * @access public - */ - function CakePHPTestSuiteFooter() { - switch ( CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - ob_start(); - $baseUrl = BASE; - include CAKE_TESTS_LIB . 'footer.php'; - break; - } - } } ?> \ No newline at end of file From 034d016a4f24a91bd52db2734bf404eb99f4bb57 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 22:11:29 -0500 Subject: [PATCH 034/137] Altering test.php to use CakeTestMenu instead of global functions. --- app/webroot/test.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/webroot/test.php b/app/webroot/test.php index b87686602..7c7dc2d27 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -86,6 +86,7 @@ if (isset($corePath[0])) { } require_once CAKE_TESTS_LIB . 'test_manager.php'; +require_once CAKE_TESTS_LIB . 'cake_test_menu.php'; if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.', true)); @@ -112,9 +113,9 @@ if (isset($_GET['output']) && $_GET['output'] == 'html') { } if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { - CakePHPTestHeader(); + CakeTestMenu::testHeader(); include CAKE_TESTS_LIB . 'simpletest.php'; - CakePHPTestSuiteFooter(); + CakeTestMenu::footer(); exit(); } @@ -123,15 +124,15 @@ if (isset($_GET['code_coverage'])) { $analyzeCodeCoverage = true; require_once CAKE_TESTS_LIB . 'code_coverage_manager.php'; if (!extension_loaded('xdebug')) { - CakePHPTestHeader(); + CakeTestMenu::testHeader(); include CAKE_TESTS_LIB . 'xdebug.php'; - CakePHPTestSuiteFooter(); + CakeTestMenu::footer(); exit(); } } -CakePHPTestHeader(); -CakePHPTestSuiteHeader(); +CakeTestMenu::testHeader(); +CakeTestMenu::testSuiteHeader(); define('RUN_TEST_LINK', $_SERVER['PHP_SELF']); if (isset($_GET['group'])) { @@ -147,8 +148,8 @@ if (isset($_GET['group'])) { } } - CakePHPTestRunMore(); - CakePHPTestAnalyzeCodeCoverage(); + CakeTestMenu::runMore(); + CakeTestMenu::analyzeCodeCoverage(); } elseif (isset($_GET['case'])) { if ($analyzeCodeCoverage) { CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter()); @@ -160,14 +161,14 @@ if (isset($_GET['group'])) { CodeCoverageManager::report(); } - CakePHPTestRunMore(); - CakePHPTestAnalyzeCodeCoverage(); + CakeTestMenu::runMore(); + CakeTestMenu::analyzeCodeCoverage(); } elseif (isset($_GET['show']) && $_GET['show'] == 'cases') { - CakePHPTestCaseList(); + CakeTestMenu::testCaseList(); } else { - CakePHPTestGroupTestList(); + CakeTestMenu::groupTestList(); } -CakePHPTestSuiteFooter(); +CakeTestMenu::footer(); $output = ob_get_clean(); echo $output; ?> \ No newline at end of file From a3b0805347102476704abbd506b12f6e34a008cd Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 22:12:00 -0500 Subject: [PATCH 035/137] Fixing formatting. --- cake/tests/lib/cake_test_menu.php | 6 +++--- cake/tests/lib/test_manager.php | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cake/tests/lib/cake_test_menu.php b/cake/tests/lib/cake_test_menu.php index 6eb9bf2bb..8fc50298e 100644 --- a/cake/tests/lib/cake_test_menu.php +++ b/cake/tests/lib/cake_test_menu.php @@ -74,7 +74,7 @@ class CakeTestMenu { switch (CAKE_TEST_OUTPUT) { case CAKE_TEST_OUTPUT_HTML: if (isset($_GET['case'])) { - $query = '?case='.$_GET['case']; + $query = '?case=' . $_GET['case']; if (isset($_GET['app'])) { $query .= '&app=true'; } elseif (isset($_GET['plugin'])) { @@ -171,8 +171,8 @@ class CakeTestMenu { switch (CAKE_TEST_OUTPUT) { case CAKE_TEST_OUTPUT_HTML: ob_start(); - $groups = $_SERVER['PHP_SELF'].'?show=groups'; - $cases = $_SERVER['PHP_SELF'].'?show=cases'; + $groups = $_SERVER['PHP_SELF'] . '?show=groups'; + $cases = $_SERVER['PHP_SELF'] . '?show=cases'; $plugins = App::objects('plugin'); include CAKE_TESTS_LIB . 'content.php'; break; diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 01aa4cc8e..a776c60c1 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -637,6 +637,5 @@ if (function_exists('caketestsgetreporter')) { return $Reporter; } - } ?> \ No newline at end of file From da19e31188a701461606c99b1f0c20cc297b0179 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 22:27:52 -0500 Subject: [PATCH 036/137] Refactoring duplicate switch logic to a single method. --- cake/tests/lib/cake_test_menu.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/cake/tests/lib/cake_test_menu.php b/cake/tests/lib/cake_test_menu.php index 8fc50298e..e27ffe401 100644 --- a/cake/tests/lib/cake_test_menu.php +++ b/cake/tests/lib/cake_test_menu.php @@ -103,16 +103,8 @@ class CakeTestMenu { * @access public */ function testCaseList() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - ob_start(); - echo HtmlTestManager::getTestCaseList(); - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - echo TextTestManager::getTestCaseList(); - break; - } + $class = CakeTestMenu::getTestManager(); + echo call_user_func(array($class, 'getTestCaseList')); } /** @@ -122,14 +114,22 @@ class CakeTestMenu { * @access public */ function groupTestList() { + $class = CakeTestMenu::getTestManager(); + echo call_user_func(array($class, 'getGroupTestList')); + } + +/** + * Gets the correct test manager for the chosen output. + * + * @return void + */ + function getTestManager() { switch (CAKE_TEST_OUTPUT) { case CAKE_TEST_OUTPUT_HTML: - echo HtmlTestManager::getGroupTestList(); - break; + return 'HtmlTestManager'; case CAKE_TEST_OUTPUT_TEXT: default: - echo TextTestManager::getGroupTestList(); - break; + return 'TextTestManager'; } } From 8181acbb0b2e4f0c594ecc926eff0a2b41050726 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 22:48:03 -0500 Subject: [PATCH 037/137] Adding doc blocks to TestManager. --- cake/tests/lib/test_manager.php | 67 ++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index a776c60c1..0b85d9830 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -23,15 +23,39 @@ define('APP_TEST_CASES', TESTS . 'cases'); define('APP_TEST_GROUPS', TESTS . 'groups'); /** - * Short description for class. + * TestManager is the base class that handles loading and initiating the running + * of TestCase and TestSuite classes that the user has selected. * * @package cake * @subpackage cake.cake.tests.lib */ class TestManager { +/** + * Extension suffix for test case files. + * + * @var string + */ var $_testExtension = '.test.php'; + +/** + * Extension suffix for group test case files. + * + * @var string + */ var $_groupExtension = '.group.php'; + +/** + * Is this test an AppTest? + * + * @var boolean + */ var $appTest = false; + +/** + * Is this test a plugin test? + * + * @var mixed boolean false or string name of the plugin being used. + */ var $pluginTest = false; /** @@ -69,8 +93,9 @@ class TestManager { /** * Runs all tests in the Application depending on the current appTest setting * - * @param string $reporter - * @return void + * @param Object $reporter Reporter object for the tests being run. + * @param boolean $testing Are tests supposed to be auto run. Set to true to return testcase list. + * @return mixed * @access public */ function runAllTests(&$reporter, $testing = false) { @@ -99,9 +124,10 @@ class TestManager { /** * Runs a specific test case file * - * @param string $testCaseFile - * @param string $reporter - * @return void + * @param string $testCaseFile Filename of the test to be run. + * @param Object $reporter Reporter instance to attach to the test case. + * @param boolean $testing Set to true if testing, otherwise test case will be run. + * @return mixed * @access public */ function runTestCase($testCaseFile, &$reporter, $testing = false) { @@ -126,9 +152,9 @@ class TestManager { /** * Runs a specific group test file * - * @param string $groupTestName - * @param string $reporter - * @return void + * @param string $groupTestName GroupTest that you want to run. + * @param Object $reporter Reporter instance to use with the group test being run. + * @return mixed * @access public */ function runGroupTest($groupTestName, &$reporter) { @@ -154,8 +180,8 @@ class TestManager { /** * Adds all testcases in a given directory to a given GroupTest object * - * @param string $groupTest - * @param string $directory + * @param object $groupTest Instance of TestSuite/GroupTest that files are to be added to. + * @param string $directory The directory to add tests from. * @return void * @access public */ @@ -170,8 +196,8 @@ class TestManager { /** * Adds a specific test file and thereby all of its test cases and group tests to a given group test file * - * @param string $groupTest - * @param string $file + * @param object $groupTest Instance of TestSuite/GroupTest that a file should be added to. + * @param string $file The file name, minus the suffix to add. * @return void * @access public */ @@ -235,6 +261,7 @@ class TestManager { /** * Returns a list of group test files from a given directory * + * @param string $directory The directory to get group test files from. * @access public */ function &_getTestGroupFileList($directory = '.') { @@ -245,6 +272,7 @@ class TestManager { /** * Returns a list of group test files from a given directory * + * @param string $directory The directory to get group tests from. * @access public */ function &_getTestGroupList($directory = '.') { @@ -261,6 +289,7 @@ class TestManager { /** * Returns a list of class names from a group test file * + * @param string $groupTestFile The groupTest file to scan for TestSuite classnames. * @access public */ function &_getGroupTestClassNames($groupTestFile) { @@ -278,6 +307,8 @@ class TestManager { * Gets a recursive list of files from a given directory and matches then against * a given fileTestFunction, like isTestCaseFile() * + * @param string $directory The directory to scan for files. + * @param mixed $fileTestFunction * @access public */ function &_getRecursiveFileList($directory = '.', $fileTestFunction) { @@ -336,8 +367,8 @@ class TestManager { /** * Returns the given path to the test files depending on a given type of tests (cases, group, ..) * - * @param string $type - * @return void + * @param string $type either 'cases' or 'groups' + * @return string The path tests are located on * @access public */ function _getTestsPath($type = 'cases') { @@ -365,10 +396,10 @@ class TestManager { } /** - * undocumented function + * Get the extension for either 'group' or 'test' types. * - * @param string $type - * @return void + * @param string $type Type of test to get, either 'test' or 'group' + * @return string Extension suffix for test. * @access public */ function getExtension($type = 'test') { From 183abfa4a996694d78e6563a3a3c9409e6a916b7 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 22:53:58 -0500 Subject: [PATCH 038/137] Adding Docblocks to TextTestManager --- cake/tests/lib/test_manager.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 0b85d9830..558a770c1 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -475,7 +475,7 @@ class TextTestManager extends TestManager { /** * Returns the base url * - * @return void + * @return string The base URL for link building. * @access public */ function getBaseURL() { @@ -485,6 +485,7 @@ class TextTestManager extends TestManager { /** * Returns a list of available group tests in a text-friendly format * + * @return string A link list for group tests. * @access public */ function &getGroupTestList() { @@ -513,6 +514,7 @@ class TextTestManager extends TestManager { /** * Returns a list of available test cases in a text-friendly format * + * @param string A link list for test cases. * @access public */ function &getTestCaseList() { From effc03ca3aab32a47c7f7bca18901b5f88703de4 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 23:22:16 -0500 Subject: [PATCH 039/137] Adding CakeTestSuiteDispatcher to handle dispatching of the test suite. --- cake/tests/lib/cake_test_menu.php | 3 +- cake/tests/lib/cake_test_suite_dispatcher.php | 160 ++++++++++++++++++ 2 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 cake/tests/lib/cake_test_suite_dispatcher.php diff --git a/cake/tests/lib/cake_test_menu.php b/cake/tests/lib/cake_test_menu.php index e27ffe401..7099bca54 100644 --- a/cake/tests/lib/cake_test_menu.php +++ b/cake/tests/lib/cake_test_menu.php @@ -194,4 +194,5 @@ class CakeTestMenu { break; } } -} \ No newline at end of file +} +?> \ No newline at end of file diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php new file mode 100644 index 000000000..cd75a5946 --- /dev/null +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -0,0 +1,160 @@ + + * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @package cake + * @subpackage cake.cake.tests.lib + * @since CakePHP(tm) v 1.3 + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ +require_once CAKE_TESTS_LIB . 'test_manager.php'; +require_once CAKE_TESTS_LIB . 'cake_test_menu.php'; + +/** + * CakeTestSuiteDispatcher handles web requests to the test suite and runs the correct action. + * + * @package cake.tests.libs + */ +class CakeTestSuiteDispatcher { +/** + * 'Request' parameters + * + * @var array + */ + var $params = array( + 'codeCoverage' => false, + 'group' => null, + 'case' => null, + 'app' => false, + 'plugin' => null, + 'output' => 'html', + 'show' => 'groups' + ); +/** + * Runs the actions required by the URL parameters. + * + * @return void + */ + function dispatch() { + CakeTestMenu::testHeader(); + CakeTestMenu::testSuiteHeader(); + + $this->_checkSimpleTest(); + $this->_parseParams(); + + if ($this->params['group']) { + $this->_runGroupTest(); + } elseif ($this->params['case']) { + $this->_runTestCase(); + } elseif (isset($_GET['show']) && $_GET['show'] == 'cases') { + CakeTestMenu::testCaseList(); + } else { + CakeTestMenu::groupTestList(); + } + + CakeTestMenu::footer(); + $output = ob_get_clean(); + echo $output; + } + +/** + * Checks that simpleTest is installed. Will exit if it doesn't + * + * @return void + */ + function _checkSimpleTest() { + if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { + CakeTestMenu::testHeader(); + include CAKE_TESTS_LIB . 'simpletest.php'; + CakeTestMenu::footer(); + exit(); + } + } + +/** + * Checks for the xdebug extension required to do code coverage. Displays an error + * if xdebug isn't installed. + * + * @return void + */ + function _checkXdebug() { + if (!extension_loaded('xdebug')) { + CakeTestMenu::testHeader(); + include CAKE_TESTS_LIB . 'xdebug.php'; + CakeTestMenu::footer(); + exit(); + } + } + +/** + * Parse url params into a 'request' + * + * @return void + */ + function _parseParams() { + if (!isset($_SERVER['SERVER_NAME'])) { + $_SERVER['SERVER_NAME'] = ''; + } + foreach ($this->params as $key => $value) { + if (isset($_GET[$key])) { + $this->params[$key] = $_GET[$key]; + } + } + if (isset($_GET['code_coverage'])) { + $this->params['codeCoverage'] = true; + require_once CAKE_TESTS_LIB . 'code_coverage_manager.php'; + $this->_checkXdebug(); + } + } + +/** + * Runs the group test case. + * + * @return void + */ + function _runGroupTest() { + if ('all' == $this->params['group']) { + TestManager::runAllTests(CakeTestsGetReporter()); + } else { + if ($this->params['codeCoverage']) { + CodeCoverageManager::start($this->params['group'], CakeTestsGetReporter()); + } + TestManager::runGroupTest(ucfirst($this->params['group']), CakeTestsGetReporter()); + if ($this->params['codeCoverage']) { + CodeCoverageManager::report(); + } + } + CakeTestMenu::runMore(); + CakeTestMenu::analyzeCodeCoverage(); + } + +/** + * Runs a test case file. + * + * @return void + */ + function _runTestCase() { + if ($this->params['codeCoverage']) { + CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter()); + } + + TestManager::runTestCase($_GET['case'], CakeTestsGetReporter()); + + if ($this->params['codeCoverage']) { + CodeCoverageManager::report(); + } + CakeTestMenu::runMore(); + CakeTestMenu::analyzeCodeCoverage(); + } +} +?> \ No newline at end of file From 4e09cabdd91a736cb9fba4e8bf1f564a9c687957 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 3 Jan 2010 23:26:24 -0500 Subject: [PATCH 040/137] Updating app/webroot/test.php to use CakeTestSuiteDispatcher. Will allow test suite changes to not affect app land files going forward. --- app/webroot/test.php | 70 +++----------------------------------------- 1 file changed, 4 insertions(+), 66 deletions(-) diff --git a/app/webroot/test.php b/app/webroot/test.php index 7c7dc2d27..28c4a9430 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -85,19 +85,10 @@ if (isset($corePath[0])) { define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH); } -require_once CAKE_TESTS_LIB . 'test_manager.php'; -require_once CAKE_TESTS_LIB . 'cake_test_menu.php'; - if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.', true)); } -if (!isset($_SERVER['SERVER_NAME'])) { - $_SERVER['SERVER_NAME'] = ''; -} -if (empty( $_GET['output'])) { - $_GET['output'] = 'html'; -} /** * * Used to determine output to display @@ -105,70 +96,17 @@ if (empty( $_GET['output'])) { define('CAKE_TEST_OUTPUT_HTML', 1); define('CAKE_TEST_OUTPUT_TEXT', 2); -if (isset($_GET['output']) && $_GET['output'] == 'html') { +if (!isset($_GET['output']) || (isset($_GET['output']) && $_GET['output'] == 'html')) { define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML); } else { Debugger::output('txt'); define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT); } - -if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { - CakeTestMenu::testHeader(); - include CAKE_TESTS_LIB . 'simpletest.php'; - CakeTestMenu::footer(); - exit(); -} - -$analyzeCodeCoverage = false; -if (isset($_GET['code_coverage'])) { - $analyzeCodeCoverage = true; - require_once CAKE_TESTS_LIB . 'code_coverage_manager.php'; - if (!extension_loaded('xdebug')) { - CakeTestMenu::testHeader(); - include CAKE_TESTS_LIB . 'xdebug.php'; - CakeTestMenu::footer(); - exit(); - } -} - -CakeTestMenu::testHeader(); -CakeTestMenu::testSuiteHeader(); define('RUN_TEST_LINK', $_SERVER['PHP_SELF']); -if (isset($_GET['group'])) { - if ('all' == $_GET['group']) { - TestManager::runAllTests(CakeTestsGetReporter()); - } else { - if ($analyzeCodeCoverage) { - CodeCoverageManager::start($_GET['group'], CakeTestsGetReporter()); - } - TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter()); - if ($analyzeCodeCoverage) { - CodeCoverageManager::report(); - } - } +require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php'; - CakeTestMenu::runMore(); - CakeTestMenu::analyzeCodeCoverage(); -} elseif (isset($_GET['case'])) { - if ($analyzeCodeCoverage) { - CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter()); - } +$Dispatcher = new CakeTestSuiteDispatcher(); +$Dispatcher->dispatch(); - TestManager::runTestCase($_GET['case'], CakeTestsGetReporter()); - - if ($analyzeCodeCoverage) { - CodeCoverageManager::report(); - } - - CakeTestMenu::runMore(); - CakeTestMenu::analyzeCodeCoverage(); -} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') { - CakeTestMenu::testCaseList(); -} else { - CakeTestMenu::groupTestList(); -} -CakeTestMenu::footer(); -$output = ob_get_clean(); -echo $output; ?> \ No newline at end of file From 33cb8eebfebdc679b3becd37d31c67f6fdfb77a0 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 4 Jan 2010 00:16:03 -0500 Subject: [PATCH 041/137] Renaming CakeHtmlReporter's file. --- cake/tests/lib/{cake_reporter.php => cake_html_reporter.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cake/tests/lib/{cake_reporter.php => cake_html_reporter.php} (100%) diff --git a/cake/tests/lib/cake_reporter.php b/cake/tests/lib/cake_html_reporter.php similarity index 100% rename from cake/tests/lib/cake_reporter.php rename to cake/tests/lib/cake_html_reporter.php From dd5a886f3af0ce5a31713a92154dca3777add175 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 4 Jan 2010 00:17:42 -0500 Subject: [PATCH 042/137] Removing CakeTestsGetReporter global function. Starting to move Reporter/Manager decision making to CakeTestSuiteDispatcher, also affording the ability to use custom reporters/managers for generating test suite output. --- cake/tests/lib/cake_test_suite_dispatcher.php | 46 ++++++++++++++++++- cake/tests/lib/test_manager.php | 30 ------------ 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index cd75a5946..ea6174be2 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -40,6 +40,7 @@ class CakeTestSuiteDispatcher { 'output' => 'html', 'show' => 'groups' ); + /** * Runs the actions required by the URL parameters. * @@ -96,6 +97,46 @@ class CakeTestSuiteDispatcher { } } +/** + * Sets the Manager to use for the request. + * + * @return string The manager class name + * @static + */ + function getManager() { + $className = ucwords($this->params['output']) . 'TestManager'; + if (class_exists($className)) { + $this->_manager = $className; + return; + } else { + $this->_manager = 'TextTestManager'; + } + } + +/** + * Gets the reporter based on the request parameters + * + * @return void + */ + function &getReporter() { + static $Reporter = NULL; + if (!$Reporter) { + $coreClass = 'Cake' . $this->params['output'] . 'Reporter'; + $coreFile = CAKE_TESTS_LIB . 'cake_' . strtolower($this->params['output']) . '_reporter.php'; + + $appClass = $this->params['output'] . 'Reporter'; + $appFile = APPLIBS . 'test_suite' . DS . strtolower($this->params['output']) . '_reporter.php'; + if (file_exists($coreFile)) { + require_once $coreFile; + $Reporter =& new $coreClass(); + } elseif (file_exists($appFile)) { + require_once $appFile; + $Reporter =& new $appClass(); + } + } + return $Reporter; + } + /** * Parse url params into a 'request' * @@ -115,6 +156,7 @@ class CakeTestSuiteDispatcher { require_once CAKE_TESTS_LIB . 'code_coverage_manager.php'; $this->_checkXdebug(); } + $this->getManager(); } /** @@ -127,9 +169,9 @@ class CakeTestSuiteDispatcher { TestManager::runAllTests(CakeTestsGetReporter()); } else { if ($this->params['codeCoverage']) { - CodeCoverageManager::start($this->params['group'], CakeTestsGetReporter()); + CodeCoverageManager::start($this->params['group'], CakeTestSuiteDispatcher::getReporter()); } - TestManager::runGroupTest(ucfirst($this->params['group']), CakeTestsGetReporter()); + TestManager::runGroupTest(ucfirst($this->params['group']), CakeTestSuiteDispatcher::getReporter()); if ($this->params['codeCoverage']) { CodeCoverageManager::report(); } diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 558a770c1..a54e3e689 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -641,34 +641,4 @@ class HtmlTestManager extends TestManager { return $buffer; } } - -if (function_exists('caketestsgetreporter')) { - echo "You need a new test.php. \n"; - echo "Try this one: " . dirname(CONSOLE_LIBS) . "templates" . DS . "skel" . DS . "webroot" . DS . "test.php"; - exit(); -} else { - -/** - * Returns an object of the currently needed reporter - * - * @access public - */ - function &CakeTestsGetReporter() { - static $Reporter = NULL; - if (!$Reporter) { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - require_once CAKE_TESTS_LIB . 'cake_reporter.php'; - $Reporter =& new CakeHtmlReporter(); - break; - default: - require_once CAKE_TESTS_LIB . 'cake_text_reporter.php'; - $Reporter =& new CakeTextReporter(); - break; - } - } - return $Reporter; - } - -} ?> \ No newline at end of file From 9a62fd52b38725a80c985300cb52de0111b6d357 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 4 Jan 2010 00:24:39 -0500 Subject: [PATCH 043/137] Fixing occurances of CakeTestsGetReporter and fixing issues loading reporters. --- cake/tests/lib/cake_test_suite_dispatcher.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index ea6174be2..b6eb7f1cc 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -121,16 +121,14 @@ class CakeTestSuiteDispatcher { function &getReporter() { static $Reporter = NULL; if (!$Reporter) { - $coreClass = 'Cake' . $this->params['output'] . 'Reporter'; + $coreClass = 'Cake' . ucwords($this->params['output']) . 'Reporter'; $coreFile = CAKE_TESTS_LIB . 'cake_' . strtolower($this->params['output']) . '_reporter.php'; - + $appClass = $this->params['output'] . 'Reporter'; $appFile = APPLIBS . 'test_suite' . DS . strtolower($this->params['output']) . '_reporter.php'; - if (file_exists($coreFile)) { - require_once $coreFile; + if (include_once $coreFile) { $Reporter =& new $coreClass(); - } elseif (file_exists($appFile)) { - require_once $appFile; + } elseif (include_once $appFile) { $Reporter =& new $appClass(); } } @@ -187,10 +185,10 @@ class CakeTestSuiteDispatcher { */ function _runTestCase() { if ($this->params['codeCoverage']) { - CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter()); + CodeCoverageManager::start($_GET['case'], CakeTestSuiteDispatcher::getReporter()); } - TestManager::runTestCase($_GET['case'], CakeTestsGetReporter()); + TestManager::runTestCase($_GET['case'], CakeTestSuiteDispatcher::getReporter()); if ($this->params['codeCoverage']) { CodeCoverageManager::report(); From 48e1c4d08af920b5dabae284d2543e18607dcd42 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 4 Jan 2010 23:58:09 -0500 Subject: [PATCH 044/137] Removing duplicate method calls, and doing some refactoring of Reporter retrieval. Adding Manager instance var to help make subclassing more flexible in regards to TestManagers. --- cake/tests/lib/cake_test_suite_dispatcher.php | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index b6eb7f1cc..5a2879d58 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -41,6 +41,20 @@ class CakeTestSuiteDispatcher { 'show' => 'groups' ); +/** + * The classname for the TestManager being used + * + * @var string + */ + var $_managerClass; + +/** + * The Instance of the Manager being used. + * + * @var TestManager subclass + */ + var $Manager; + /** * Runs the actions required by the URL parameters. * @@ -75,7 +89,6 @@ class CakeTestSuiteDispatcher { */ function _checkSimpleTest() { if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { - CakeTestMenu::testHeader(); include CAKE_TESTS_LIB . 'simpletest.php'; CakeTestMenu::footer(); exit(); @@ -90,7 +103,6 @@ class CakeTestSuiteDispatcher { */ function _checkXdebug() { if (!extension_loaded('xdebug')) { - CakeTestMenu::testHeader(); include CAKE_TESTS_LIB . 'xdebug.php'; CakeTestMenu::footer(); exit(); @@ -106,11 +118,14 @@ class CakeTestSuiteDispatcher { function getManager() { $className = ucwords($this->params['output']) . 'TestManager'; if (class_exists($className)) { - $this->_manager = $className; - return; + $this->_managerClass = $className; } else { - $this->_manager = 'TextTestManager'; + $this->_managerClass = 'TextTestManager'; } + if (empty($this->Manager)) { + $this->Manager = new $this->_managerClass(); + } + return $this->Manager; } /** @@ -163,13 +178,14 @@ class CakeTestSuiteDispatcher { * @return void */ function _runGroupTest() { + $Reporter =& CakeTestSuiteDispatcher::getReporter(); if ('all' == $this->params['group']) { - TestManager::runAllTests(CakeTestsGetReporter()); + TestManager::runAllTests($Reporter); } else { if ($this->params['codeCoverage']) { - CodeCoverageManager::start($this->params['group'], CakeTestSuiteDispatcher::getReporter()); + CodeCoverageManager::start($this->params['group'], $Reporter); } - TestManager::runGroupTest(ucfirst($this->params['group']), CakeTestSuiteDispatcher::getReporter()); + TestManager::runGroupTest(ucfirst($this->params['group']), $Reporter); if ($this->params['codeCoverage']) { CodeCoverageManager::report(); } @@ -184,11 +200,12 @@ class CakeTestSuiteDispatcher { * @return void */ function _runTestCase() { + $Reporter =& CakeTestSuiteDispatcher::getReporter(); if ($this->params['codeCoverage']) { - CodeCoverageManager::start($_GET['case'], CakeTestSuiteDispatcher::getReporter()); + CodeCoverageManager::start($_GET['case'], $Reporter); } - TestManager::runTestCase($_GET['case'], CakeTestSuiteDispatcher::getReporter()); + TestManager::runTestCase($_GET['case'], $Reporter); if ($this->params['codeCoverage']) { CodeCoverageManager::report(); From e60d742c045cf8d2c00c5ff3d9fa98e0e43ba2c7 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 00:03:30 -0500 Subject: [PATCH 045/137] Whitespace updates. --- cake/tests/lib/test_manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index a54e3e689..21649caa6 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -505,7 +505,7 @@ class TextTestManager extends TestManager { $buffer .= "All tests\n" . $_SERVER['SERVER_NAME'] . $manager->getBaseURL() . "?group=all&output=txt{$urlExtra}\n"; foreach ((array)$groupTests as $groupTest) { - $buffer .= $_SERVER['SERVER_NAME']. $manager->getBaseURL()."?group=" . $groupTest . "&output=txt{$urlExtra}"."\n"; + $buffer .= $_SERVER['SERVER_NAME'] . $manager->getBaseURL() . "?group=" . $groupTest . "&output=text{$urlExtra}\n"; } return $buffer; @@ -537,7 +537,7 @@ class TextTestManager extends TestManager { } foreach ($testCases as $testCaseFile => $testCase) { - $buffer .= $_SERVER['SERVER_NAME']. $manager->getBaseURL()."?case=" . $testCase . "&output=txt"."\n"; + $buffer .= $_SERVER['SERVER_NAME']. $manager->getBaseURL()."?case=" . $testCase . "&output=text"."\n"; } $buffer .= "\n"; From 104086b928dffee7e8a18e4388378de4f36444d7 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 00:09:07 -0500 Subject: [PATCH 046/137] Converting static calls to TestManager to use Manager instance in the TestSuiteDispatcher. Converting static methods to instance methods. --- cake/tests/lib/cake_test_suite_dispatcher.php | 6 +++--- cake/tests/lib/test_manager.php | 11 ++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 5a2879d58..91a3c774f 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -180,12 +180,12 @@ class CakeTestSuiteDispatcher { function _runGroupTest() { $Reporter =& CakeTestSuiteDispatcher::getReporter(); if ('all' == $this->params['group']) { - TestManager::runAllTests($Reporter); + $this->Manager->runAllTests($Reporter); } else { if ($this->params['codeCoverage']) { CodeCoverageManager::start($this->params['group'], $Reporter); } - TestManager::runGroupTest(ucfirst($this->params['group']), $Reporter); + $this->Manager->runGroupTest(ucfirst($this->params['group']), $Reporter); if ($this->params['codeCoverage']) { CodeCoverageManager::report(); } @@ -205,7 +205,7 @@ class CakeTestSuiteDispatcher { CodeCoverageManager::start($_GET['case'], $Reporter); } - TestManager::runTestCase($_GET['case'], $Reporter); + $this->Manager->runTestCase($_GET['case'], $Reporter); if ($this->params['codeCoverage']) { CodeCoverageManager::report(); diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 21649caa6..2d22c5219 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -131,9 +131,7 @@ class TestManager { * @access public */ function runTestCase($testCaseFile, &$reporter, $testing = false) { - $manager =& new TestManager(); - - $testCaseFileWithPath = $manager->_getTestsPath() . DS . $testCaseFile; + $testCaseFileWithPath = $this->_getTestsPath() . DS . $testCaseFile; if (!file_exists($testCaseFileWithPath)) { trigger_error("Test case {$testCaseFile} cannot be found", E_USER_ERROR); @@ -158,8 +156,7 @@ class TestManager { * @access public */ function runGroupTest($groupTestName, &$reporter) { - $manager =& new TestManager(); - $filePath = $manager->_getTestsPath('groups') . DS . strtolower($groupTestName) . $manager->_groupExtension; + $filePath = $this->_getTestsPath('groups') . DS . strtolower($groupTestName) . $this->_groupExtension; if (!file_exists($filePath)) { trigger_error("Group test {$groupTestName} cannot be found at {$filePath}", E_USER_ERROR); @@ -167,7 +164,7 @@ class TestManager { require_once $filePath; $test =& new TestSuite($groupTestName . ' group test'); - foreach ($manager->_getGroupTestClassNames($filePath) as $groupTest) { + foreach ($this->_getGroupTestClassNames($filePath) as $groupTest) { $testCase = new $groupTest(); $test->addTestCase($testCase); if (isset($testCase->label)) { @@ -582,8 +579,8 @@ class HtmlTestManager extends TestManager { * @access public */ function &getGroupTestList() { - $urlExtra = ''; $manager =& new HtmlTestManager(); + $urlExtra = ''; $groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups')); $buffer = "

Core Test Groups:

\n
    "; From 34ffa43119e39c6f5961d87c8b7f9101d49ffeb6 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 00:13:03 -0500 Subject: [PATCH 047/137] Refactoring hardcoded extensions to use properties. --- cake/tests/lib/test_manager.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 2d22c5219..7181f7465 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -201,10 +201,10 @@ class TestManager { function addTestFile(&$groupTest, $file) { $manager =& new TestManager(); - if (file_exists($file.'.test.php')) { - $file .= '.test.php'; - } elseif (file_exists($file.'.group.php')) { - $file .= '.group.php'; + if (file_exists($file . $manager->_testExtension)) { + $file .= $manager->_testExtension; + } elseif (file_exists($file . $manager->_groupExtension)) { + $file .= $manager->_groupExtension; } $groupTest->addTestFile($file); } From 5bd9734f96149e877bf4929d72433e77e4dca2b7 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 20:10:41 -0500 Subject: [PATCH 048/137] Moving reporters to a directory and updating CakeTestSuiteDispatcher. --- cake/tests/lib/cake_test_suite_dispatcher.php | 5 +++-- cake/tests/lib/{ => reporter}/cake_html_reporter.php | 0 cake/tests/lib/{ => reporter}/cake_text_reporter.php | 0 cake/tests/lib/{ => reporter}/cli_reporter.php | 0 4 files changed, 3 insertions(+), 2 deletions(-) rename cake/tests/lib/{ => reporter}/cake_html_reporter.php (100%) rename cake/tests/lib/{ => reporter}/cake_text_reporter.php (100%) rename cake/tests/lib/{ => reporter}/cli_reporter.php (100%) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 91a3c774f..b9278df71 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -136,11 +136,12 @@ class CakeTestSuiteDispatcher { function &getReporter() { static $Reporter = NULL; if (!$Reporter) { + $type = strtolower($this->params['output']); $coreClass = 'Cake' . ucwords($this->params['output']) . 'Reporter'; - $coreFile = CAKE_TESTS_LIB . 'cake_' . strtolower($this->params['output']) . '_reporter.php'; + $coreFile = CAKE_TESTS_LIB . 'reporter' . DS . 'cake_' . $type . '_reporter.php'; $appClass = $this->params['output'] . 'Reporter'; - $appFile = APPLIBS . 'test_suite' . DS . strtolower($this->params['output']) . '_reporter.php'; + $appFile = APPLIBS . 'test_suite' . DS . 'reporter' . DS . $type . '_reporter.php'; if (include_once $coreFile) { $Reporter =& new $coreClass(); } elseif (include_once $appFile) { diff --git a/cake/tests/lib/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php similarity index 100% rename from cake/tests/lib/cake_html_reporter.php rename to cake/tests/lib/reporter/cake_html_reporter.php diff --git a/cake/tests/lib/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php similarity index 100% rename from cake/tests/lib/cake_text_reporter.php rename to cake/tests/lib/reporter/cake_text_reporter.php diff --git a/cake/tests/lib/cli_reporter.php b/cake/tests/lib/reporter/cli_reporter.php similarity index 100% rename from cake/tests/lib/cli_reporter.php rename to cake/tests/lib/reporter/cli_reporter.php From 0d7875f4ad35bee13d4427cb49faaf1b33c4e619 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 20:29:08 -0500 Subject: [PATCH 049/137] Extracting methods and features out into CakeBaseReporter. --- .../tests/lib/reporter/cake_base_reporter.php | 92 +++++++++++++++++++ .../tests/lib/reporter/cake_html_reporter.php | 40 +------- 2 files changed, 93 insertions(+), 39 deletions(-) create mode 100644 cake/tests/lib/reporter/cake_base_reporter.php diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php new file mode 100644 index 000000000..ef70e0620 --- /dev/null +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -0,0 +1,92 @@ + + * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @package cake + * @subpackage cake.cake.tests.libs + * @since CakePHP(tm) v 1.3 + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ + +/** + * CakeBaseReporter contains common reporting features used in the CakePHP Test suite + * + * @package cake + * @subpackage cake.tests.lib + */ +class CakeBaseReporter extends SimpleReporter { + +/** + * Time the test runs started. + * + * @var integer + * @access protected + */ + var $_timeStart = 0; + +/** + * Time the test runs ended + * + * @var integer + * @access protected + */ + var $_timeEnd = 0; + +/** + * Duration of all test methods. + * + * @var integer + * @access protected + */ + var $_timeDuration = 0; + +/** + * Signals / Paints the beginning of a TestSuite executing. + * Starts the timer for the TestSuite execution time. + * + * @param string $test_name Name of the test that is being run. + * @param integer $size + * @return void + */ + function paintGroupStart($test_name, $size) { + if (empty($this->_timeStart)) { + $this->_timeStart = $this->_getTime(); + } + parent::paintGroupStart($test_name, $size); + } + +/** + * Signals/Paints the end of a TestSuite. All test cases have run + * and timers are stopped. + * + * @param string $test_name Name of the test that is being run. + * @return void + */ + function paintGroupEnd($test_name) { + $this->_timeEnd = $this->_getTime(); + $this->_timeDuration = $this->_timeEnd - $this->_timeStart; + parent::paintGroupEnd($test_name); + } + +/** + * Get the current time in microseconds. Similar to getMicrotime in basics.php + * but in a separate function to reduce dependancies. + * + * @return float Time in microseconds + */ + function _getTime() { + list($usec, $sec) = explode(' ', microtime()); + return ((float)$sec + (float)$usec); + } + +} diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 9f0ada202..af34124da 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -18,6 +18,7 @@ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ +include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; /** * CakeHtmlReporter Reports Results of TestSuites and Test Cases * in an HTML format / context. @@ -80,45 +81,6 @@ class CakeHtmlReporter extends SimpleReporter { $this->_character_set = $character_set; } -/** - * Signals / Paints the beginning of a TestSuite executing. - * Starts the timer for the TestSuite execution time. - * - * @param string $test_name Name of the test that is being run. - * @param integer $size - * @return void - */ - function paintGroupStart($test_name, $size) { - if (empty($this->_timeStart)) { - $this->_timeStart = $this->_getTime(); - } - parent::paintGroupStart($test_name, $size); - } - -/** - * Signals/Paints the end of a TestSuite. All test cases have run - * and timers are stopped. - * - * @param string $test_name Name of the test that is being run. - * @return void - */ - function paintGroupEnd($test_name) { - $this->_timeEnd = $this->_getTime(); - $this->_timeDuration = $this->_timeEnd - $this->_timeStart; - parent::paintGroupEnd($test_name); - } - -/** - * Get the current time in microseconds. Similar to getMicrotime in basics.php - * but in a separate function to reduce dependancies. - * - * @return float Time in microseconds - */ - function _getTime() { - list($usec, $sec) = explode(' ', microtime()); - return ((float)$sec + (float)$usec); - } - /** * Paints the top of the web page setting the * title to the name of the starting test. From 84c2bbdfe21218e55e0e78c718ab62bac089978f Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 20:44:01 -0500 Subject: [PATCH 050/137] Making CakeTextReporter use CakeBaseReporter as its base class, moving methods from TextReporter. --- .../tests/lib/reporter/cake_text_reporter.php | 159 +++++++++++++----- 1 file changed, 119 insertions(+), 40 deletions(-) diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index 94b6e8d6f..70038f65c 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -1,47 +1,31 @@ + * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://cakephp.org + * @package cake + * @subpackage cake.cake.tests.libs + * @since CakePHP(tm) v 1.3 + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ +include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; /** - * Signals / Paints the beginning of a TestSuite executing. - * Starts the timer for the TestSuite execution time. + * CakeTextReporter contains reporting features used for plain text based output * - * @param - * @return void + * @package cake + * @subpackage cake.tests.lib */ - function paintGroupStart($test_name, $size) { - if (empty($this->_timeStart)) { - $this->_timeStart = $this->_getTime(); - } - parent::paintGroupStart($test_name, $size); - } - -/** - * Signals/Paints the end of a TestSuite. All test cases have run - * and timers are stopped. - * - * @return void - */ - function paintGroupEnd($test_name) { - $this->_timeEnd = $this->_getTime(); - $this->_timeDuration = $this->_timeEnd - $this->_timeStart; - parent::paintGroupEnd($test_name); - } - -/** - * Get the current time in microseconds. Similar to getMicrotime in basics.php - * but in a separate function to reduce dependancies. - * - * @return float Time in microseconds - */ - function _getTime() { - list($usec, $sec) = explode(' ', microtime()); - return ((float)$sec + (float)$usec); - } - +class CakeTextReporter extends CakeBaseReporter { /** * Paints the end of the test with a summary of * the passes and failures. @@ -50,11 +34,106 @@ class CakeTextReporter extends TextReporter { * @access public */ function paintFooter($test_name) { - parent::paintFooter($test_name); + if ($this->getFailCount() + $this->getExceptionCount() == 0) { + echo "OK\n"; + } else { + echo "FAILURES!!!\n"; + } + echo "Test cases run: " . $this->getTestCaseProgress() . + "/" . $this->getTestCaseCount() . + ", Passes: " . $this->getPassCount() . + ", Failures: " . $this->getFailCount() . + ", Exceptions: " . $this->getExceptionCount() . "\n"; + echo 'Time taken by tests (in seconds): ' . $this->_timeDuration . "\n"; if (function_exists('memory_get_peak_usage')) { echo 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n"; } } +/** + * Paints the title only. + * + * @param string $test_name Name class of test. + * @access public + */ + function paintHeader($test_name) { + if (! SimpleReporter::inCli()) { + header('Content-type: text/plain'); + } + echo "$test_name\n"; + flush(); + } + +/** + * Paints the test failure as a stack trace. + * + * @param string $message Failure message displayed in + * the context of the other tests. + * @access public + */ + function paintFail($message) { + parent::paintFail($message); + echo $this->getFailCount() . ") $message\n"; + $breadcrumb = $this->getTestList(); + array_shift($breadcrumb); + echo "\tin " . implode("\n\tin ", array_reverse($breadcrumb)); + echo "\n"; + } + +/** + * Paints a PHP error. + * + * @param string $message Message to be shown. + * @access public + */ + function paintError($message) { + parent::paintError($message); + echo "Exception " . $this->getExceptionCount() . "!\n$message\n"; + $breadcrumb = $this->getTestList(); + array_shift($breadcrumb); + echo "\tin " . implode("\n\tin ", array_reverse($breadcrumb)); + echo "\n"; + } + +/** + * Paints a PHP exception. + * + * @param Exception $exception Exception to describe. + * @access public + */ + function paintException($exception) { + parent::paintException($exception); + $message = 'Unexpected exception of type [' . get_class($exception) . + '] with message ['. $exception->getMessage() . + '] in ['. $exception->getFile() . + ' line ' . $exception->getLine() . ']'; + echo "Exception " . $this->getExceptionCount() . "!\n$message\n"; + $breadcrumb = $this->getTestList(); + array_shift($breadcrumb); + echo "\tin " . implode("\n\tin ", array_reverse($breadcrumb)); + echo "\n"; + } + +/** + * Prints the message for skipping tests. + * + * @param string $message Text of skip condition. + * @access public + */ + function paintSkip($message) { + parent::paintSkip($message); + echo "Skip: $message\n"; + } + +/** + * Paints formatted text such as dumped variables. + * + * @param string $message Text to show. + * @access public + */ + function paintFormattedMessage($message) { + echo "$message\n"; + flush(); + } } ?> \ No newline at end of file From 1d63d52d3c953d17aacfe9506c1ce1fda1b010de Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 20:44:15 -0500 Subject: [PATCH 051/137] Updating @link properties and spacing. --- cake/tests/lib/cake_test_suite_dispatcher.php | 2 +- cake/tests/lib/reporter/cake_base_reporter.php | 2 +- cake/tests/lib/reporter/cake_html_reporter.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index b9278df71..29092a583 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -11,7 +11,7 @@ * Redistributions of files must retain the above copyright notice. * * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) - * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @link http://cakephp.org * @package cake * @subpackage cake.cake.tests.lib * @since CakePHP(tm) v 1.3 diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index ef70e0620..ad1fd5bf0 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -11,7 +11,7 @@ * Redistributions of files must retain the above copyright notice. * * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) - * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @link http://cakephp.org * @package cake * @subpackage cake.cake.tests.libs * @since CakePHP(tm) v 1.3 diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index af34124da..0c8005136 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -1,6 +1,6 @@ Date: Tue, 5 Jan 2010 20:52:22 -0500 Subject: [PATCH 052/137] Removing use of Set::filter(). Coupling the test suite to Set is not a good idea. --- cake/tests/lib/reporter/cake_html_reporter.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 0c8005136..97d0c15a9 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -32,6 +32,7 @@ class CakeHtmlReporter extends SimpleReporter { * Character set for the output of test reporting. * * @var string + * @access protected */ var $_character_set; /** @@ -153,7 +154,7 @@ class CakeHtmlReporter extends SimpleReporter { echo "
  • \n"; echo "Failed"; echo "
    " . $this->_htmlEntities($message) . "
    \n"; - $breadcrumb = Set::filter($this->getTestList()); + $breadcrumb = $this->getTestList(); array_shift($breadcrumb); echo "
    " . implode(" -> ", $breadcrumb) . "
    \n"; echo "
  • \n"; @@ -173,7 +174,7 @@ class CakeHtmlReporter extends SimpleReporter { if ($this->_show_passes) { echo "
  • \n"; echo "Passed "; - $breadcrumb = Set::filter($this->getTestList()); + $breadcrumb = $this->getTestList(); array_shift($breadcrumb); echo implode(" -> ", $breadcrumb); echo "
    " . $this->_htmlEntities($message) . "\n"; @@ -192,7 +193,7 @@ class CakeHtmlReporter extends SimpleReporter { echo "
  • \n"; echo "Error"; echo "
    " . $this->_htmlEntities($message) . "
    \n"; - $breadcrumb = Set::filter($this->getTestList()); + $breadcrumb = $this->getTestList(); array_shift($breadcrumb); echo "
    " . implode(" -> ", $breadcrumb) . "
    \n"; echo "
  • \n"; @@ -213,7 +214,7 @@ class CakeHtmlReporter extends SimpleReporter { '] in ['. $exception->getFile() . ' line ' . $exception->getLine() . ']'; echo "
    " . $this->_htmlEntities($message) . "
    \n"; - $breadcrumb = Set::filter($this->getTestList()); + $breadcrumb = $this->getTestList(); array_shift($breadcrumb); echo "
    " . implode(" -> ", $breadcrumb) . "
    \n"; echo "\n"; From f228990c58829d57251f8e307481908f0d38295c Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 20:56:25 -0500 Subject: [PATCH 053/137] Updating doc blocks. --- cake/tests/lib/reporter/cake_base_reporter.php | 1 + cake/tests/lib/reporter/cake_html_reporter.php | 12 ++++++++++-- cake/tests/lib/reporter/cake_text_reporter.php | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index ad1fd5bf0..f7275b15d 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -83,6 +83,7 @@ class CakeBaseReporter extends SimpleReporter { * but in a separate function to reduce dependancies. * * @return float Time in microseconds + * @access protected */ function _getTime() { list($usec, $sec) = explode(' ', microtime()); diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 97d0c15a9..6f7c699f0 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -87,6 +87,7 @@ class CakeHtmlReporter extends SimpleReporter { * title to the name of the starting test. * * @param string $test_name Name class of test. + * @return void * @access public */ function paintHeader($testName) { @@ -100,8 +101,8 @@ class CakeHtmlReporter extends SimpleReporter { * reloaded on every request. Otherwise you could be * scratching your head over out of date test data. * + * @return void * @access public - * @static */ function sendNoCacheHeaders() { if (!headers_sent()) { @@ -118,6 +119,7 @@ class CakeHtmlReporter extends SimpleReporter { * the passes and failures. * * @param string $test_name Name class of test. + * @return void * @access public */ function paintFooter($test_name) { @@ -147,6 +149,7 @@ class CakeHtmlReporter extends SimpleReporter { * * @param string $message Failure message displayed in * the context of the other tests. + * @return void * @access public */ function paintFail($message) { @@ -166,6 +169,7 @@ class CakeHtmlReporter extends SimpleReporter { * top level test. * * @param string $message Pass message displayed in the context of the other tests. + * @return void * @access public */ function paintPass($message) { @@ -186,6 +190,7 @@ class CakeHtmlReporter extends SimpleReporter { * Paints a PHP error. * * @param string $message Message is ignored. + * @return void * @access public */ function paintError($message) { @@ -203,6 +208,7 @@ class CakeHtmlReporter extends SimpleReporter { * Paints a PHP exception. * * @param Exception $exception Exception to display. + * @return void * @access public */ function paintException($exception) { @@ -223,7 +229,8 @@ class CakeHtmlReporter extends SimpleReporter { /** * Prints the message for skipping tests. * - * @param string $message Text of skip condition. + * @param string $message Text of skip condition. + * @return void * @access public */ function paintSkip($message) { @@ -238,6 +245,7 @@ class CakeHtmlReporter extends SimpleReporter { * Paints formatted text such as dumped variables. * * @param string $message Text to show. + * @return void * @access public */ function paintFormattedMessage($message) { diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index 70038f65c..6a4ff7b76 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -31,6 +31,7 @@ class CakeTextReporter extends CakeBaseReporter { * the passes and failures. * * @param string $test_name Name class of test. + * @return void * @access public */ function paintFooter($test_name) { @@ -54,6 +55,7 @@ class CakeTextReporter extends CakeBaseReporter { * Paints the title only. * * @param string $test_name Name class of test. + * @return void * @access public */ function paintHeader($test_name) { @@ -69,6 +71,7 @@ class CakeTextReporter extends CakeBaseReporter { * * @param string $message Failure message displayed in * the context of the other tests. + * @return void * @access public */ function paintFail($message) { @@ -84,6 +87,7 @@ class CakeTextReporter extends CakeBaseReporter { * Paints a PHP error. * * @param string $message Message to be shown. + * @return void * @access public */ function paintError($message) { @@ -99,6 +103,7 @@ class CakeTextReporter extends CakeBaseReporter { * Paints a PHP exception. * * @param Exception $exception Exception to describe. + * @return void * @access public */ function paintException($exception) { @@ -118,6 +123,7 @@ class CakeTextReporter extends CakeBaseReporter { * Prints the message for skipping tests. * * @param string $message Text of skip condition. + * @return void * @access public */ function paintSkip($message) { @@ -129,6 +135,7 @@ class CakeTextReporter extends CakeBaseReporter { * Paints formatted text such as dumped variables. * * @param string $message Text to show. + * @return void * @access public */ function paintFormattedMessage($message) { From 3c57dbee04ca1774fae1ae7cf07e6d4a282cb6e8 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 22:20:32 -0500 Subject: [PATCH 054/137] Refactoring methods from CakeTestMenu into CakeHtmlReporter. Updating CakeTestSuiteDispatcher to reflect removed methods. --- cake/tests/lib/cake_test_menu.php | 77 ------------------- cake/tests/lib/cake_test_suite_dispatcher.php | 11 +-- .../tests/lib/reporter/cake_html_reporter.php | 73 ++++++++++++++++-- 3 files changed, 71 insertions(+), 90 deletions(-) diff --git a/cake/tests/lib/cake_test_menu.php b/cake/tests/lib/cake_test_menu.php index 7099bca54..c2f920de9 100644 --- a/cake/tests/lib/cake_test_menu.php +++ b/cake/tests/lib/cake_test_menu.php @@ -18,83 +18,6 @@ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ class CakeTestMenu { -/** - * Provides the "Run More" links in the testsuite interface - * - * @return void - * @access public - */ - function runMore() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - if (isset($_GET['group'])) { - if (isset($_GET['app'])) { - $show = '?show=groups&app=true'; - } else if (isset($_GET['plugin'])) { - $show = '?show=groups&plugin=' . $_GET['plugin']; - } else { - $show = '?show=groups'; - } - $query = '?group='.$_GET['group']; - if (isset($_GET['app'])) { - $query .= '&app=true'; - } elseif (isset($_GET['plugin'])) { - $query .= '&plugin=' . $_GET['plugin']; - } - } - if (isset($_GET['case'])) { - if (isset($_GET['app'])) { - $show = '?show=cases&app=true'; - } else if (isset($_GET['plugin'])) { - $show = '?show=cases&plugin=' . $_GET['plugin']; - } else { - $show = '?show=cases'; - } - $query = '?case='.$_GET['case']; - if (isset($_GET['app'])) { - $query .= '&app=true'; - } elseif (isset($_GET['plugin'])) { - $query .= '&plugin=' . $_GET['plugin']; - } - } - ob_start(); - echo "

    Run more tests | Show Passes | \n"; - - break; - } - } - -/** - * Provides the links to analyzing code coverage - * - * @return void - * @access public - */ - function analyzeCodeCoverage() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - if (isset($_GET['case'])) { - $query = '?case=' . $_GET['case']; - if (isset($_GET['app'])) { - $query .= '&app=true'; - } elseif (isset($_GET['plugin'])) { - $query .= '&plugin=' . $_GET['plugin']; - } - } else { - $query = '?group='.$_GET['group']; - if (isset($_GET['app'])) { - $query .= '&app=true'; - } elseif (isset($_GET['plugin'])) { - $query .= '&plugin=' . $_GET['plugin']; - } - } - $query .= '&code_coverage=true'; - ob_start(); - echo " Analyze Code Coverage

    \n"; - - break; - } - } /** * Prints a list of test cases diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 29092a583..ebea5f42c 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -38,7 +38,8 @@ class CakeTestSuiteDispatcher { 'app' => false, 'plugin' => null, 'output' => 'html', - 'show' => 'groups' + 'show' => 'groups', + 'show_passes' => false ); /** @@ -143,9 +144,9 @@ class CakeTestSuiteDispatcher { $appClass = $this->params['output'] . 'Reporter'; $appFile = APPLIBS . 'test_suite' . DS . 'reporter' . DS . $type . '_reporter.php'; if (include_once $coreFile) { - $Reporter =& new $coreClass(); + $Reporter =& new $coreClass(null, $this->params); } elseif (include_once $appFile) { - $Reporter =& new $appClass(); + $Reporter =& new $appClass(null, $this->params); } } return $Reporter; @@ -191,8 +192,6 @@ class CakeTestSuiteDispatcher { CodeCoverageManager::report(); } } - CakeTestMenu::runMore(); - CakeTestMenu::analyzeCodeCoverage(); } /** @@ -211,8 +210,6 @@ class CakeTestSuiteDispatcher { if ($this->params['codeCoverage']) { CodeCoverageManager::report(); } - CakeTestMenu::runMore(); - CakeTestMenu::analyzeCodeCoverage(); } } ?> \ No newline at end of file diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 6f7c699f0..a24fb85aa 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -67,19 +67,33 @@ class CakeHtmlReporter extends SimpleReporter { */ var $_timeDuration = 0; +/** + * Array of request parameters. Usually parsed GET params. + * + * @var array + */ + var $params = array(); + /** * Does nothing yet. The first output will * be sent on the first test start. For use * by a web browser. * + * ### Params + * + * - show_passes - Should passes be shown + * - plugin - Plugin test being run? + * - app - App test being run. + * - case - The case being run + * + * @param string $character_set The character set to output with. Defaults to ISO-8859-1 + * @param array $params Array of request parameters the reporter should use. See above. * @access public */ - function CakeHtmlReporter($character_set = 'ISO-8859-1') { - if (isset($_GET['show_passes']) && $_GET['show_passes']) { - $this->_show_passes = true; - } + function CakeHtmlReporter($character_set = 'ISO-8859-1', $params = array()) { $this->SimpleReporter(); - $this->_character_set = $character_set; + $this->_character_set = !empty($character_set) ? $character_set : 'ISO-8859-1'; + $this->params = $params; } /** @@ -139,9 +153,56 @@ class CakeHtmlReporter extends SimpleReporter { if (function_exists('memory_get_peak_usage')) { echo '

    Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . '

    '; } + echo $this->_paintLinks(); echo ''; } +/** + * Renders the links that for accessing things in the test suite. + * + * @return void + */ + function _paintLinks() { + $show = $query = array(); + if (!empty($this->params['group'])) { + $show['show'] = 'groups'; + } elseif (!empty($this->params['case'])) { + $show['show'] = 'cases'; + } + + if (!empty($this->params['app'])) { + $show['app'] = $query['app'] = 'true'; + } + if (!empty($this->params['plugin'])) { + $show['plugin'] = $query['plugin'] = $this->params['plugin']; + } + if (!empty($this->params['case'])) { + $query['case'] = $this->params['case']; + } elseif (!empty($this->params['group'])) { + $query['group'] = $this->params['group']; + } + $show = $this->_queryString($show); + $query = $this->_queryString($query); + + echo "

    Run more tests | Show Passes | \n"; + echo " Analyze Code Coverage

    \n"; + } +/** + * Convert an array of parameters into a query string url + * + * @param array $url Url hash to be converted + * @return string Converted url query string + */ + function _queryString($url) { + $out = '?'; + $params = array(); + foreach ($url as $key => $value) { + $params[] = "$key=$value"; + } + $out .= implode('&', $params); + return $out; + } + /** * Paints the test failure with a breadcrumbs * trail of the nesting test suites below the @@ -175,7 +236,7 @@ class CakeHtmlReporter extends SimpleReporter { function paintPass($message) { parent::paintPass($message); - if ($this->_show_passes) { + if (isset($this->params['show_passes']) && $this->params['show_passes']) { echo "
  • \n"; echo "Passed "; $breadcrumb = $this->getTestList(); From 1e5923c75a49f86c2e006aab66ed480301363f68 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 22:51:39 -0500 Subject: [PATCH 055/137] Moving templates to templates dir. --- cake/tests/lib/cake_test_suite_dispatcher.php | 7 ++- cake/tests/lib/templates/content.php | 58 +++++++++++++++++++ cake/tests/lib/{ => templates}/footer.php | 0 cake/tests/lib/{ => templates}/header.php | 0 cake/tests/lib/{ => templates}/simpletest.php | 0 cake/tests/lib/{ => templates}/xdebug.php | 0 6 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 cake/tests/lib/templates/content.php rename cake/tests/lib/{ => templates}/footer.php (100%) rename cake/tests/lib/{ => templates}/header.php (100%) rename cake/tests/lib/{ => templates}/simpletest.php (100%) rename cake/tests/lib/{ => templates}/xdebug.php (100%) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index ebea5f42c..5de18820a 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -90,7 +90,7 @@ class CakeTestSuiteDispatcher { */ function _checkSimpleTest() { if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { - include CAKE_TESTS_LIB . 'simpletest.php'; + include CAKE_TESTS_LIB . 'templates' . DS . 'simpletest.php'; CakeTestMenu::footer(); exit(); } @@ -104,7 +104,7 @@ class CakeTestSuiteDispatcher { */ function _checkXdebug() { if (!extension_loaded('xdebug')) { - include CAKE_TESTS_LIB . 'xdebug.php'; + include CAKE_TESTS_LIB . 'templates' . DS . 'xdebug.php'; CakeTestMenu::footer(); exit(); } @@ -116,7 +116,7 @@ class CakeTestSuiteDispatcher { * @return string The manager class name * @static */ - function getManager() { + function &getManager() { $className = ucwords($this->params['output']) . 'TestManager'; if (class_exists($className)) { $this->_managerClass = $className; @@ -133,6 +133,7 @@ class CakeTestSuiteDispatcher { * Gets the reporter based on the request parameters * * @return void + * @static */ function &getReporter() { static $Reporter = NULL; diff --git a/cake/tests/lib/templates/content.php b/cake/tests/lib/templates/content.php new file mode 100644 index 000000000..8fd087474 --- /dev/null +++ b/cake/tests/lib/templates/content.php @@ -0,0 +1,58 @@ + + * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @package cake + * @subpackage cake.cake.tests.lib + * @since CakePHP(tm) v 1.2.0.4433 + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ +?> +
    + +
    +
    \ No newline at end of file diff --git a/cake/tests/lib/footer.php b/cake/tests/lib/templates/footer.php similarity index 100% rename from cake/tests/lib/footer.php rename to cake/tests/lib/templates/footer.php diff --git a/cake/tests/lib/header.php b/cake/tests/lib/templates/header.php similarity index 100% rename from cake/tests/lib/header.php rename to cake/tests/lib/templates/header.php diff --git a/cake/tests/lib/simpletest.php b/cake/tests/lib/templates/simpletest.php similarity index 100% rename from cake/tests/lib/simpletest.php rename to cake/tests/lib/templates/simpletest.php diff --git a/cake/tests/lib/xdebug.php b/cake/tests/lib/templates/xdebug.php similarity index 100% rename from cake/tests/lib/xdebug.php rename to cake/tests/lib/templates/xdebug.php From 44cacf6dad76d7f045efb5d54ad6b273a1b039d9 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 22:52:25 -0500 Subject: [PATCH 056/137] Adding stub methods for upcoming refactoring of menu generation. --- .../tests/lib/reporter/cake_base_reporter.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index f7275b15d..208e9ca10 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -90,4 +90,25 @@ class CakeBaseReporter extends SimpleReporter { return ((float)$sec + (float)$usec); } +/** + * Retrieves a list of test cases from the active Manager class, + * displaying it in the correct format for the reporter subclass + * + * @return mixed + */ + function testCaseList() { + + } + +/** + * Retrieves a list of group test cases from the active Manager class + * displaying it in the correct format for the reporter subclass. + * + * @return void + */ + function groupTestList() { + + } + } +?> \ No newline at end of file From 21afcef7cf07bb2b21047266d7eb46427faf1a47 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 5 Jan 2010 23:12:28 -0500 Subject: [PATCH 057/137] Updating CakeTestSuiteDispatcher to get base url and base dir. Refactoring xdebug and simpletest error pages. Starting to phase out CakeTestMenu. --- cake/tests/lib/cake_test_suite_dispatcher.php | 28 +++++++++++++++++-- cake/tests/lib/templates/header.php | 2 +- cake/tests/lib/templates/simpletest.php | 6 ++-- cake/tests/lib/templates/xdebug.php | 13 +++++---- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 5de18820a..9e5b2982f 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -56,6 +56,30 @@ class CakeTestSuiteDispatcher { */ var $Manager; +/** + * Baseurl for the request + * + * @var string + */ + var $_baseUrl; + +/** + * Base dir of the request. Used for accessing assets. + * + * @var string + */ + var $_baseDir; + +/** + * constructor + * + * @return void + */ + function CakeTestSuiteDispatcher() { + $this->_baseUrl = $_SERVER['PHP_SELF']; + $this->_baseDir = dirname($this->_baseUrl) . '/'; + } + /** * Runs the actions required by the URL parameters. * @@ -90,8 +114,8 @@ class CakeTestSuiteDispatcher { */ function _checkSimpleTest() { if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { + $baseUrl = $this->_baseDir; include CAKE_TESTS_LIB . 'templates' . DS . 'simpletest.php'; - CakeTestMenu::footer(); exit(); } } @@ -104,8 +128,8 @@ class CakeTestSuiteDispatcher { */ function _checkXdebug() { if (!extension_loaded('xdebug')) { + $baseUrl = $this->_baseDir; include CAKE_TESTS_LIB . 'templates' . DS . 'xdebug.php'; - CakeTestMenu::footer(); exit(); } } diff --git a/cake/tests/lib/templates/header.php b/cake/tests/lib/templates/header.php index ab521a69f..faf49f653 100644 --- a/cake/tests/lib/templates/header.php +++ b/cake/tests/lib/templates/header.php @@ -21,7 +21,7 @@ - + CakePHP Test Suite 1.3 - +
    From 4c0d90c50290d6fa403296171f4f46e0f81ed6c4 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 6 Jan 2010 22:52:04 -0500 Subject: [PATCH 063/137] Adding paintDocumentFooter and paintDocumentHeader to CakeBaseReporter and CakeHtmlReporter. Refactoring case list and group lists to use reporter methods. --- cake/tests/lib/cake_test_suite_dispatcher.php | 8 ++++++++ .../tests/lib/reporter/cake_base_reporter.php | 20 +++++++++++++++++++ .../tests/lib/reporter/cake_html_reporter.php | 14 +++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 44460719e..59365c818 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -136,7 +136,11 @@ class CakeTestSuiteDispatcher { * @return void */ function _testCaseList() { + $Reporter =& $this->getReporter(); + $Reporter->paintDocumentHeader(); + $Reporter->paintTestMenu(); CakeTestMenu::testCaseList(); + $Reporter->paintDocumentEnd(); } /** @@ -145,7 +149,11 @@ class CakeTestSuiteDispatcher { * @return void */ function _groupTestList() { + $Reporter =& $this->getReporter(); + $Reporter->paintDocumentHeader(); + $Reporter->paintTestMenu(); CakeTestMenu::groupTestList(); + $Reporter->paintDocumentEnd(); } /** diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index 208e9ca10..dca615863 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -107,6 +107,26 @@ class CakeBaseReporter extends SimpleReporter { * @return void */ function groupTestList() { + + } + +/** + * paints the header of the response from the test suite. + * Used to paint things like head elements in an html page. + * + * @return void + */ + function paintDocumentHeader() { + + } + +/** + * paints the end of the response from the test suite. + * Used to paint things like in an html page. + * + * @return void + */ + function paintDocumentFooter() { } diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 3d5206547..4bb8ea927 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -177,8 +177,7 @@ class CakeHtmlReporter extends SimpleReporter { } echo $this->_paintLinks(); echo '
    '; - $baseDir = $this->params['baseDir']; - include CAKE_TESTS_LIB . 'templates' . DS . 'footer.php'; + $this->paintDocumentEnd(); } /** @@ -211,6 +210,7 @@ class CakeHtmlReporter extends SimpleReporter { echo "

    Run more tests | Show Passes | \n"; echo " Analyze Code Coverage

    \n"; } + /** * Convert an array of parameters into a query string url * @@ -227,6 +227,16 @@ class CakeHtmlReporter extends SimpleReporter { return $out; } +/** + * paints the end of the document html. + * + * @return void + */ + function paintDocumentEnd() { + $baseDir = $this->params['baseDir']; + include CAKE_TESTS_LIB . 'templates' . DS . 'footer.php'; + } + /** * Paints the test failure with a breadcrumbs * trail of the nesting test suites below the From a0f5d0fc0214622a9473925e89d7fdd92532c14a Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 6 Jan 2010 23:02:37 -0500 Subject: [PATCH 064/137] Renaming menu template file. Refactoring logic from CakeTestMenu into the Reporters. --- cake/tests/lib/cake_test_menu.php | 18 ------ cake/tests/lib/cake_test_suite_dispatcher.php | 4 +- .../tests/lib/reporter/cake_html_reporter.php | 23 +++++++- cake/tests/lib/templates/content.php | 58 ------------------- .../lib/{content.php => templates/menu.php} | 4 +- 5 files changed, 26 insertions(+), 81 deletions(-) delete mode 100644 cake/tests/lib/templates/content.php rename cake/tests/lib/{content.php => templates/menu.php} (93%) diff --git a/cake/tests/lib/cake_test_menu.php b/cake/tests/lib/cake_test_menu.php index c2f920de9..3e7e262f8 100644 --- a/cake/tests/lib/cake_test_menu.php +++ b/cake/tests/lib/cake_test_menu.php @@ -84,24 +84,6 @@ class CakeTestMenu { } } -/** - * Provides the left hand navigation for the testsuite - * - * @return void - * @access public - */ - function testSuiteHeader() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - ob_start(); - $groups = $_SERVER['PHP_SELF'] . '?show=groups'; - $cases = $_SERVER['PHP_SELF'] . '?show=cases'; - $plugins = App::objects('plugin'); - include CAKE_TESTS_LIB . 'content.php'; - break; - } - } - /** * Provides the testsuite footer text * diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 59365c818..26b5068ba 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -139,7 +139,7 @@ class CakeTestSuiteDispatcher { $Reporter =& $this->getReporter(); $Reporter->paintDocumentHeader(); $Reporter->paintTestMenu(); - CakeTestMenu::testCaseList(); + $Reporter->testCaseList(); $Reporter->paintDocumentEnd(); } @@ -152,7 +152,7 @@ class CakeTestSuiteDispatcher { $Reporter =& $this->getReporter(); $Reporter->paintDocumentHeader(); $Reporter->paintTestMenu(); - CakeTestMenu::groupTestList(); + $Reporter->groupTestList(); $Reporter->paintDocumentEnd(); } diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 4bb8ea927..3a256333f 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -129,7 +129,28 @@ class CakeHtmlReporter extends SimpleReporter { * @return void */ function paintTestMenu() { - CakeTestMenu::testSuiteHeader(); + $groups = $_SERVER['PHP_SELF'] . '?show=groups'; + $cases = $_SERVER['PHP_SELF'] . '?show=cases'; + $plugins = App::objects('plugin'); + include CAKE_TESTS_LIB . 'templates' . DS . 'menu.php'; + } + +/** + * Retrieves and paints the list of tests cases in an HTML format. + * + * @return void + */ + function testCaseList() { + CakeTestMenu::testCaseList(); + } + +/** + * Retrieves and paints the list of group tests in an HTML format. + * + * @return void + */ + function groupTestList() { + CakeTestMenu::groupTestList(); } /** diff --git a/cake/tests/lib/templates/content.php b/cake/tests/lib/templates/content.php deleted file mode 100644 index 8fd087474..000000000 --- a/cake/tests/lib/templates/content.php +++ /dev/null @@ -1,58 +0,0 @@ - - * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) - * - * Licensed under The Open Group Test Suite License - * Redistributions of files must retain the above copyright notice. - * - * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) - * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.lib - * @since CakePHP(tm) v 1.2.0.4433 - * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License - */ -?> -
    - -
    -
    \ No newline at end of file diff --git a/cake/tests/lib/content.php b/cake/tests/lib/templates/menu.php similarity index 93% rename from cake/tests/lib/content.php rename to cake/tests/lib/templates/menu.php index 8fd087474..2a5b86219 100644 --- a/cake/tests/lib/content.php +++ b/cake/tests/lib/templates/menu.php @@ -21,7 +21,7 @@
    • - App + App
      • Test Groups
      • Test Cases
      • @@ -31,7 +31,7 @@ if (!empty($plugins)): ?>
      • - Plugins + Plugins From 61079f63174e21e670b0a9efe6296524c45a52f5 Mon Sep 17 00:00:00 2001 From: tPl0ch Date: Thu, 7 Jan 2010 21:15:10 +0100 Subject: [PATCH 065/137] Fixes #42. Updated Sanitize::clean() with 'remove_html' option. Updated Sanitize::html() to accept new options. Updated test cases. Signed-off-by: Mark Story --- cake/libs/sanitize.php | 37 +++++++++++++++++++------ cake/tests/cases/libs/sanitize.test.php | 28 ++++++++++++++----- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index 8edb7b8d4..533f52556 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -79,22 +79,40 @@ class Sanitize { /** * Returns given string safe for display as HTML. Renders entities. + * + * strip_tags() is not validating HTML, so it might strip whole passages + * with broken HTML. * * @param string $string String from where to strip tags - * @param boolean $remove If true, the string is stripped of all HTML tags + * @param array $options + * + * possible options: + * + * - remove (boolean) if true strips all HTML tags before encoding + * - charset (string) the charset used to encode the string + * - quotes (int) see http://php.net/manual/en/function.htmlentities.php + * * @return string Sanitized string * @access public * @static */ - function html($string, $remove = false) { - if ($remove) { + function html($string, $options = array()) { + $default = array( + 'remove' => false, + 'charset' => 'UTF-8', + 'quotes' => ENT_QUOTES + ); + + $options = array_merge($default, $options); + + if ($options['remove']) { $string = strip_tags($string); - } else { - $patterns = array('&', '%', '<', '>', '"', "'", '(', ')', '+', '-'); - $replacements = array("&", "%", "<", ">", """, "'", "(", ")", "+", "-"); - $string = str_replace($patterns, $replacements, $string); } - return $string; + $encoding = Configure::read('App.encoding'); + if (empty($encoding)) { + $encoding = $options['charset']; + } + return htmlentities($string, $options['quotes'], $encoding); } /** @@ -198,6 +216,7 @@ class Sanitize { $options = array_merge(array( 'connection' => 'default', 'odd_spaces' => true, + 'remove_html' => false, 'encode' => true, 'dollar' => true, 'carriage' => true, @@ -216,7 +235,7 @@ class Sanitize { $data = str_replace(chr(0xCA), '', str_replace(' ', ' ', $data)); } if ($options['encode']) { - $data = Sanitize::html($data); + $data = Sanitize::html($data, array('remove' => $options['remove_html'])); } if ($options['dollar']) { $data = str_replace("\\\$", "$", $data); diff --git a/cake/tests/cases/libs/sanitize.test.php b/cake/tests/cases/libs/sanitize.test.php index 49b023b77..8a6f7c325 100644 --- a/cake/tests/cases/libs/sanitize.test.php +++ b/cake/tests/cases/libs/sanitize.test.php @@ -145,7 +145,7 @@ class SanitizeTest extends CakeTestCase { */ function testClean() { $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; - $expected = 'test & "quote" 'other' ;.$ symbol.another line'; + $expected = 'test & "quote" 'other' ;.$ symbol.another line'; $result = Sanitize::clean($string, array('connection' => 'test_suite')); $this->assertEqual($result, $expected); @@ -170,7 +170,7 @@ class SanitizeTest extends CakeTestCase { $this->assertEqual($result, $expected); $array = array(array('test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line')); - $expected = array(array('test & "quote" 'other' ;.$ symbol.another line')); + $expected = array(array('test & "quote" 'other' ;.$ symbol.another line')); $result = Sanitize::clean($array, array('connection' => 'test_suite')); $this->assertEqual($result, $expected); @@ -179,8 +179,8 @@ class SanitizeTest extends CakeTestCase { $result = Sanitize::clean($array, array('encode' => false, 'escape' => false, 'connection' => 'test_suite')); $this->assertEqual($result, $expected); - $array = array(array('test odd '.chr(0xCA).' spaces'.chr(0xCA))); - $expected = array(array('test odd '.chr(0xCA).' spaces'.chr(0xCA))); + $array = array(array('test odd Ä spacesé')); + $expected = array(array('test odd Ä spacesé')); $result = Sanitize::clean($array, array('odd_spaces' => false, 'escape' => false, 'connection' => 'test_suite')); $this->assertEqual($result, $expected); @@ -203,12 +203,26 @@ class SanitizeTest extends CakeTestCase { */ function testHtml() { $string = '

        This is a test string & so is this

        '; - $expected = 'This is a test string & so is this'; - $result = Sanitize::html($string, true); + $expected = 'This is a test string & so is this'; + $result = Sanitize::html($string, array('remove' => true)); $this->assertEqual($result, $expected); $string = 'The "lazy" dog \'jumped\' & flew over the moon. If (1+1) = 2 is true, (2-1) = 1 is also true'; - $expected = 'The "lazy" dog 'jumped' & flew over the moon. If (1+1) = 2 <em>is</em> true, (2-1) = 1 is also true'; + $expected = 'The "lazy" dog 'jumped' & flew over the moon. If (1+1) = 2 <em>is</em> true, (2-1) = 1 is also true'; + $result = Sanitize::html($string); + $this->assertEqual($result, $expected); + + $string = 'The "lazy" dog \'jumped\''; + $expected = 'The "lazy" dog \'jumped\''; + $result = Sanitize::html($string, array('quotes' => ENT_COMPAT)); + $this->assertEqual($result, $expected); + + $string = 'The "lazy" dog \'jumped\''; + $result = Sanitize::html($string, array('quotes' => ENT_NOQUOTES)); + $this->assertEqual($result, $string); + + $string = 'The "lazy" dog \'jumped\' & flew over the moon. If (1+1) = 2 is true, (2-1) = 1 is also true'; + $expected = 'The "lazy" dog 'jumped' & flew over the moon. If (1+1) = 2 <em>is</em> true, (2-1) = 1 is also true'; $result = Sanitize::html($string); $this->assertEqual($result, $expected); } From b47b858355c73845cbeb6b24e3060288930da9a3 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 7 Jan 2010 21:47:23 -0500 Subject: [PATCH 066/137] Updating and reformatting docs for Sanitize. --- cake/libs/sanitize.php | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index 533f52556..9492acbdb 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -35,6 +35,7 @@ class Sanitize { * Removes any non-alphanumeric characters. * * @param string $string String to sanitize + * @param array $allowed An array of additional characters that are not to be removed. * @return string Sanitized string * @access public * @static @@ -80,18 +81,17 @@ class Sanitize { /** * Returns given string safe for display as HTML. Renders entities. * - * strip_tags() is not validating HTML, so it might strip whole passages + * strip_tags() does not validating HTML syntax or structure, so it might strip whole passages * with broken HTML. * + * ### Options: + * + * - remove (boolean) if true strips all HTML tags before encoding + * - charset (string) the charset used to encode the string + * - quotes (int) see http://php.net/manual/en/function.htmlentities.php + * * @param string $string String from where to strip tags - * @param array $options - * - * possible options: - * - * - remove (boolean) if true strips all HTML tags before encoding - * - charset (string) the charset used to encode the string - * - quotes (int) see http://php.net/manual/en/function.htmlentities.php - * + * @param array $options Array of options to use. * @return string Sanitized string * @access public * @static @@ -173,6 +173,10 @@ class Sanitize { * Strips the specified tags from output. First parameter is string from * where to remove tags. All subsequent parameters are tags. * + * Ex.`$clean = Sanitize::stripTags($dirty, 'b', 'p', 'div');` + * + * Will remove all ``, `

        `, and `

        ` tags from the $dirty string. + * * @param string $str String to sanitize * @param string $tag Tag to remove (add more parameters as needed) * @return string sanitized String @@ -193,8 +197,16 @@ class Sanitize { /** * Sanitizes given array or value for safe input. Use the options to specify * the connection to use, and what filters should be applied (with a boolean - * value). Valid filters: odd_spaces, encode, dollar, carriage, unicode, - * escape, backslash. + * value). Valid filters: + * + * - odd_spaces - removes any non space whitespace characters + * - encode - Encode any html entities. Encode must be true for the `remove_html` to work. + * - dollar - Escape `$` with `\$` + * - carriage - Remove `\r` + * - unicode - + * - escape - Should the string be SQL escaped. + * - backslash - + * - remove_html - Strip HTML with strip_tags. `encode` must be true for this option to work. * * @param mixed $data Data to sanitize * @param mixed $options If string, DB connection being used, otherwise set of options From bc2dd3c987330430d226bcbeefb40b14c8877615 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 09:29:28 -0500 Subject: [PATCH 067/137] Removing refactored header and footer. --- cake/tests/lib/cake_test_menu.php | 43 ------------------------------- 1 file changed, 43 deletions(-) diff --git a/cake/tests/lib/cake_test_menu.php b/cake/tests/lib/cake_test_menu.php index 3e7e262f8..809477fd1 100644 --- a/cake/tests/lib/cake_test_menu.php +++ b/cake/tests/lib/cake_test_menu.php @@ -56,48 +56,5 @@ class CakeTestMenu { } } -/** - * Includes the Testsuite Header - * - * @return void - * @access public - */ - function testHeader() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - ob_start(); - if (!class_exists('dispatcher')) { - require CAKE . 'dispatcher.php'; - } - $dispatch =& new Dispatcher(); - $dispatch->baseUrl(); - define('BASE', $dispatch->webroot); - $baseUrl = BASE; - $characterSet = 'charset=utf-8'; - include CAKE_TESTS_LIB . 'header.php'; - - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - header('content-type: text/plain'); - break; - } - } - -/** - * Provides the testsuite footer text - * - * @return void - * @access public - */ - function footer() { - switch ( CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - ob_start(); - $baseUrl = BASE; - include CAKE_TESTS_LIB . 'footer.php'; - break; - } - } } ?> \ No newline at end of file From c529d3c6e9d5fb80725c852ad20bfa429781fff4 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 10:55:58 -0500 Subject: [PATCH 068/137] Refactoring test case list output generation into Reporters. --- .../tests/lib/reporter/cake_base_reporter.php | 6 +- .../tests/lib/reporter/cake_html_reporter.php | 56 ++++++++++--------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index dca615863..89a7c5a08 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -97,7 +97,8 @@ class CakeBaseReporter extends SimpleReporter { * @return mixed */ function testCaseList() { - + $testList = TestManager::getTestCaseList(); + return $testList; } /** @@ -107,7 +108,8 @@ class CakeBaseReporter extends SimpleReporter { * @return void */ function groupTestList() { - + $testList = TestManager::getGroupTestList(); + return $testList; } /** diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 3a256333f..a1bdd8902 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -26,7 +26,7 @@ include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; * @package cake * @subpackage cake.tests.lib */ -class CakeHtmlReporter extends SimpleReporter { +class CakeHtmlReporter extends CakeBaseReporter { /** * Character set for the output of test reporting. @@ -43,30 +43,6 @@ class CakeHtmlReporter extends SimpleReporter { */ var $_show_passes = false; -/** - * Time the test runs started. - * - * @var integer - * @access protected - */ - var $_timeStart = 0; - -/** - * Time the test runs ended - * - * @var integer - * @access protected - */ - var $_timeEnd = 0; - -/** - * Duration of all test methods. - * - * @var integer - * @access protected - */ - var $_timeDuration = 0; - /** * Array of request parameters. Usually parsed GET params. * @@ -94,6 +70,7 @@ class CakeHtmlReporter extends SimpleReporter { $this->SimpleReporter(); $this->_character_set = !empty($character_set) ? $character_set : 'ISO-8859-1'; $this->params = $params; + $this->_url = $_SERVER['PHP_SELF']; } /** @@ -141,7 +118,34 @@ class CakeHtmlReporter extends SimpleReporter { * @return void */ function testCaseList() { - CakeTestMenu::testCaseList(); + $testCases = parent::testCaseList(); + $app = $this->params['app']; + $plugin = $this->params['plugin']; + + $buffer = "

        Core Test Cases:

        \n
          "; + $urlExtra = null; + if ($app) { + $buffer = "

          App Test Cases:

          \n
            "; + $urlExtra = '&app=true'; + } elseif ($plugin) { + $buffer = "

            " . Inflector::humanize($plugin) . " Test Cases:

            \n
              "; + $urlExtra = '&plugin=' . $plugin; + } + + if (1 > count($testCases)) { + $buffer .= "EMPTY"; + echo $buffer; + } + + foreach ($testCases as $testCaseFile => $testCase) { + $title = explode(strpos($testCase, '\\') ? '\\' : '/', str_replace('.test.php', '', $testCase)); + $title[count($title) - 1] = Inflector::camelize($title[count($title) - 1]); + $title = implode(' / ', $title); + + $buffer .= "
            • " . $title . "
            • \n"; + } + $buffer .= "
            \n"; + echo $buffer; } /** From bdc84cd5d0ab34eedaf8699ccf436edeab519495 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 11:20:47 -0500 Subject: [PATCH 069/137] Renaming paintDocumentHeader to paintDocumentStart Renaming paintDocumentFooter to paintDocumentEnd Moving features from CakeTestMenu, HtmlTestManager, and TextTestManager into the appropriate Reporters. --- cake/tests/lib/cake_test_suite_dispatcher.php | 4 +- .../tests/lib/reporter/cake_base_reporter.php | 66 +++++++++++++- .../tests/lib/reporter/cake_html_reporter.php | 89 +++++++------------ .../tests/lib/reporter/cake_text_reporter.php | 40 ++++++++- 4 files changed, 132 insertions(+), 67 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 26b5068ba..52da314c7 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -137,7 +137,7 @@ class CakeTestSuiteDispatcher { */ function _testCaseList() { $Reporter =& $this->getReporter(); - $Reporter->paintDocumentHeader(); + $Reporter->paintDocumentStart(); $Reporter->paintTestMenu(); $Reporter->testCaseList(); $Reporter->paintDocumentEnd(); @@ -150,7 +150,7 @@ class CakeTestSuiteDispatcher { */ function _groupTestList() { $Reporter =& $this->getReporter(); - $Reporter->paintDocumentHeader(); + $Reporter->paintDocumentStart(); $Reporter->paintTestMenu(); $Reporter->groupTestList(); $Reporter->paintDocumentEnd(); diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index 89a7c5a08..0bedcc9b5 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -50,6 +50,42 @@ class CakeBaseReporter extends SimpleReporter { */ var $_timeDuration = 0; +/** + * Array of request parameters. Usually parsed GET params. + * + * @var array + */ + var $params = array(); + +/** + * Character set for the output of test reporting. + * + * @var string + * @access protected + */ + var $_characterSet; + +/** + * Does nothing yet. The first output will + * be sent on the first test start. + * + * ### Params + * + * - show_passes - Should passes be shown + * - plugin - Plugin test being run? + * - app - App test being run. + * - case - The case being run + * + * @param string $charset The character set to output with. Defaults to UTF-8 + * @param array $params Array of request parameters the reporter should use. See above. + * @access public + */ + function CakeBaseReporter($charset = 'utf-8', $params = array()) { + $this->SimpleReporter(); + $this->_characterSet = $charset; + $this->params = $params; + } + /** * Signals / Paints the beginning of a TestSuite executing. * Starts the timer for the TestSuite execution time. @@ -113,24 +149,46 @@ class CakeBaseReporter extends SimpleReporter { } /** - * paints the header of the response from the test suite. + * Paints the start of the response from the test suite. * Used to paint things like head elements in an html page. * * @return void */ - function paintDocumentHeader() { + function paintDocumentStart() { } /** - * paints the end of the response from the test suite. + * Paints the end of the response from the test suite. * Used to paint things like in an html page. * * @return void */ - function paintDocumentFooter() { + function paintDocumentEnd() { } +/** + * Paint a list of test sets, core, app, and plugin test sets + * available. + * + * @return void + */ + function paintTestMenu() { + + } + +/** + * Get the baseUrl if one is available. + * + * @return string The base url for the request. + */ + function baseUrl() { + if (!empty($_SERVER['PHP_SELF'])) { + return $_SERVER['PHP_SELF']; + } + return ''; + } + } ?> \ No newline at end of file diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index a1bdd8902..9c9cbbfdf 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -28,51 +28,6 @@ include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; */ class CakeHtmlReporter extends CakeBaseReporter { -/** - * Character set for the output of test reporting. - * - * @var string - * @access protected - */ - var $_character_set; -/** - * Toggle to show passes in output. - * - * @var boolean - * @access protected - */ - var $_show_passes = false; - -/** - * Array of request parameters. Usually parsed GET params. - * - * @var array - */ - var $params = array(); - -/** - * Does nothing yet. The first output will - * be sent on the first test start. For use - * by a web browser. - * - * ### Params - * - * - show_passes - Should passes be shown - * - plugin - Plugin test being run? - * - app - App test being run. - * - case - The case being run - * - * @param string $character_set The character set to output with. Defaults to ISO-8859-1 - * @param array $params Array of request parameters the reporter should use. See above. - * @access public - */ - function CakeHtmlReporter($character_set = 'ISO-8859-1', $params = array()) { - $this->SimpleReporter(); - $this->_character_set = !empty($character_set) ? $character_set : 'ISO-8859-1'; - $this->params = $params; - $this->_url = $_SERVER['PHP_SELF']; - } - /** * Paints the top of the web page setting the * title to the name of the starting test. @@ -83,18 +38,18 @@ class CakeHtmlReporter extends CakeBaseReporter { */ function paintHeader($testName) { $this->sendNoCacheHeaders(); - $this->paintDocumentHeader(); + $this->paintDocumentStart(); $this->paintTestMenu(); echo "

            $testName

            \n"; echo "
              \n"; } /** - * Paints the document header contained in header.php + * Paints the document start content contained in header.php * * @return void */ - function paintDocumentHeader() { + function paintDocumentStart() { $baseDir = $this->params['baseDir']; include CAKE_TESTS_LIB . 'templates' . DS . 'header.php'; } @@ -106,8 +61,8 @@ class CakeHtmlReporter extends CakeBaseReporter { * @return void */ function paintTestMenu() { - $groups = $_SERVER['PHP_SELF'] . '?show=groups'; - $cases = $_SERVER['PHP_SELF'] . '?show=cases'; + $groups = $this->baseUrl() . '?show=groups'; + $cases = $this->baseUrl() . '?show=cases'; $plugins = App::objects('plugin'); include CAKE_TESTS_LIB . 'templates' . DS . 'menu.php'; } @@ -134,15 +89,13 @@ class CakeHtmlReporter extends CakeBaseReporter { if (1 > count($testCases)) { $buffer .= "EMPTY"; - echo $buffer; } foreach ($testCases as $testCaseFile => $testCase) { $title = explode(strpos($testCase, '\\') ? '\\' : '/', str_replace('.test.php', '', $testCase)); $title[count($title) - 1] = Inflector::camelize($title[count($title) - 1]); $title = implode(' / ', $title); - - $buffer .= "
            • " . $title . "
            • \n"; + $buffer .= "
            • " . $title . "
            • \n"; } $buffer .= "
            \n"; echo $buffer; @@ -154,7 +107,27 @@ class CakeHtmlReporter extends CakeBaseReporter { * @return void */ function groupTestList() { - CakeTestMenu::groupTestList(); + $groupTests = parent::groupTestList(); + $app = $this->params['app']; + $plugin = $this->params['plugin']; + + $buffer = "

            Core Test Groups:

            \n
              "; + $urlExtra = null; + if ($app) { + $buffer = "

              App Test Groups:

              \n
                "; + $urlExtra = '&app=true'; + } else if ($plugin) { + $buffer = "

                " . Inflector::humanize($plugin) . " Test Groups:

                \n
                  "; + $urlExtra = '&plugin=' . $plugin; + } + + $buffer .= "
                • All tests
                • \n"; + + foreach ($groupTests as $groupTest) { + $buffer .= "
                • " . $groupTest . "
                • \n"; + } + $buffer .= "
                \n"; + echo $buffer; } /** @@ -232,8 +205,8 @@ class CakeHtmlReporter extends CakeBaseReporter { $show = $this->_queryString($show); $query = $this->_queryString($query); - echo "

                Run more tests | Show Passes | \n"; - echo " Analyze Code Coverage

                \n"; + echo "

                Run more tests | Show Passes | \n"; + echo " Analyze Code Coverage

                \n"; } /** @@ -253,7 +226,7 @@ class CakeHtmlReporter extends CakeBaseReporter { } /** - * paints the end of the document html. + * Paints the end of the document html. * * @return void */ @@ -380,7 +353,7 @@ class CakeHtmlReporter extends CakeBaseReporter { * @access protected */ function _htmlEntities($message) { - return htmlentities($message, ENT_COMPAT, $this->_character_set); + return htmlentities($message, ENT_COMPAT, $this->_characterSet); } } ?> \ No newline at end of file diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index 6a4ff7b76..4c3bf6c87 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -26,6 +26,7 @@ include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; * @subpackage cake.tests.lib */ class CakeTextReporter extends CakeBaseReporter { + /** * Paints the end of the test with a summary of * the passes and failures. @@ -59,9 +60,7 @@ class CakeTextReporter extends CakeBaseReporter { * @access public */ function paintHeader($test_name) { - if (! SimpleReporter::inCli()) { - header('Content-type: text/plain'); - } + header('Content-type: text/plain'); echo "$test_name\n"; flush(); } @@ -142,5 +141,40 @@ class CakeTextReporter extends CakeBaseReporter { echo "$message\n"; flush(); } + +/** + * Generate a test case list in plain text. + * Creates as series of url's for tests that can be run. + * One case per line. + * + * @return void + */ + function testCaseList() { + $testCases = parent::testCaseList(); + $app = $this->params['app']; + $plugin = $this->params['plugin']; + + $buffer = "Core Test Cases:\n"; + $urlExtra = ''; + if ($app) { + $buffer = "App Test Cases:\n"; + $urlExtra = '&app=true'; + } elseif ($plugin) { + $buffer = Inflector::humanize($plugin) . " Test Cases:\n"; + $urlExtra = '&plugin=' . $plugin; + } + + if (1 > count($testCases)) { + $buffer .= "EMPTY"; + echo $buffer; + } + + foreach ($testCases as $testCaseFile => $testCase) { + $buffer .= $_SERVER['SERVER_NAME'] . $this->baseUrl() ."?case=" . $testCase . "&output=text"."\n"; + } + + $buffer .= "\n"; + echo $buffer; + } } ?> \ No newline at end of file From 28ad1ea1c2aff03fcd3a19f8c85126dc21881240 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 11:24:52 -0500 Subject: [PATCH 070/137] Removing constants from app/webroot/test.php as they are no longer needed. --- app/webroot/test.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/webroot/test.php b/app/webroot/test.php index 28c4a9430..7bdd62463 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -89,21 +89,6 @@ if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.', true)); } -/** - * - * Used to determine output to display - */ -define('CAKE_TEST_OUTPUT_HTML', 1); -define('CAKE_TEST_OUTPUT_TEXT', 2); - -if (!isset($_GET['output']) || (isset($_GET['output']) && $_GET['output'] == 'html')) { - define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML); -} else { - Debugger::output('txt'); - define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT); -} -define('RUN_TEST_LINK', $_SERVER['PHP_SELF']); - require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php'; $Dispatcher = new CakeTestSuiteDispatcher(); From e061a5335845feeb0e3371c2524b3097ed27ca68 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 11:25:35 -0500 Subject: [PATCH 071/137] Removing CakeTestMenu as its been made obsolete. Removing constant use from reporter. --- cake/tests/lib/cake_test_menu.php | 60 ------------------- cake/tests/lib/cake_test_suite_dispatcher.php | 1 - .../tests/lib/reporter/cake_html_reporter.php | 2 +- 3 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 cake/tests/lib/cake_test_menu.php diff --git a/cake/tests/lib/cake_test_menu.php b/cake/tests/lib/cake_test_menu.php deleted file mode 100644 index 809477fd1..000000000 --- a/cake/tests/lib/cake_test_menu.php +++ /dev/null @@ -1,60 +0,0 @@ - - * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) - * - * Licensed under The Open Group Test Suite License - * Redistributions of files must retain the above copyright notice. - * - * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) - * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.lib - * @since CakePHP(tm) v 1.3 - * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License - */ -class CakeTestMenu { - -/** - * Prints a list of test cases - * - * @return void - * @access public - */ - function testCaseList() { - $class = CakeTestMenu::getTestManager(); - echo call_user_func(array($class, 'getTestCaseList')); - } - -/** - * Prints a list of group tests - * - * @return void - * @access public - */ - function groupTestList() { - $class = CakeTestMenu::getTestManager(); - echo call_user_func(array($class, 'getGroupTestList')); - } - -/** - * Gets the correct test manager for the chosen output. - * - * @return void - */ - function getTestManager() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - return 'HtmlTestManager'; - case CAKE_TEST_OUTPUT_TEXT: - default: - return 'TextTestManager'; - } - } - -} -?> \ No newline at end of file diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 52da314c7..7523c6b45 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -18,7 +18,6 @@ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ require_once CAKE_TESTS_LIB . 'test_manager.php'; -require_once CAKE_TESTS_LIB . 'cake_test_menu.php'; /** * CakeTestSuiteDispatcher handles web requests to the test suite and runs the correct action. diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 9c9cbbfdf..1e272209b 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -205,7 +205,7 @@ class CakeHtmlReporter extends CakeBaseReporter { $show = $this->_queryString($show); $query = $this->_queryString($query); - echo "

                Run more tests | Show Passes | \n"; + echo "

                Run more tests | Show Passes | \n"; echo " Analyze Code Coverage

                \n"; } From 88f58dfbe8aa187b2a381d5be70e7ae594de1b77 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 19:19:09 -0500 Subject: [PATCH 072/137] Fixing missing headers when in plain text reporting. --- cake/tests/lib/reporter/cake_text_reporter.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index 4c3bf6c87..dd793a475 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -27,6 +27,17 @@ include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; */ class CakeTextReporter extends CakeBaseReporter { +/** + * Sets the text/plain header if the test is not a CLI test. + * + * @return void + */ + function paintDocumentStart() { + if (!SimpleReporter::inCli()) { + header('Content-type: text/plain'); + } + } + /** * Paints the end of the test with a summary of * the passes and failures. @@ -52,6 +63,7 @@ class CakeTextReporter extends CakeBaseReporter { echo 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n"; } } + /** * Paints the title only. * @@ -60,7 +72,6 @@ class CakeTextReporter extends CakeBaseReporter { * @access public */ function paintHeader($test_name) { - header('Content-type: text/plain'); echo "$test_name\n"; flush(); } From f567d9aacc74929107d340050ef22255361ef726 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 19:35:01 -0500 Subject: [PATCH 073/137] Removing unnecessary TestManager subclasses --- cake/tests/lib/cake_test_suite_dispatcher.php | 8 +- cake/tests/lib/test_manager.php | 189 ------------------ 2 files changed, 1 insertion(+), 196 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 7523c6b45..1b671204d 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -46,7 +46,7 @@ class CakeTestSuiteDispatcher { * * @var string */ - var $_managerClass; + var $_managerClass = 'TestManager'; /** * The Instance of the Manager being used. @@ -162,12 +162,6 @@ class CakeTestSuiteDispatcher { * @static */ function &getManager() { - $className = ucwords($this->params['output']) . 'TestManager'; - if (class_exists($className)) { - $this->_managerClass = $className; - } else { - $this->_managerClass = 'TextTestManager'; - } if (empty($this->Manager)) { $this->Manager = new $this->_managerClass(); } diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 7181f7465..09a3572cd 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -449,193 +449,4 @@ class CliTestManager extends TestManager { } } -/** - * The TextTestManager ensures that the list of available tests is printed as a list of urls in a text-friendly format - * - * @package cake - * @subpackage cake.cake.tests.lib - */ -class TextTestManager extends TestManager { - var $_url; - -/** - * Constructor - * - * @return void - * @access public - */ - function TextTestManager() { - parent::TestManager(); - $this->_url = $_SERVER['PHP_SELF']; - } - -/** - * Returns the base url - * - * @return string The base URL for link building. - * @access public - */ - function getBaseURL() { - return $this->_url; - } - -/** - * Returns a list of available group tests in a text-friendly format - * - * @return string A link list for group tests. - * @access public - */ - function &getGroupTestList() { - $manager =& new TextTestManager(); - $groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups')); - - $buffer = "Core Test Groups:\n"; - $urlExtra = ''; - if ($manager->appTest) { - $buffer = "App Test Groups:\n"; - $urlExtra = '&app=true'; - } else if ($manager->pluginTest) { - $buffer = Inflector::humanize($manager->pluginTest) . " Test Groups:\n"; - $urlExtra = '&plugin=' . $manager->pluginTest; - } - - $buffer .= "All tests\n" . $_SERVER['SERVER_NAME'] . $manager->getBaseURL() . "?group=all&output=txt{$urlExtra}\n"; - - foreach ((array)$groupTests as $groupTest) { - $buffer .= $_SERVER['SERVER_NAME'] . $manager->getBaseURL() . "?group=" . $groupTest . "&output=text{$urlExtra}\n"; - } - - return $buffer; - } - -/** - * Returns a list of available test cases in a text-friendly format - * - * @param string A link list for test cases. - * @access public - */ - function &getTestCaseList() { - $manager =& new TextTestManager(); - $testCases =& $manager->_getTestCaseList($manager->_getTestsPath()); - - $buffer = "Core Test Cases:\n"; - $urlExtra = ''; - if ($manager->appTest) { - $buffer = "App Test Cases:\n"; - $urlExtra = '&app=true'; - } else if ($manager->pluginTest) { - $buffer = Inflector::humanize($manager->pluginTest) . " Test Cases:\n"; - $urlExtra = '&plugin=' . $manager->pluginTest; - } - - if (1 > count($testCases)) { - $buffer .= "EMPTY"; - return $buffer; - } - - foreach ($testCases as $testCaseFile => $testCase) { - $buffer .= $_SERVER['SERVER_NAME']. $manager->getBaseURL()."?case=" . $testCase . "&output=text"."\n"; - } - - $buffer .= "\n"; - return $buffer; - } -} - -/** - * The HtmlTestManager provides the foundation for the web-based CakePHP testsuite. - * It prints the different lists of tests and provides the interface for CodeCoverage, etc. - * - * @package cake - * @subpackage cake.cake.tests.lib - */ -class HtmlTestManager extends TestManager { - var $_url; - -/** - * Constructor - * - * @return void - * @access public - */ - function HtmlTestManager() { - parent::TestManager(); - $this->_url = $_SERVER['PHP_SELF']; - } - -/** - * Returns the current base url - * - * @return void - * @access public - */ - function getBaseURL() { - return $this->_url; - } - -/** - * Prints the links to the available group tests - * - * @access public - */ - function &getGroupTestList() { - $manager =& new HtmlTestManager(); - $urlExtra = ''; - $groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups')); - - $buffer = "

                Core Test Groups:

                \n
                  "; - $urlExtra = null; - if ($manager->appTest) { - $buffer = "

                  App Test Groups:

                  \n
                    "; - $urlExtra = '&app=true'; - } else if ($manager->pluginTest) { - $buffer = "

                    " . Inflector::humanize($manager->pluginTest) . " Test Groups:

                    \n
                      "; - $urlExtra = '&plugin=' . $manager->pluginTest; - } - - $buffer .= "
                    • All tests
                    • \n"; - - foreach ($groupTests as $groupTest) { - $buffer .= "
                    • " . $groupTest . "
                    • \n"; - } - $buffer .= "
                    \n"; - return $buffer; - } - -/** - * Prints the links to the available test cases - * - * @access public - */ - function &getTestCaseList() { - $urlExtra = ''; - $manager =& new HtmlTestManager(); - $testCases =& $manager->_getTestCaseList($manager->_getTestsPath()); - - $buffer = "

                    Core Test Cases:

                    \n
                      "; - $urlExtra = null; - if ($manager->appTest) { - $buffer = "

                      App Test Cases:

                      \n
                        "; - $urlExtra = '&app=true'; - } else if ($manager->pluginTest) { - $buffer = "

                        " . Inflector::humanize($manager->pluginTest) . " Test Cases:

                        \n
                          "; - $urlExtra = '&plugin=' . $manager->pluginTest; - } - - if (1 > count($testCases)) { - $buffer .= "EMPTY"; - return $buffer; - } - - foreach ($testCases as $testCaseFile => $testCase) { - $title = explode(strpos($testCase, '\\') ? '\\' : '/', str_replace('.test.php', '', $testCase)); - $title[count($title) - 1] = Inflector::camelize($title[count($title) - 1]); - $title = implode(' / ', $title); - - $buffer .= "
                        • " . $title . "
                        • \n"; - } - $buffer .= "
                        \n"; - return $buffer; - } -} ?> \ No newline at end of file From 5a10e52d1fd942ff95cfc85da9b65e607a37aa36 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 19:37:37 -0500 Subject: [PATCH 074/137] Updating package strings for reporters --- cake/tests/lib/reporter/cake_html_reporter.php | 2 +- cake/tests/lib/reporter/cake_text_reporter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 1e272209b..c85f118eb 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -13,7 +13,7 @@ * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org * @package cake - * @subpackage cake.cake.tests.libs + * @subpackage cake.tests.libs.reporter * @since CakePHP(tm) v 1.2.0.4433 * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index dd793a475..7d3b7f5e5 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -13,7 +13,7 @@ * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org * @package cake - * @subpackage cake.cake.tests.libs + * @subpackage cake.tests.libs.reporter * @since CakePHP(tm) v 1.3 * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ From 1e0215b7c1b4f7291346665074cc3e69c8583601 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 19:44:50 -0500 Subject: [PATCH 075/137] Correcting whitespace. --- cake/console/libs/testsuite.php | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php index d2856e84d..a0fdef3c3 100644 --- a/cake/console/libs/testsuite.php +++ b/cake/console/libs/testsuite.php @@ -94,7 +94,7 @@ class TestSuiteShell extends Shell { $this->__installSimpleTest(); require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php'; - require_once CAKE . 'tests' . DS . 'lib' . DS . 'cli_reporter.php'; + require_once CAKE . 'tests' . DS . 'lib' . DS . 'reporter' . DS . 'cake_cli_reporter.php'; $plugins = App::objects('plugin'); foreach ($plugins as $p) { @@ -139,7 +139,7 @@ class TestSuiteShell extends Shell { } if ($this->__canRun()) { - $this->out('Running '.$this->category.' '.$this->type.' '.$this->file); + $this->out('Running ' . $this->category . ' ' . $this->type . ' ' . $this->file); $exitCode = 0; if (!$this->__run()) { @@ -201,7 +201,7 @@ class TestSuiteShell extends Shell { $isPlugin = in_array(Inflector::underscore($this->category), $this->plugins); if ($isNeitherAppNorCore && !$isPlugin) { - $this->err($this->category.' is an invalid test category (either "app", "core" or name of a plugin)'); + $this->err($this->category . ' is an invalid test category (either "app", "core" or name of a plugin)'); return false; } @@ -212,7 +212,7 @@ class TestSuiteShell extends Shell { } if (!in_array($this->type, array('all', 'group', 'case'))) { - $this->err($this->type.' is invalid. Should be case, group or all'); + $this->err($this->type . ' is invalid. Should be case, group or all'); return false; } @@ -221,27 +221,27 @@ class TestSuiteShell extends Shell { return true; break; case 'group': - if (file_exists($folder.DS.'groups'.DS.$this->file.'.group.php')) { + if (file_exists($folder . DS . 'groups' . DS . $this->file . '.group.php')) { return true; } break; case 'case': - if ($this->category == 'app' && file_exists($folder.DS.'cases'.DS.$this->file.'.test.php')) { + if ($this->category == 'app' && file_exists($folder . DS . 'cases' . DS . $this->file . '.test.php')) { return true; } - $coreCaseExists = file_exists($folder.DS.'cases'.DS.$this->file.'.test.php'); - $coreLibCaseExists = file_exists($folder.DS.'cases'.DS.'libs'.DS.$this->file.'.test.php'); + $coreCaseExists = file_exists($folder . DS . 'cases' . DS . $this->file . '.test.php'); + $coreLibCaseExists = file_exists($folder . DS . 'cases' . DS . 'libs' . DS . $this->file . '.test.php'); if ($this->category == 'core' && ($coreCaseExists || $coreLibCaseExists)) { return true; } - if ($isPlugin && file_exists($folder.DS.'cases'.DS.$this->file.'.test.php')) { + if ($isPlugin && file_exists($folder . DS . 'cases' . DS . $this->file . '.test.php')) { return true; } break; } - $this->err($this->category.' '.$this->type.' '.$this->file.' is an invalid test identifier'); + $this->err($this->category . ' ' . $this->type . ' ' . $this->file . ' is an invalid test identifier'); return false; } @@ -273,7 +273,7 @@ class TestSuiteShell extends Shell { if ($this->category == 'app') { $path = APP_TEST_GROUPS; } elseif ($this->isPluginTest) { - $path = APP.'plugins'.DS.$this->category.DS.'tests'.DS.'groups'; + $path = APP . 'plugins' . DS . $this->category . DS . 'tests' . DS . 'groups'; } if ($this->doCoverage) { @@ -287,16 +287,16 @@ class TestSuiteShell extends Shell { return $result; } if ($this->category === 'core') { - $coreCaseExists = file_exists(CORE_TEST_CASES.DS.$this->file.'.test.php'); + $coreCaseExists = file_exists(CORE_TEST_CASES . DS . $this->file . '.test.php'); if ($coreCaseExists) { $case = $this->file . '.test.php'; } else { $case = 'libs' . DS . $this->file . '.test.php'; } } elseif ($this->category === 'app') { - $case = $this->file.'.test.php'; + $case = $this->file . '.test.php'; } elseif ($this->isPluginTest) { - $case = $this->file.'.test.php'; + $case = $this->file . '.test.php'; } if ($this->doCoverage) { @@ -322,7 +322,7 @@ class TestSuiteShell extends Shell { $folder = ''; $paths = array( 'core' => CAKE, - 'app' => APP + 'app' => APP ); if (array_key_exists($category, $paths)) { @@ -350,8 +350,8 @@ class TestSuiteShell extends Shell { function __setGetVars() { if (in_array($this->category, $this->plugins)) { $_GET['plugin'] = $this->category; - } elseif (in_array(Inflector::Humanize($this->category), $this->plugins)) { - $_GET['plugin'] = Inflector::Humanize($this->category); + } elseif (in_array(Inflector::humanize($this->category), $this->plugins)) { + $_GET['plugin'] = Inflector::humanize($this->category); } elseif ($this->category == 'app') { $_GET['app'] = true; } From 8a567933689d9b7600aa4164f0711cf06d4a7b2a Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 19:52:52 -0500 Subject: [PATCH 076/137] Correcting doc blocks. --- cake/tests/lib/test_manager.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 09a3572cd..661e4e6ad 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -97,6 +97,7 @@ class TestManager { * @param boolean $testing Are tests supposed to be auto run. Set to true to return testcase list. * @return mixed * @access public + * @static */ function runAllTests(&$reporter, $testing = false) { $manager =& new TestManager(); @@ -181,6 +182,7 @@ class TestManager { * @param string $directory The directory to add tests from. * @return void * @access public + * @static */ function addTestCasesFromDirectory(&$groupTest, $directory = '.') { $manager =& new TestManager(); @@ -197,6 +199,7 @@ class TestManager { * @param string $file The file name, minus the suffix to add. * @return void * @access public + * @static */ function addTestFile(&$groupTest, $file) { $manager =& new TestManager(); @@ -223,6 +226,7 @@ class TestManager { /** * Builds the list of test cases from a given directory * + * @param string $directory Directory to get test case list from. * @access public */ function &_getTestCaseList($directory = '.') { @@ -237,7 +241,8 @@ class TestManager { /** * Returns a list of test files from a given directory * - * @access public + * @param string $directory Directory to get test case files from. + * @access protected */ function &_getTestFileList($directory = '.') { $return = $this->_getRecursiveFileList($directory, array(&$this, '_isTestCaseFile')); @@ -248,6 +253,7 @@ class TestManager { * Returns a list of group tests found in the current valid test case path * * @access public + * @static */ function &getGroupTestList() { $manager =& new TestManager(); @@ -259,7 +265,7 @@ class TestManager { * Returns a list of group test files from a given directory * * @param string $directory The directory to get group test files from. - * @access public + * @access protected */ function &_getTestGroupFileList($directory = '.') { $return = $this->_getRecursiveFileList($directory, array(&$this, '_isTestGroupFile')); @@ -270,7 +276,7 @@ class TestManager { * Returns a list of group test files from a given directory * * @param string $directory The directory to get group tests from. - * @access public + * @access protected */ function &_getTestGroupList($directory = '.') { $fileList =& $this->_getTestGroupFileList($directory); @@ -287,7 +293,7 @@ class TestManager { * Returns a list of class names from a group test file * * @param string $groupTestFile The groupTest file to scan for TestSuite classnames. - * @access public + * @access protected */ function &_getGroupTestClassNames($groupTestFile) { $file = implode("\n", file($groupTestFile)); @@ -306,7 +312,7 @@ class TestManager { * * @param string $directory The directory to scan for files. * @param mixed $fileTestFunction - * @access public + * @access protected */ function &_getRecursiveFileList($directory = '.', $fileTestFunction) { $fileList = array(); @@ -332,7 +338,7 @@ class TestManager { * * @param string $file * @return void - * @access public + * @access protected */ function _isTestCaseFile($file) { return $this->_hasExpectedExtension($file, $this->_testExtension); @@ -343,7 +349,7 @@ class TestManager { * * @param string $file * @return void - * @access public + * @access protected */ function _isTestGroupFile($file) { return $this->_hasExpectedExtension($file, $this->_groupExtension); @@ -355,7 +361,7 @@ class TestManager { * @param string $file * @param string $extension * @return void - * @access public + * @access protected */ function _hasExpectedExtension($file, $extension) { return $extension == strtolower(substr($file, (0 - strlen($extension)))); @@ -366,7 +372,7 @@ class TestManager { * * @param string $type either 'cases' or 'groups' * @return string The path tests are located on - * @access public + * @access protected */ function _getTestsPath($type = 'cases') { if (!empty($this->appTest)) { From 6721c4926d6dad470be1772f4c23eac3e1ab4b1b Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 20:19:49 -0500 Subject: [PATCH 077/137] Renaming CliReporter to CakeCliReporter, so it name matches the other new refactored reporters. --- .../reporter/{cli_reporter.php => cake_cli_reporter.php} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename cake/tests/lib/reporter/{cli_reporter.php => cake_cli_reporter.php} (95%) diff --git a/cake/tests/lib/reporter/cli_reporter.php b/cake/tests/lib/reporter/cake_cli_reporter.php similarity index 95% rename from cake/tests/lib/reporter/cli_reporter.php rename to cake/tests/lib/reporter/cake_cli_reporter.php index 35c6c1df9..aecbce25e 100644 --- a/cake/tests/lib/reporter/cli_reporter.php +++ b/cake/tests/lib/reporter/cake_cli_reporter.php @@ -1,6 +1,6 @@ Date: Sat, 9 Jan 2010 20:20:13 -0500 Subject: [PATCH 078/137] Fixing package string on CakeBaseReporter --- cake/tests/lib/reporter/cake_base_reporter.php | 2 +- cake/tests/lib/test_manager.php | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index 0bedcc9b5..109bc012a 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -13,7 +13,7 @@ * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org * @package cake - * @subpackage cake.cake.tests.libs + * @subpackage cake.tests.libs.reporter * @since CakePHP(tm) v 1.3 * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 661e4e6ad..e00ee0204 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -97,16 +97,13 @@ class TestManager { * @param boolean $testing Are tests supposed to be auto run. Set to true to return testcase list. * @return mixed * @access public - * @static */ function runAllTests(&$reporter, $testing = false) { - $manager =& new TestManager(); - - $testCases =& $manager->_getTestFileList($manager->_getTestsPath()); - if ($manager->appTest) { + $testCases =& $this->_getTestFileList($this->_getTestsPath()); + if ($this->appTest) { $test =& new TestSuite('All App Tests'); - } else if ($manager->pluginTest) { - $test =& new TestSuite('All ' . Inflector::humanize($manager->pluginTest) . ' Plugin Tests'); + } else if ($this->pluginTest) { + $test =& new TestSuite('All ' . Inflector::humanize($this->pluginTest) . ' Plugin Tests'); } else { $test =& new TestSuite('All Core Tests'); } @@ -337,7 +334,7 @@ class TestManager { * Tests if a file has the correct test case extension * * @param string $file - * @return void + * @return boolean * @access protected */ function _isTestCaseFile($file) { From 80670d85fbe99c0fc1ba2a12607729576968cf72 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 20:20:51 -0500 Subject: [PATCH 079/137] Updating TestSuite shell to use refactored classes and methods in the TestSuite. --- cake/console/libs/testsuite.php | 93 +++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php index a0fdef3c3..3228a7a33 100644 --- a/cake/console/libs/testsuite.php +++ b/cake/console/libs/testsuite.php @@ -100,6 +100,51 @@ class TestSuiteShell extends Shell { foreach ($plugins as $p) { $this->plugins[] = Inflector::underscore($p); } + $this->parseArgs(); + $this->getManager(); + } + +/** + * Parse the arguments given into the Shell object properties. + * + * @return void + * @access public + */ + function parseArgs() { + $this->category = $this->args[0]; + + if (!in_array($this->category, array('app', 'core'))) { + $this->isPluginTest = true; + } + + if (isset($this->args[1])) { + $this->type = $this->args[1]; + } + + if (isset($this->args[2])) { + if ($this->args[2] == 'cov') { + $this->doCoverage = true; + } else { + $this->file = Inflector::underscore($this->args[2]); + } + } + + if (isset($this->args[3]) && $this->args[3] == 'cov') { + $this->doCoverage = true; + } + } + +/** + * Gets a manager instance, and set the app/plugin properties. + * + * @return void + */ + function getManager() { + $this->Manager = new TestManager(); + $this->Manager->appTest = ($this->category === 'app'); + if ($this->isPluginTest) { + $this->Manager->pluginTest = $this->category; + } } /** @@ -112,29 +157,7 @@ class TestSuiteShell extends Shell { $this->out($this->headline); $this->hr(); - if (count($this->args) > 0) { - $this->category = $this->args[0]; - - if (!in_array($this->category, array('app', 'core'))) { - $this->isPluginTest = true; - } - - if (isset($this->args[1])) { - $this->type = $this->args[1]; - } - - if (isset($this->args[2])) { - if ($this->args[2] == 'cov') { - $this->doCoverage = true; - } else { - $this->file = Inflector::underscore($this->args[2]); - } - } - - if (isset($this->args[3]) && $this->args[3] == 'cov') { - $this->doCoverage = true; - } - } else { + if (count($this->args) == 0) { $this->err('Sorry, you did not pass any arguments!'); } @@ -252,11 +275,10 @@ class TestSuiteShell extends Shell { * @access private */ function __run() { - $reporter = new CLIReporter(); - $this->__setGetVars(); + $Reporter = new CakeCliReporter(); if ($this->type == 'all') { - return TestManager::runAllTests($reporter); + return $this->Manager->runAllTests($Reporter); } if ($this->doCoverage) { @@ -278,9 +300,9 @@ class TestSuiteShell extends Shell { if ($this->doCoverage) { require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php'; - CodeCoverageManager::start($ucFirstGroup, $reporter); + CodeCoverageManager::start($ucFirstGroup, $Reporter); } - $result = TestManager::runGroupTest($ucFirstGroup, $reporter); + $result = $this->Manager->runGroupTest($ucFirstGroup, $Reporter); if ($this->doCoverage) { CodeCoverageManager::report(); } @@ -301,10 +323,10 @@ class TestSuiteShell extends Shell { if ($this->doCoverage) { require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php'; - CodeCoverageManager::start($case, $reporter); + CodeCoverageManager::start($case, $Reporter); } - $result = TestManager::runTestCase($case, $reporter); + $result = $this->Manager->runTestCase($case, $Reporter); if ($this->doCoverage) { CodeCoverageManager::report(); } @@ -328,14 +350,9 @@ class TestSuiteShell extends Shell { if (array_key_exists($category, $paths)) { $folder = $paths[$category] . 'tests'; } else { - $scoredCategory = Inflector::underscore($category); - $folder = APP . 'plugins' . DS . $scoredCategory . DS; - $pluginPaths = App::path('plugins'); - foreach ($pluginPaths as $path) { - if (file_exists($path . $scoredCategory . DS . 'tests')) { - $folder = $path . $scoredCategory . DS . 'tests'; - break; - } + $pluginPath = App::pluginPath($category); + if (is_dir($pluginPath . 'tests')) { + $folder = $pluginPath . 'tests' . DS; } } return $folder; From 924571971199690d2eafc1a04f055f0268ebd16e Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 21:22:41 -0500 Subject: [PATCH 080/137] Updating TestManager::getExtension to be an instance method only. Updating doc blocks for TestManager. Removing CliTestManager as it is no longer used/needed. --- cake/tests/lib/test_manager.php | 57 +++++---------------------------- 1 file changed, 8 insertions(+), 49 deletions(-) diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index e00ee0204..af29e2f3c 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -125,7 +125,7 @@ class TestManager { * @param string $testCaseFile Filename of the test to be run. * @param Object $reporter Reporter instance to attach to the test case. * @param boolean $testing Set to true if testing, otherwise test case will be run. - * @return mixed + * @return mixed Result of test case being run. * @access public */ function runTestCase($testCaseFile, &$reporter, $testing = false) { @@ -150,7 +150,7 @@ class TestManager { * * @param string $groupTestName GroupTest that you want to run. * @param Object $reporter Reporter instance to use with the group test being run. - * @return mixed + * @return mixed Results of group test being run. * @access public */ function runGroupTest($groupTestName, &$reporter) { @@ -213,6 +213,7 @@ class TestManager { * Returns a list of test cases found in the current valid test case path * * @access public + * @static */ function &getTestCaseList() { $manager =& new TestManager(); @@ -224,7 +225,7 @@ class TestManager { * Builds the list of test cases from a given directory * * @param string $directory Directory to get test case list from. - * @access public + * @access protected */ function &_getTestCaseList($directory = '.') { $fileList =& $this->_getTestFileList($directory); @@ -334,7 +335,7 @@ class TestManager { * Tests if a file has the correct test case extension * * @param string $file - * @return boolean + * @return boolean Whether $file is a test case. * @access protected */ function _isTestCaseFile($file) { @@ -345,7 +346,7 @@ class TestManager { * Tests if a file has the correct group test extension * * @param string $file - * @return void + * @return boolean Whether $file is a group * @access protected */ function _isTestGroupFile($file) { @@ -403,52 +404,10 @@ class TestManager { * @access public */ function getExtension($type = 'test') { - $manager =& new TestManager(); if ($type == 'test') { - return $manager->_testExtension; + return $this->_testExtension; } - return $manager->_groupExtension; - } -} - -/** - * The CliTestManager ensures that the list of available files are printed in the correct cli format - * - * @package cake - * @subpackage cake.cake.tests.lib - */ -class CliTestManager extends TestManager { - -/** - * Prints the list of group tests in a cli friendly format - * - * @access public - */ - function &getGroupTestList() { - $manager =& new CliTestManager(); - $groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups')); - $buffer = "Available Group Test:\n"; - - foreach ($groupTests as $groupTest) { - $buffer .= " " . $groupTest . "\n"; - } - return $buffer . "\n"; - } - -/** - * Prints the list of test cases in a cli friendly format - * - * @access public - */ - function &getTestCaseList() { - $manager =& new CliTestManager(); - $testCases =& $manager->_getTestCaseList($manager->_getTestsPath()); - $buffer = "Available Test Cases:\n"; - - foreach ($testCases as $testCaseFile => $testCase) { - $buffer .= " " . $testCaseFile . "\n"; - } - return $buffer . "\n"; + return $this->_groupExtension; } } From 6a3152c5185203c0555803da09f7b4eb59eaee3d Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 21:24:27 -0500 Subject: [PATCH 081/137] Update file header. --- cake/tests/lib/test_manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index af29e2f3c..3b543a614 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -1,6 +1,6 @@ Date: Sat, 9 Jan 2010 21:25:05 -0500 Subject: [PATCH 082/137] Refactoring testsuite shell features, and adding i18n text. --- cake/console/libs/testsuite.php | 57 +++++++++++++++++---------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php index 3228a7a33..3670e76e2 100644 --- a/cake/console/libs/testsuite.php +++ b/cake/console/libs/testsuite.php @@ -69,14 +69,6 @@ class TestSuiteShell extends Shell { */ var $doCoverage = false; -/** - * The headline for the test output - * - * @var string - * @access public - */ - var $headline = 'CakePHP Test Shell'; - /** * Initialization method installs Simpletest and loads all plugins * @@ -111,6 +103,9 @@ class TestSuiteShell extends Shell { * @access public */ function parseArgs() { + if (empty($this->args)) { + return; + } $this->category = $this->args[0]; if (!in_array($this->category, array('app', 'core'))) { @@ -154,24 +149,24 @@ class TestSuiteShell extends Shell { * @access public */ function main() { - $this->out($this->headline); + $this->out(__('CakePHP Test Shell', true)); $this->hr(); if (count($this->args) == 0) { - $this->err('Sorry, you did not pass any arguments!'); + $this->error(__('Sorry, you did not pass any arguments!', true)); } if ($this->__canRun()) { - $this->out('Running ' . $this->category . ' ' . $this->type . ' ' . $this->file); + $message = sprintf(__('Running %s %s %s', true), $this->category, $this->type, $this->file); + $this->out($message); $exitCode = 0; if (!$this->__run()) { $exitCode = 1; } - exit($exitCode); + $this->_stop($exitCode); } else { - $this->err('Sorry, the tests could not be found.'); - exit(1); + $this->error(__('Sorry, the tests could not be found.', true)); } } @@ -224,47 +219,55 @@ class TestSuiteShell extends Shell { $isPlugin = in_array(Inflector::underscore($this->category), $this->plugins); if ($isNeitherAppNorCore && !$isPlugin) { - $this->err($this->category . ' is an invalid test category (either "app", "core" or name of a plugin)'); + $message = sprintf( + __('%s is an invalid test category (either "app", "core" or name of a plugin)', true), + $this->category + ); + $this->error($message); return false; } $folder = $this->__findFolderByCategory($this->category); if (!file_exists($folder)) { - $this->err($folder . ' not found'); + $this->err(sprintf(__('%s not found', true), $folder)); return false; } if (!in_array($this->type, array('all', 'group', 'case'))) { - $this->err($this->type . ' is invalid. Should be case, group or all'); + $this->err(sprintf(__('%s is invalid. Should be case, group or all', true), $this->type)); return false; } + $ext = $this->Manager->getExtensino($this->type); switch ($this->type) { case 'all': return true; - break; case 'group': - if (file_exists($folder . DS . 'groups' . DS . $this->file . '.group.php')) { + if (file_exists($folder . DS . 'groups' . DS . $this->file . $ext)) { return true; } break; case 'case': - if ($this->category == 'app' && file_exists($folder . DS . 'cases' . DS . $this->file . '.test.php')) { + if ($this->category == 'app' && file_exists($folder . DS . 'cases' . DS . $this->file . $ext)) { return true; } - $coreCaseExists = file_exists($folder . DS . 'cases' . DS . $this->file . '.test.php'); - $coreLibCaseExists = file_exists($folder . DS . 'cases' . DS . 'libs' . DS . $this->file . '.test.php'); + $coreCaseExists = file_exists($folder . DS . 'cases' . DS . $this->file . $ext); + $coreLibCaseExists = file_exists($folder . DS . 'cases' . DS . 'libs' . DS . $this->file . $ext); if ($this->category == 'core' && ($coreCaseExists || $coreLibCaseExists)) { return true; } - if ($isPlugin && file_exists($folder . DS . 'cases' . DS . $this->file . '.test.php')) { + if ($isPlugin && file_exists($folder . DS . 'cases' . DS . $this->file . $ext)) { return true; } break; } - - $this->err($this->category . ' ' . $this->type . ' ' . $this->file . ' is an invalid test identifier'); + + $message = sprintf( + __('%s %s %s is an invalid test identifier', true), + $this->category, $this->type, $this->file + ); + $this->err($message); return false; } @@ -283,7 +286,7 @@ class TestSuiteShell extends Shell { if ($this->doCoverage) { if (!extension_loaded('xdebug')) { - $this->out('You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation. Download it from http://www.xdebug.org/docs/install'); + $this->out(__('You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation. Download it from http://www.xdebug.org/docs/install', true)); exit(0); } } @@ -385,7 +388,7 @@ class TestSuiteShell extends Shell { */ function __installSimpleTest() { if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { - $this->err('Sorry, Simpletest could not be found. Download it from http://simpletest.org and install it to your vendors directory.'); + $this->err(__('Sorry, Simpletest could not be found. Download it from http://simpletest.org and install it to your vendors directory.', true)); exit; } } From a8f289349ea56b986832c40b6624e9d7b64fdf5a Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 21:29:57 -0500 Subject: [PATCH 083/137] Letting TestManager::getExtension accept either test or case as a test case type. --- cake/tests/lib/test_manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 3b543a614..21ee551ca 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -404,7 +404,7 @@ class TestManager { * @access public */ function getExtension($type = 'test') { - if ($type == 'test') { + if ($type == 'test' || $type == 'case') { return $this->_testExtension; } return $this->_groupExtension; From 081509a09c1893b803cee40bb88856f258b65e57 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 21:30:46 -0500 Subject: [PATCH 084/137] Fixing typos. Removing useless constant. Fixing constructor --- cake/console/libs/testsuite.php | 2 +- cake/tests/lib/reporter/cake_cli_reporter.php | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php index 3670e76e2..f4822441d 100644 --- a/cake/console/libs/testsuite.php +++ b/cake/console/libs/testsuite.php @@ -237,7 +237,7 @@ class TestSuiteShell extends Shell { $this->err(sprintf(__('%s is invalid. Should be case, group or all', true), $this->type)); return false; } - $ext = $this->Manager->getExtensino($this->type); + $ext = $this->Manager->getExtension($this->type); switch ($this->type) { case 'all': diff --git a/cake/tests/lib/reporter/cake_cli_reporter.php b/cake/tests/lib/reporter/cake_cli_reporter.php index aecbce25e..e2db21771 100644 --- a/cake/tests/lib/reporter/cake_cli_reporter.php +++ b/cake/tests/lib/reporter/cake_cli_reporter.php @@ -17,10 +17,6 @@ * @since CakePHP(tm) v 1.2.0.4433 * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ - if (! defined('ST_FAILDETAIL_SEPARATOR')) { - define('ST_FAILDETAIL_SEPARATOR', "->"); - } - if (version_compare(PHP_VERSION, '4.4.4', '<=') || PHP_SAPI == 'cgi') { define('STDOUT', fopen('php://stdout', 'w')); @@ -37,9 +33,9 @@ */ class CakeCliReporter extends TextReporter { - var $faildetail_separator = ST_FAILDETAIL_SEPARATOR; + var $faildetail_separator = '->'; - function CLIReporter($faildetail_separator = NULL) { + function CakeCLIReporter($faildetail_separator = NULL) { $this->SimpleReporter(); if (! is_null($faildetail_separator)) { $this->setFailDetailSeparator($faildetail_separator); From 7b5addec3e7287e4906c742299c93aafc9a8b682 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 22:02:35 -0500 Subject: [PATCH 085/137] Making CakeCliReporter a subclass of CakeBaseReporter. Removing duplicated output from reporter message. Adjusting formatting of output to be more readable. --- cake/tests/lib/reporter/cake_cli_reporter.php | 72 +++++++++++++------ 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/cake/tests/lib/reporter/cake_cli_reporter.php b/cake/tests/lib/reporter/cake_cli_reporter.php index e2db21771..bc1f17255 100644 --- a/cake/tests/lib/reporter/cake_cli_reporter.php +++ b/cake/tests/lib/reporter/cake_cli_reporter.php @@ -24,6 +24,8 @@ register_shutdown_function(create_function('', 'fclose(STDOUT); fclose(STDERR); return true;')); } +include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; + /** * Minimal command line test displayer. Writes fail details to STDERR. Returns 0 * to the shell if all tests pass, ST_FAILS_RETURN_CODE if any test fails. @@ -31,47 +33,73 @@ * @package cake * @subpackage cake.tests.libs.reporter */ -class CakeCliReporter extends TextReporter { +class CakeCliReporter extends CakeBaseReporter { - var $faildetail_separator = '->'; + var $separator = '->'; - function CakeCLIReporter($faildetail_separator = NULL) { + function CakeCLIReporter($separator = NULL) { $this->SimpleReporter(); - if (! is_null($faildetail_separator)) { - $this->setFailDetailSeparator($faildetail_separator); + if (!is_null($separator)) { + $this->setFailDetailSeparator($separator); } } function setFailDetailSeparator($separator) { - $this->faildetail_separator = $separator; - } - -/** - * Return a formatted faildetail for printing. - */ - function &_paintTestFailDetail(&$message) { - $buffer = ''; - $faildetail = $this->getTestList(); - array_shift($faildetail); - $buffer .= implode($this->faildetail_separator, $faildetail); - $buffer .= $this->faildetail_separator . "$message\n"; - return $buffer; + $this->separator = $separator; } /** * Paint fail faildetail to STDERR. + * + * @param string $message Message of the fail. + * @return void + * @access public */ function paintFail($message) { parent::paintFail($message); - fwrite(STDERR, 'FAIL' . $this->faildetail_separator . $this->_paintTestFailDetail($message)); + $breadcrumb = $this->getTestList(); + array_shift($breadcrumb); + $message .= "\n\tin " . implode("\n\tin ", array_reverse($breadcrumb)); + $message .= "\n\n"; + fwrite(STDERR, 'FAIL' . $this->separator . $message); + } + +/** + * Paint PHP errors to STDERR. + * + * @param string $message Message of the Error + * @return void + * @access public + */ + function paintError($message) { + parent::paintError($message); + $breadcrumb = $this->getTestList(); + array_shift($breadcrumb); + $message .= "\n\tin " . implode("\n\tin ", array_reverse($breadcrumb)); + $message .= "\n\n"; + fwrite(STDERR, 'ERROR' . $this->separator . $message); } /** * Paint exception faildetail to STDERR. + * + * @param string $message Message of the Error + * @return void + * @access public */ - function paintException($message) { - parent::paintException($message); - fwrite(STDERR, 'EXCEPTION' . $this->faildetail_separator . $this->_paintTestFailDetail($message)); + function paintException($exception) { + parent::paintException($exception); + $message .= sprintf('Unexpected exception of type [%s] with message [%s] in [%s] line [%s]', + get_class($exception), + $exception->getMessage(), + $exception->getFile(), + $exception->getLine() + ); + $breadcrumb = $this->getTestList(); + array_shift($breadcrumb); + $message .= "\n\tin " . implode("\n\tin ", array_reverse($breadcrumb)); + $message .= "\n\n"; + fwrite(STDERR, 'EXCEPTION' . $this->separator . $message); } /** From f52900f8181e6834746ac077263f3a23455c0493 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 22:04:28 -0500 Subject: [PATCH 086/137] Adding time and memory use to CakeCliReporter --- cake/tests/lib/reporter/cake_cli_reporter.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cake/tests/lib/reporter/cake_cli_reporter.php b/cake/tests/lib/reporter/cake_cli_reporter.php index bc1f17255..dc2409b0c 100644 --- a/cake/tests/lib/reporter/cake_cli_reporter.php +++ b/cake/tests/lib/reporter/cake_cli_reporter.php @@ -117,6 +117,10 @@ class CakeCliReporter extends CakeBaseReporter { $buffer .= ", " . $this->getExceptionCount() . " exceptions"; } $buffer .= ".\n"; + $buffer .= 'Time taken by tests (in seconds): ' . $this->_timeDuration . "\n"; + if (function_exists('memory_get_peak_usage')) { + $buffer .= 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n"; + } fwrite(STDOUT, $buffer); } else { fwrite(STDOUT, $buffer . $this->getPassCount() . " passes.\n"); From 03da53bb9296193e92f9e35c50ae6d2c323a3b25 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 22:35:29 -0500 Subject: [PATCH 087/137] Correcting classname used in CodeCoverageManager Moving CodeCoverageManager::report() to be inside the html document. --- cake/tests/lib/cake_test_suite_dispatcher.php | 8 -------- cake/tests/lib/code_coverage_manager.php | 2 +- cake/tests/lib/reporter/cake_html_reporter.php | 7 +++++++ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 1b671204d..7ba5f7596 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -230,9 +230,6 @@ class CakeTestSuiteDispatcher { CodeCoverageManager::start($this->params['group'], $Reporter); } $this->Manager->runGroupTest(ucfirst($this->params['group']), $Reporter); - if ($this->params['codeCoverage']) { - CodeCoverageManager::report(); - } } } @@ -246,12 +243,7 @@ class CakeTestSuiteDispatcher { if ($this->params['codeCoverage']) { CodeCoverageManager::start($this->params['case'], $Reporter); } - $this->Manager->runTestCase($this->params['case'], $Reporter); - - if ($this->params['codeCoverage']) { - CodeCoverageManager::report(); - } } } ?> \ No newline at end of file diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index 019c632a2..81af4a040 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -155,7 +155,7 @@ class CodeCoverageManager { case 'CakeHtmlReporter': $result = $manager->reportCaseHtmlDiff(@file($testObjectFile), $coverageData, $execCodeLines, $manager->numDiffContextLines); break; - case 'CLIReporter': + case 'CakeCliReporter': $result = $manager->reportCaseCli(@file($testObjectFile), $coverageData, $execCodeLines, $manager->numDiffContextLines); break; default: diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index c85f118eb..53162aa4b 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -175,6 +175,13 @@ class CakeHtmlReporter extends CakeBaseReporter { } echo $this->_paintLinks(); echo '
        '; + if ( + isset($this->params['codeCoverage']) && + $this->params['codeCoverage'] && + class_exists('CodeCoverageManager') + ) { + CodeCoverageManager::report(); + } $this->paintDocumentEnd(); } From d79bacd1ed7b7452c59c663d8b998c3b511919d8 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 22:41:49 -0500 Subject: [PATCH 088/137] Making CodeCoverageManager get its settings from the reporter. This makes code coverage much less reliant on GET parameters. --- cake/tests/lib/code_coverage_manager.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index 81af4a040..eb6294e1c 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -96,24 +96,24 @@ class CodeCoverageManager { */ function start($testCaseFile, &$reporter) { $manager =& CodeCoverageManager::getInstance(); - $manager->reporter = $reporter; + $manager->reporter =& $reporter; $testCaseFile = str_replace(DS . DS, DS, $testCaseFile); $thisFile = str_replace('.php', '.test.php', basename(__FILE__)); if (strpos($testCaseFile, $thisFile) !== false) { trigger_error('Xdebug supports no parallel coverage analysis - so this is not possible.', E_USER_ERROR); } - - if (isset($_GET['app'])) { + + if ($reporter->params['app']) { $manager->appTest = true; } - if (isset($_GET['group'])) { + if ($reporter->params['group']) { $manager->groupTest = true; } - if (isset($_GET['plugin'])) { - $manager->pluginTest = Inflector::underscore($_GET['plugin']); + if ($reporter->params['plugin']) { + $manager->pluginTest = Inflector::underscore($reporter->params['plugin']); } $manager->testCaseFile = $testCaseFile; xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); From bcd7d3402390b1c7842f5417ef0d0b58858abff9 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 22:51:17 -0500 Subject: [PATCH 089/137] Refactoring breadcrumb and time generation in the CLI reporter. --- cake/tests/lib/reporter/cake_cli_reporter.php | 58 ++++++++++++++----- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/cake/tests/lib/reporter/cake_cli_reporter.php b/cake/tests/lib/reporter/cake_cli_reporter.php index dc2409b0c..60d30751e 100644 --- a/cake/tests/lib/reporter/cake_cli_reporter.php +++ b/cake/tests/lib/reporter/cake_cli_reporter.php @@ -57,10 +57,7 @@ class CakeCliReporter extends CakeBaseReporter { */ function paintFail($message) { parent::paintFail($message); - $breadcrumb = $this->getTestList(); - array_shift($breadcrumb); - $message .= "\n\tin " . implode("\n\tin ", array_reverse($breadcrumb)); - $message .= "\n\n"; + $message .= $this->_getBreadcrumb(); fwrite(STDERR, 'FAIL' . $this->separator . $message); } @@ -73,10 +70,7 @@ class CakeCliReporter extends CakeBaseReporter { */ function paintError($message) { parent::paintError($message); - $breadcrumb = $this->getTestList(); - array_shift($breadcrumb); - $message .= "\n\tin " . implode("\n\tin ", array_reverse($breadcrumb)); - $message .= "\n\n"; + $message .= $this->_getBreadcrumb(); fwrite(STDERR, 'ERROR' . $this->separator . $message); } @@ -95,11 +89,32 @@ class CakeCliReporter extends CakeBaseReporter { $exception->getFile(), $exception->getLine() ); + $message .= $this->_getBreadcrumb(); + fwrite(STDERR, 'EXCEPTION' . $this->separator . $message); + } + +/** + * Get the breadcrumb trail for the current test method/case + * + * @return string The string for the breadcrumb + */ + function _getBreadcrumb() { $breadcrumb = $this->getTestList(); array_shift($breadcrumb); - $message .= "\n\tin " . implode("\n\tin ", array_reverse($breadcrumb)); - $message .= "\n\n"; - fwrite(STDERR, 'EXCEPTION' . $this->separator . $message); + $out = "\n\tin " . implode("\n\tin ", array_reverse($breadcrumb)); + $out .= "\n\n"; + return $out; + } + +/** + * Paint a test skip message + * + * @param string $message The message of the skip + * @return void + */ + function paintSkip($message) { + parent::paintSkip($message); + fwrite(STDOUT, 'SKIP' . $this->separator . $message . "\n\n"); } /** @@ -117,14 +132,25 @@ class CakeCliReporter extends CakeBaseReporter { $buffer .= ", " . $this->getExceptionCount() . " exceptions"; } $buffer .= ".\n"; - $buffer .= 'Time taken by tests (in seconds): ' . $this->_timeDuration . "\n"; - if (function_exists('memory_get_peak_usage')) { - $buffer .= 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n"; - } + $buffer .= $this->_timeStats(); fwrite(STDOUT, $buffer); } else { - fwrite(STDOUT, $buffer . $this->getPassCount() . " passes.\n"); + fwrite(STDOUT, $buffer . $this->getPassCount() . " passes.\n" . $this->_timeStats()); } } + +/** + * Get the time and memory stats for this test case/group + * + * @return string String content to display + * @access protected + */ + function _timeStats() { + $out = 'Time taken by tests (in seconds): ' . $this->_timeDuration . "\n"; + if (function_exists('memory_get_peak_usage')) { + $out .= 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n"; + } + return $out; + } } ?> \ No newline at end of file From f4bda62ea34304adc2e4b9068985186364129a89 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 Jan 2010 23:00:03 -0500 Subject: [PATCH 090/137] Adding doc blocks and correcting constructor of CakeCliReporter Fixing TestSuite console code coverage output. --- cake/console/libs/testsuite.php | 7 +++++- cake/tests/lib/reporter/cake_cli_reporter.php | 24 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php index f4822441d..162119a28 100644 --- a/cake/console/libs/testsuite.php +++ b/cake/console/libs/testsuite.php @@ -278,7 +278,11 @@ class TestSuiteShell extends Shell { * @access private */ function __run() { - $Reporter = new CakeCliReporter(); + $Reporter = new CakeCliReporter('utf-8', array( + 'app' => $this->Manager->appTest, + 'plugin' => $this->Manager->pluginTest, + 'group' => ($this->type === 'group') + )); if ($this->type == 'all') { return $this->Manager->runAllTests($Reporter); @@ -332,6 +336,7 @@ class TestSuiteShell extends Shell { $result = $this->Manager->runTestCase($case, $Reporter); if ($this->doCoverage) { CodeCoverageManager::report(); + $this->out(); } return $result; diff --git a/cake/tests/lib/reporter/cake_cli_reporter.php b/cake/tests/lib/reporter/cake_cli_reporter.php index 60d30751e..b736ce4d1 100644 --- a/cake/tests/lib/reporter/cake_cli_reporter.php +++ b/cake/tests/lib/reporter/cake_cli_reporter.php @@ -34,11 +34,29 @@ include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; * @subpackage cake.tests.libs.reporter */ class CakeCliReporter extends CakeBaseReporter { - +/** + * separator string for fail, error, exception, and skip messages. + * + * @var string + */ var $separator = '->'; - function CakeCLIReporter($separator = NULL) { - $this->SimpleReporter(); +/** + * array of 'request' parameters + * + * @var array + */ + var $params = array(); + +/** + * Constructor + * + * @param string $separator + * @param array $params + * @return void + */ + function CakeCLIReporter($separator = NULL, $params = array()) { + $this->CakeBaseReporter('utf-8', $params); if (!is_null($separator)) { $this->setFailDetailSeparator($separator); } From a0aca7ee62387761014c45cc8163e3eb3913d434 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 12:34:55 -0500 Subject: [PATCH 091/137] Adding output buffering to htmlreporter fixing issues with tests that send headers like Dispatcher test. --- cake/tests/lib/reporter/cake_html_reporter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 53162aa4b..b7e0934e9 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -38,6 +38,7 @@ class CakeHtmlReporter extends CakeBaseReporter { */ function paintHeader($testName) { $this->sendNoCacheHeaders(); + ob_start(); $this->paintDocumentStart(); $this->paintTestMenu(); echo "

        $testName

        \n"; @@ -240,6 +241,7 @@ class CakeHtmlReporter extends CakeBaseReporter { function paintDocumentEnd() { $baseDir = $this->params['baseDir']; include CAKE_TESTS_LIB . 'templates' . DS . 'footer.php'; + ob_end_flush(); } /** From e304246e8f177daf207952c1c3beb44abe669b89 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 12:39:21 -0500 Subject: [PATCH 092/137] Updating test manager test cases to reflect changes in API. --- cake/tests/cases/libs/test_manager.test.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cake/tests/cases/libs/test_manager.test.php b/cake/tests/cases/libs/test_manager.test.php index 5a673f690..dc717ee11 100644 --- a/cake/tests/cases/libs/test_manager.test.php +++ b/cake/tests/cases/libs/test_manager.test.php @@ -19,7 +19,6 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ -App::import('Core', 'TestManager'); /** * TestManagerTest class @@ -36,7 +35,7 @@ class TestManagerTest extends CakeTestCase { * @access public */ function setUp() { - $this->Sut =& new TestManager(); + $this->TestManager =& new TestManager(); $this->Reporter =& new CakeHtmlReporter(); } @@ -47,12 +46,12 @@ class TestManagerTest extends CakeTestCase { * @access public */ function testRunAllTests() { - $folder =& new Folder($this->Sut->_getTestsPath()); - $extension = str_replace('.', '\.', TestManager::getExtension('test')); + $folder =& new Folder($this->TestManager->_getTestsPath()); + $extension = str_replace('.', '\.', $this->TestManager->getExtension('test')); $out = $folder->findRecursive('.*' . $extension); $reporter =& new CakeHtmlReporter(); - $list = TestManager::runAllTests($reporter, true); + $list = $this->TestManager->runAllTests($reporter, true); $this->assertEqual(count($out), count($list)); } @@ -65,12 +64,12 @@ class TestManagerTest extends CakeTestCase { */ function testRunTestCase() { $file = md5(time()); - $result = $this->Sut->runTestCase($file, $this->Reporter); + $result = $this->TestManager->runTestCase($file, $this->Reporter); $this->assertError('Test case ' . $file . ' cannot be found'); $this->assertFalse($result); $file = str_replace(CORE_TEST_CASES, '', __FILE__); - $result = $this->Sut->runTestCase($file, $this->Reporter, true); + $result = $this->TestManager->runTestCase($file, $this->Reporter, true); $this->assertTrue($result); } From cf5c48ecc54650db24f66fef29786d3b72554aab Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 12:48:11 -0500 Subject: [PATCH 093/137] Making CakeBaseReporter constructor take null for charset, so its easier to type. --- cake/tests/lib/reporter/cake_base_reporter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index 109bc012a..7a12fd3ae 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -82,6 +82,9 @@ class CakeBaseReporter extends SimpleReporter { */ function CakeBaseReporter($charset = 'utf-8', $params = array()) { $this->SimpleReporter(); + if (!$charset) { + $charset = 'utf-8'; + } $this->_characterSet = $charset; $this->params = $params; } From 836c7de7cb23f3c346985940275f7a05dc07ec62 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 12:48:40 -0500 Subject: [PATCH 094/137] Updating CodeCoverageManager test case and CodeCoverageManager --- .../cases/libs/code_coverage_manager.test.php | 10 +++---- cake/tests/lib/code_coverage_manager.php | 27 ++++++++++++++----- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/cake/tests/cases/libs/code_coverage_manager.test.php b/cake/tests/cases/libs/code_coverage_manager.test.php index cfc5968b2..b07c3f6cf 100644 --- a/cake/tests/cases/libs/code_coverage_manager.test.php +++ b/cake/tests/cases/libs/code_coverage_manager.test.php @@ -19,7 +19,6 @@ */ require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php'; require_once CAKE . 'tests' . DS . 'lib' . DS . 'cli_reporter.php'; -require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_reporter.php'; /** * CodeCoverageManagerTest class @@ -65,12 +64,13 @@ class CodeCoverageManagerTest extends CakeTestCase { */ function testNoTestCaseSupplied() { if (PHP_SAPI != 'cli') { - unset($_GET['group']); - CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter()); + $reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false)); + + CodeCoverageManager::start(substr(md5(microtime()), 0, 5), $reporter); CodeCoverageManager::report(false); $this->assertError(); - CodeCoverageManager::start('tests' . DS . 'lib' . DS . basename(__FILE__), new CakeHtmlReporter()); + CodeCoverageManager::start('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter); CodeCoverageManager::report(false); $this->assertError(); @@ -96,7 +96,7 @@ class CodeCoverageManagerTest extends CakeTestCase { $contents[1] = array_filter($contents[1], "remove"); foreach ($contents[1] as $file) { - CodeCoverageManager::start('libs'.DS.$file, new CakeHtmlReporter()); + CodeCoverageManager::start('libs'.DS.$file, $reporter); CodeCoverageManager::report(false); $this->assertNoErrors('libs'.DS.$file); } diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index eb6294e1c..3dee49713 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -93,6 +93,7 @@ class CodeCoverageManager { * @param string $testCaseFile * @param string $reporter * @return void + * @static */ function start($testCaseFile, &$reporter) { $manager =& CodeCoverageManager::getInstance(); @@ -103,26 +104,35 @@ class CodeCoverageManager { if (strpos($testCaseFile, $thisFile) !== false) { trigger_error('Xdebug supports no parallel coverage analysis - so this is not possible.', E_USER_ERROR); } - + $manager->setParams($reporter); + $manager->testCaseFile = $testCaseFile; + xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); + } + +/** + * Set the parameters from a reporter to the CodeCoverageManager + * + * @return void + */ + function setParams(&$reporter) { if ($reporter->params['app']) { - $manager->appTest = true; + $this->appTest = true; } if ($reporter->params['group']) { - $manager->groupTest = true; + $this->groupTest = true; } if ($reporter->params['plugin']) { - $manager->pluginTest = Inflector::underscore($reporter->params['plugin']); + $this->pluginTest = Inflector::underscore($reporter->params['plugin']); } - $manager->testCaseFile = $testCaseFile; - xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); } /** * Stops the current code coverage analyzation and dumps a nice report depending on the reporter that was passed to start() * * @return void + * @static */ function report($output = true) { $manager =& CodeCoverageManager::getInstance(); @@ -212,6 +222,7 @@ class CodeCoverageManager { * @param string $execCodeLines * @param string $output * @return void + * @static */ function reportCaseHtml($testObjectFile, $coverageData, $execCodeLines) { $manager = CodeCoverageManager::getInstance(); @@ -248,6 +259,7 @@ class CodeCoverageManager { * @param string $execCodeLines * @param string $output * @return void + * @static */ function reportCaseHtmlDiff($testObjectFile, $coverageData, $execCodeLines, $numContextLines) { $manager = CodeCoverageManager::getInstance(); @@ -366,6 +378,7 @@ class CodeCoverageManager { * @param string $execCodeLines * @param string $output * @return void + * @static */ function reportCaseCli($testObjectFile, $coverageData, $execCodeLines) { $manager = CodeCoverageManager::getInstance(); @@ -396,6 +409,7 @@ class CodeCoverageManager { * @param string $execCodeLines * @param string $output * @return void + * @static */ function reportGroupHtml($testObjectFiles, $coverageData, $execCodeLines, $numContextLines) { $manager = CodeCoverageManager::getInstance(); @@ -436,6 +450,7 @@ class CodeCoverageManager { * @param string $execCodeLines * @param string $output * @return void + * @static */ function reportGroupCli($testObjectFiles, $coverageData, $execCodeLines) { $manager = CodeCoverageManager::getInstance(); From 6147de77259dad9439a6863744394b4637e4c657 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 12:52:06 -0500 Subject: [PATCH 095/137] Fixing notice errors in test case. --- cake/tests/cases/libs/view/view.test.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index d13b1d58f..42e315819 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -697,6 +697,7 @@ class ViewTest extends CakeTestCase { $this->PostsController->helpers = array('Cache', 'Html'); $this->PostsController->constructClasses(); $this->PostsController->cacheAction = array('index' => 3600); + $this->PostsController->params['action'] = 'index'; Configure::write('Cache.check', true); $View = new TestView($this->PostsController); From 3dad64c9c0c274cb26faddacad4f41002a9f59d0 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 13:05:35 -0500 Subject: [PATCH 096/137] Moving buffer start in CakeHtmlReporter to fix errors when displaying menus. Adding paintDocumentStart() to CakeTextReporter::paintHeader() to fix issues with test results not being text/plain. --- cake/tests/lib/reporter/cake_html_reporter.php | 2 +- cake/tests/lib/reporter/cake_text_reporter.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index b7e0934e9..81b2c9663 100644 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -38,7 +38,6 @@ class CakeHtmlReporter extends CakeBaseReporter { */ function paintHeader($testName) { $this->sendNoCacheHeaders(); - ob_start(); $this->paintDocumentStart(); $this->paintTestMenu(); echo "

        $testName

        \n"; @@ -51,6 +50,7 @@ class CakeHtmlReporter extends CakeBaseReporter { * @return void */ function paintDocumentStart() { + ob_start(); $baseDir = $this->params['baseDir']; include CAKE_TESTS_LIB . 'templates' . DS . 'header.php'; } diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index 7d3b7f5e5..8de320821 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -72,6 +72,7 @@ class CakeTextReporter extends CakeBaseReporter { * @access public */ function paintHeader($test_name) { + $this->paintDocumentStart(); echo "$test_name\n"; flush(); } From b83f3d37c8b2ffd1bbfe4a991cf02a29bf94884c Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 13:06:11 -0500 Subject: [PATCH 097/137] Removing unused method. --- cake/tests/lib/code_coverage_manager.php | 37 ------------------------ 1 file changed, 37 deletions(-) diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index 3dee49713..1c19791e4 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -214,43 +214,6 @@ class CodeCoverageManager { } } -/** - * Html reporting - * - * @param string $testObjectFile - * @param string $coverageData - * @param string $execCodeLines - * @param string $output - * @return void - * @static - */ - function reportCaseHtml($testObjectFile, $coverageData, $execCodeLines) { - $manager = CodeCoverageManager::getInstance(); - $lineCount = $coveredCount = 0; - $report = ''; - - foreach ($testObjectFile as $num => $line) { - $num++; - $foundByManualFinder = isset($execCodeLines[$num]) && trim($execCodeLines[$num]) != ''; - $foundByXdebug = isset($coverageData[$num]) && $coverageData[$num] !== -2; - - // xdebug does not find all executable lines (zend engine fault) - if ($foundByManualFinder && $foundByXdebug) { - $class = 'uncovered'; - $lineCount++; - - if ($coverageData[$num] > 0) { - $class = 'covered'; - $coveredCount++; - } - } else { - $class = 'ignored'; - } - $report .= $manager->__paintCodeline($class, $num, $line); - } - return $manager->__paintHeader($lineCount, $coveredCount, $report); - } - /** * Diff reporting * From da26124add3ef94e6f232b9d8a310e68a357b2fc Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 13:23:37 -0500 Subject: [PATCH 098/137] Renaming CodeCoverageManager::start() to init(). Adding a start(), stop(), and clear() methods to CodeCoverageManager. Making CakeBaseReporter toggle code coverage on and off as needed. Updating test case for CodeCoverageManager. --- .../cases/libs/code_coverage_manager.test.php | 6 +-- cake/tests/lib/code_coverage_manager.php | 44 ++++++++++++++++--- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/cake/tests/cases/libs/code_coverage_manager.test.php b/cake/tests/cases/libs/code_coverage_manager.test.php index b07c3f6cf..29caa3c7a 100644 --- a/cake/tests/cases/libs/code_coverage_manager.test.php +++ b/cake/tests/cases/libs/code_coverage_manager.test.php @@ -66,11 +66,11 @@ class CodeCoverageManagerTest extends CakeTestCase { if (PHP_SAPI != 'cli') { $reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false)); - CodeCoverageManager::start(substr(md5(microtime()), 0, 5), $reporter); + CodeCoverageManager::init(substr(md5(microtime()), 0, 5), $reporter); CodeCoverageManager::report(false); $this->assertError(); - CodeCoverageManager::start('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter); + CodeCoverageManager::init('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter); CodeCoverageManager::report(false); $this->assertError(); @@ -96,7 +96,7 @@ class CodeCoverageManagerTest extends CakeTestCase { $contents[1] = array_filter($contents[1], "remove"); foreach ($contents[1] as $file) { - CodeCoverageManager::start('libs'.DS.$file, $reporter); + CodeCoverageManager::init('libs'.DS.$file, $reporter); CodeCoverageManager::report(false); $this->assertNoErrors('libs'.DS.$file); } diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index 1c19791e4..b207c7707 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -87,15 +87,14 @@ class CodeCoverageManager { } /** - * Starts a new Coverage Analyzation for a given test case file - * @TODO: Works with $_GET now within the function body, which will make it hard when we do code coverage reports for CLI + * Initializes a new Coverage Analyzation for a given test case file * - * @param string $testCaseFile - * @param string $reporter + * @param string $testCaseFile The test case file being covered. + * @param object $reporter Instance of the reporter running. * @return void * @static */ - function start($testCaseFile, &$reporter) { + function init($testCaseFile, &$reporter) { $manager =& CodeCoverageManager::getInstance(); $manager->reporter =& $reporter; $testCaseFile = str_replace(DS . DS, DS, $testCaseFile); @@ -106,9 +105,41 @@ class CodeCoverageManager { } $manager->setParams($reporter); $manager->testCaseFile = $testCaseFile; + CodeCoverageManager::start(); + } + +/** + * Start/resume Code coverage collection. + * + * @return void + * @static + */ + function start() { xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); } +/** + * Stops/pauses code coverage collection. Does not clean the + * code coverage memory. Use clean() to clear code coverage memory + * + * @return void + * @static + */ + function stop() { + xdebug_stop_code_coverage(false); + } + +/** + * Clears the existing code coverage information. Also stops any + * running collection. + * + * @return void + * @static + */ + function clear() { + xdebug_stop_code_coverage(); + } + /** * Set the parameters from a reporter to the CodeCoverageManager * @@ -137,6 +168,8 @@ class CodeCoverageManager { function report($output = true) { $manager =& CodeCoverageManager::getInstance(); + CodeCoverageManager::stop(); + if (!$manager->groupTest) { $testObjectFile = $manager->__testObjectFileFromCaseFile($manager->testCaseFile, $manager->appTest); @@ -145,7 +178,6 @@ class CodeCoverageManager { return ; } $dump = xdebug_get_code_coverage(); - xdebug_stop_code_coverage(); $coverageData = array(); foreach ($dump as $file => $data) { From d7164c416e27e762ba6973c82b57a68ff0fc04b1 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 13:24:41 -0500 Subject: [PATCH 099/137] Adding code coverage toggling to CakeBaseReporter. Updating CodeCoverageManager method use in CakeTestSuiteDispatcher. --- cake/tests/lib/cake_test_suite_dispatcher.php | 4 +-- .../tests/lib/reporter/cake_base_reporter.php | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 7ba5f7596..445636693 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -227,7 +227,7 @@ class CakeTestSuiteDispatcher { $this->Manager->runAllTests($Reporter); } else { if ($this->params['codeCoverage']) { - CodeCoverageManager::start($this->params['group'], $Reporter); + CodeCoverageManager::init($this->params['group'], $Reporter); } $this->Manager->runGroupTest(ucfirst($this->params['group']), $Reporter); } @@ -241,7 +241,7 @@ class CakeTestSuiteDispatcher { function _runTestCase() { $Reporter =& CakeTestSuiteDispatcher::getReporter(); if ($this->params['codeCoverage']) { - CodeCoverageManager::start($this->params['case'], $Reporter); + CodeCoverageManager::init($this->params['case'], $Reporter); } $this->Manager->runTestCase($this->params['case'], $Reporter); } diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index 7a12fd3ae..c634f89d0 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -75,6 +75,7 @@ class CakeBaseReporter extends SimpleReporter { * - plugin - Plugin test being run? * - app - App test being run. * - case - The case being run + * - codeCoverage - Whether the case/group being run is being code covered. * * @param string $charset The character set to output with. Defaults to UTF-8 * @param array $params Array of request parameters the reporter should use. See above. @@ -117,6 +118,34 @@ class CakeBaseReporter extends SimpleReporter { parent::paintGroupEnd($test_name); } +/** + * Paints the beginning of a test method being run. This is used + * to start/resume the code coverage tool. + * + * @param string $method The method name being run. + * @return void + */ + function paintMethodStart($method) { + parent::paintMethodStart($method); + if (!empty($this->params['codeCoverage'])) { + CodeCoverageManager::start(); + } + } + +/** + * Paints the end of a test method being run. This is used + * to pause the collection of code coverage if its being used. + * + * @param string $method The name of the method being run. + * @return void + */ + function paintMethodEnd($method) { + parent::paintMethodEnd($method); + if (!empty($this->params['codeCoverage'])) { + CodeCoverageManager::stop(); + } + } + /** * Get the current time in microseconds. Similar to getMicrotime in basics.php * but in a separate function to reduce dependancies. From 645807211b9ec7f5e9cb4c07afd8748645935631 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 13:39:41 -0500 Subject: [PATCH 100/137] Adding clear to CodeCoverageManager. --- cake/tests/lib/code_coverage_manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index b207c7707..0aac099ce 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -214,7 +214,6 @@ class CodeCoverageManager { } } $dump = xdebug_get_code_coverage(); - xdebug_stop_code_coverage(); $coverageData = array(); foreach ($dump as $file => $data) { if (in_array($file, $testObjectFiles)) { @@ -240,6 +239,7 @@ class CodeCoverageManager { break; } } + CodeCoverageManager::clear(); if ($output) { echo $result; From 5a88aaf909a7f87af95ad567d1c4a028a19e4702 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 15:28:29 -0500 Subject: [PATCH 101/137] Refactoring loops in CodeCoverageManager --- cake/tests/lib/code_coverage_manager.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index 0aac099ce..4b975ab53 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -105,7 +105,6 @@ class CodeCoverageManager { } $manager->setParams($reporter); $manager->testCaseFile = $testCaseFile; - CodeCoverageManager::start(); } /** @@ -180,11 +179,8 @@ class CodeCoverageManager { $dump = xdebug_get_code_coverage(); $coverageData = array(); - foreach ($dump as $file => $data) { - if ($file == $testObjectFile) { - $coverageData = $data; - break; - } + if (isset($dump[$testObjectFile])) { + $coverageData = $dump[$testObjectFile]; } if (empty($coverageData) && $output) { @@ -215,9 +211,10 @@ class CodeCoverageManager { } $dump = xdebug_get_code_coverage(); $coverageData = array(); - foreach ($dump as $file => $data) { - if (in_array($file, $testObjectFiles)) { - $coverageData[$file] = $data; + + foreach ($testObjectFiles as $file) { + if (isset($dump[$file])) { + $coverageData[$file] = $dump[$file]; } } From e7e1a9b15c7ef8d42a41c1700aa70b8af79728db Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 15:42:30 -0500 Subject: [PATCH 102/137] Further refactoring of code coverage manager. --- cake/tests/lib/code_coverage_manager.php | 88 +++++++++++++----------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index 4b975ab53..ddd1eefe9 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -168,24 +168,15 @@ class CodeCoverageManager { $manager =& CodeCoverageManager::getInstance(); CodeCoverageManager::stop(); + CodeCoverageManager::clear(); + + list($coverageData, $testObjectFile) = $manager->_getCoverageData(); + + if (empty($coverageData) && $output) { + echo 'The test object file is never loaded.'; + } if (!$manager->groupTest) { - $testObjectFile = $manager->__testObjectFileFromCaseFile($manager->testCaseFile, $manager->appTest); - - if (!file_exists($testObjectFile)) { - trigger_error('This test object file is invalid: ' . $testObjectFile); - return ; - } - $dump = xdebug_get_code_coverage(); - $coverageData = array(); - - if (isset($dump[$testObjectFile])) { - $coverageData = $dump[$testObjectFile]; - } - - if (empty($coverageData) && $output) { - echo 'The test object file is never loaded.'; - } $execCodeLines = $manager->__getExecutableLines(file_get_contents($testObjectFile)); $result = ''; @@ -201,48 +192,65 @@ class CodeCoverageManager { break; } } else { - $testObjectFiles = $manager->__testObjectFilesFromGroupFile($manager->testCaseFile, $manager->appTest); - - foreach ($testObjectFiles as $file) { - if (!file_exists($file)) { - trigger_error('This test object file is invalid: ' . $file); - return ; - } - } - $dump = xdebug_get_code_coverage(); - $coverageData = array(); - - foreach ($testObjectFiles as $file) { - if (isset($dump[$file])) { - $coverageData[$file] = $dump[$file]; - } - } - - if (empty($coverageData) && $output) { - echo 'The test object files are never loaded.'; - } - $execCodeLines = $manager->__getExecutableLines($testObjectFiles); + $execCodeLines = $manager->__getExecutableLines($testObjectFile); $result = ''; switch (get_class($manager->reporter)) { case 'CakeHtmlReporter': - $result = $manager->reportGroupHtml($testObjectFiles, $coverageData, $execCodeLines, $manager->numDiffContextLines); + $result = $manager->reportGroupHtml($testObjectFile, $coverageData, $execCodeLines, $manager->numDiffContextLines); break; case 'CLIReporter': - $result = $manager->reportGroupCli($testObjectFiles, $coverageData, $execCodeLines, $manager->numDiffContextLines); + $result = $manager->reportGroupCli($testObjectFile, $coverageData, $execCodeLines, $manager->numDiffContextLines); break; default: trigger_error('Currently only HTML and CLI reporting is supported for code coverage analysis.'); break; } } - CodeCoverageManager::clear(); if ($output) { echo $result; } } +/** + * Gets the coverage data for the test case or group test that is being run. + * + * @return void + */ + function _getCoverageData() { + $coverageData = array(); + $dump = xdebug_get_code_coverage(); + + if ($this->groupTest) { + $testObjectFile = $this->__testObjectFilesFromGroupFile($this->testCaseFile, $this->appTest); + + foreach ($testObjectFile as $file) { + if (!file_exists($file)) { + trigger_error('This test object file is invalid: ' . $file); + return ; + } + } + foreach ($testObjectFile as $file) { + if (isset($dump[$file])) { + $coverageData[$file] = $dump[$file]; + } + } + } else { + $testObjectFile = $this->__testObjectFileFromCaseFile($this->testCaseFile, $this->appTest); + + if (!file_exists($testObjectFile)) { + trigger_error('This test object file is invalid: ' . $testObjectFile); + return ; + } + + if (isset($dump[$testObjectFile])) { + $coverageData = $dump[$testObjectFile]; + } + } + return array($coverageData, $testObjectFile); + } + /** * Diff reporting * From 02dbbcdfc6806269af12abd8e20fc368d9408522 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 15:45:41 -0500 Subject: [PATCH 103/137] Fixing CliReporter class name as well as making cli/text output the default if the reporter is unknown. --- cake/tests/lib/code_coverage_manager.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index ddd1eefe9..dac048f90 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -159,7 +159,8 @@ class CodeCoverageManager { } /** - * Stops the current code coverage analyzation and dumps a nice report depending on the reporter that was passed to start() + * Stops the current code coverage analyzation and dumps a nice report + * depending on the reporter that was passed to start() * * @return void * @static @@ -185,10 +186,8 @@ class CodeCoverageManager { $result = $manager->reportCaseHtmlDiff(@file($testObjectFile), $coverageData, $execCodeLines, $manager->numDiffContextLines); break; case 'CakeCliReporter': - $result = $manager->reportCaseCli(@file($testObjectFile), $coverageData, $execCodeLines, $manager->numDiffContextLines); - break; default: - trigger_error('Currently only HTML and CLI reporting is supported for code coverage analysis.'); + $result = $manager->reportCaseCli(@file($testObjectFile), $coverageData, $execCodeLines, $manager->numDiffContextLines); break; } } else { @@ -199,11 +198,9 @@ class CodeCoverageManager { case 'CakeHtmlReporter': $result = $manager->reportGroupHtml($testObjectFile, $coverageData, $execCodeLines, $manager->numDiffContextLines); break; - case 'CLIReporter': - $result = $manager->reportGroupCli($testObjectFile, $coverageData, $execCodeLines, $manager->numDiffContextLines); - break; + case 'CakeCliReporter': default: - trigger_error('Currently only HTML and CLI reporting is supported for code coverage analysis.'); + $result = $manager->reportGroupCli($testObjectFile, $coverageData, $execCodeLines, $manager->numDiffContextLines); break; } } From 980a85cec494e6a2c0854fef8149e82182c23418 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 15:55:09 -0500 Subject: [PATCH 104/137] Updating testsuite shell to use new CodeCoverage methods. --- cake/console/libs/testsuite.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php index 162119a28..bc261d36e 100644 --- a/cake/console/libs/testsuite.php +++ b/cake/console/libs/testsuite.php @@ -307,7 +307,8 @@ class TestSuiteShell extends Shell { if ($this->doCoverage) { require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php'; - CodeCoverageManager::start($ucFirstGroup, $Reporter); + CodeCoverageManager::init($ucFirstGroup, $Reporter); + CodeCoverageManager::start(); } $result = $this->Manager->runGroupTest($ucFirstGroup, $Reporter); if ($this->doCoverage) { @@ -330,7 +331,8 @@ class TestSuiteShell extends Shell { if ($this->doCoverage) { require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php'; - CodeCoverageManager::start($case, $Reporter); + CodeCoverageManager::init($case, $Reporter); + CodeCoverageManager::start(); } $result = $this->Manager->runTestCase($case, $Reporter); From 9989327b5b26bf3079e2f9665cc74b7e5edd9749 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 15:55:49 -0500 Subject: [PATCH 105/137] Fixing constructor of CakeCliReporter to match CakeBaseReporter. --- cake/tests/lib/reporter/cake_cli_reporter.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cake/tests/lib/reporter/cake_cli_reporter.php b/cake/tests/lib/reporter/cake_cli_reporter.php index b736ce4d1..61775842c 100644 --- a/cake/tests/lib/reporter/cake_cli_reporter.php +++ b/cake/tests/lib/reporter/cake_cli_reporter.php @@ -55,11 +55,8 @@ class CakeCliReporter extends CakeBaseReporter { * @param array $params * @return void */ - function CakeCLIReporter($separator = NULL, $params = array()) { - $this->CakeBaseReporter('utf-8', $params); - if (!is_null($separator)) { - $this->setFailDetailSeparator($separator); - } + function CakeCLIReporter($charset = 'utf-8', $params = array()) { + $this->CakeBaseReporter($charset, $params); } function setFailDetailSeparator($separator) { From 489958ea48f43e1832130d527ceb76ca4b22ee8f Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 15:56:24 -0500 Subject: [PATCH 106/137] CakeTextReporter now outputs code coverage. --- cake/tests/lib/reporter/cake_text_reporter.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index 8de320821..68dd09b6c 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -62,6 +62,13 @@ class CakeTextReporter extends CakeBaseReporter { if (function_exists('memory_get_peak_usage')) { echo 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n"; } + if ( + isset($this->params['codeCoverage']) && + $this->params['codeCoverage'] && + class_exists('CodeCoverageManager') + ) { + CodeCoverageManager::report(); + } } /** From 84e70c1db1e8075427f20d510f035f081f701246 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 10 Jan 2010 15:56:51 -0500 Subject: [PATCH 107/137] Adding linebreak for text/cli output situations. --- cake/tests/lib/code_coverage_manager.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index dac048f90..503a7dcdf 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -174,7 +174,7 @@ class CodeCoverageManager { list($coverageData, $testObjectFile) = $manager->_getCoverageData(); if (empty($coverageData) && $output) { - echo 'The test object file is never loaded.'; + echo "The test object file is never loaded.\n"; } if (!$manager->groupTest) { @@ -221,7 +221,6 @@ class CodeCoverageManager { if ($this->groupTest) { $testObjectFile = $this->__testObjectFilesFromGroupFile($this->testCaseFile, $this->appTest); - foreach ($testObjectFile as $file) { if (!file_exists($file)) { trigger_error('This test object file is invalid: ' . $file); From 04562982b241ac2744e77283edad95f82806ff23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 11 Jan 2010 15:34:16 -0430 Subject: [PATCH 108/137] Fixing doc block --- cake/tests/cases/libs/model/datasources/dbo_source.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 0cd9bc0f9..f0d4f4b49 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -4242,7 +4242,7 @@ class DboSourceTest extends CakeTestCase { } /** - * test calculate to generate claculate statements on virtual fields + * test group to generate GROUP BY statements on virtual fields * * @return void */ From 07b43be1259212d7d4146d4f77d55cf0adf4b42c Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 11 Jan 2010 18:00:45 -0500 Subject: [PATCH 109/137] Making CLI case code coverage reports include text. --- cake/tests/lib/code_coverage_manager.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/code_coverage_manager.php b/cake/tests/lib/code_coverage_manager.php index 503a7dcdf..946842901 100644 --- a/cake/tests/lib/code_coverage_manager.php +++ b/cake/tests/lib/code_coverage_manager.php @@ -681,7 +681,6 @@ class CodeCoverageManager { $manager =& CodeCoverageManager::getInstance(); $codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount); $class = 'bad'; - if ($codeCoverage > 50) { $class = 'ok'; } @@ -702,7 +701,14 @@ class CodeCoverageManager { function __paintHeaderCli($lineCount, $coveredCount, $report) { $manager =& CodeCoverageManager::getInstance(); $codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount); - return $report = 'Code Coverage: ' . $codeCoverage . '%'; + $class = 'bad'; + if ($codeCoverage > 50) { + $class = 'ok'; + } + if ($codeCoverage > 80) { + $class = 'good'; + } + return $report = "Code Coverage: $codeCoverage% ($class)\n"; } /** From 0803e2a5a69dca16a72145387d2ff5ea8e9b328f Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 11 Jan 2010 18:04:08 -0500 Subject: [PATCH 110/137] Moving CLI code coverage generation into the CliReporter. --- cake/tests/lib/reporter/cake_cli_reporter.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cake/tests/lib/reporter/cake_cli_reporter.php b/cake/tests/lib/reporter/cake_cli_reporter.php index 61775842c..654cfce2e 100644 --- a/cake/tests/lib/reporter/cake_cli_reporter.php +++ b/cake/tests/lib/reporter/cake_cli_reporter.php @@ -152,6 +152,14 @@ class CakeCliReporter extends CakeBaseReporter { } else { fwrite(STDOUT, $buffer . $this->getPassCount() . " passes.\n" . $this->_timeStats()); } + + if ( + isset($this->params['codeCoverage']) && + $this->params['codeCoverage'] && + class_exists('CodeCoverageManager') + ) { + CodeCoverageManager::report(); + } } /** From 4a96f52be98757997f3af6e4b44a36e7c682900b Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 11 Jan 2010 18:04:38 -0500 Subject: [PATCH 111/137] Refactoring testsuite shell and consolidating duplicated filename generation logic. --- cake/console/libs/testsuite.php | 105 ++++++++++++++------------------ 1 file changed, 46 insertions(+), 59 deletions(-) diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php index bc261d36e..0eee7555f 100644 --- a/cake/console/libs/testsuite.php +++ b/cake/console/libs/testsuite.php @@ -237,32 +237,12 @@ class TestSuiteShell extends Shell { $this->err(sprintf(__('%s is invalid. Should be case, group or all', true), $this->type)); return false; } - $ext = $this->Manager->getExtension($this->type); - switch ($this->type) { - case 'all': - return true; - case 'group': - if (file_exists($folder . DS . 'groups' . DS . $this->file . $ext)) { - return true; - } - break; - case 'case': - if ($this->category == 'app' && file_exists($folder . DS . 'cases' . DS . $this->file . $ext)) { - return true; - } - $coreCaseExists = file_exists($folder . DS . 'cases' . DS . $this->file . $ext); - $coreLibCaseExists = file_exists($folder . DS . 'cases' . DS . 'libs' . DS . $this->file . $ext); - if ($this->category == 'core' && ($coreCaseExists || $coreLibCaseExists)) { - return true; - } - - if ($isPlugin && file_exists($folder . DS . 'cases' . DS . $this->file . $ext)) { - return true; - } - break; + $fileName = $this->__getFileName($folder, $this->isPluginTest); + if ($fileName === true || file_exists($folder . $fileName)) { + return true; } - + $message = sprintf( __('%s %s %s is an invalid test identifier', true), $this->category, $this->type, $this->file @@ -270,7 +250,6 @@ class TestSuiteShell extends Shell { $this->err($message); return false; } - /** * Executes the tests depending on our settings * @@ -281,7 +260,8 @@ class TestSuiteShell extends Shell { $Reporter = new CakeCliReporter('utf-8', array( 'app' => $this->Manager->appTest, 'plugin' => $this->Manager->pluginTest, - 'group' => ($this->type === 'group') + 'group' => ($this->type === 'group'), + 'codeCoverage' => $this->doCoverage )); if ($this->type == 'all') { @@ -291,62 +271,68 @@ class TestSuiteShell extends Shell { if ($this->doCoverage) { if (!extension_loaded('xdebug')) { $this->out(__('You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation. Download it from http://www.xdebug.org/docs/install', true)); - exit(0); + $this->_stop(0); } } if ($this->type == 'group') { $ucFirstGroup = ucfirst($this->file); - - $path = CORE_TEST_GROUPS; - if ($this->category == 'app') { - $path = APP_TEST_GROUPS; - } elseif ($this->isPluginTest) { - $path = APP . 'plugins' . DS . $this->category . DS . 'tests' . DS . 'groups'; - } - if ($this->doCoverage) { require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php'; CodeCoverageManager::init($ucFirstGroup, $Reporter); CodeCoverageManager::start(); } $result = $this->Manager->runGroupTest($ucFirstGroup, $Reporter); - if ($this->doCoverage) { - CodeCoverageManager::report(); - } return $result; } - if ($this->category === 'core') { - $coreCaseExists = file_exists(CORE_TEST_CASES . DS . $this->file . '.test.php'); - if ($coreCaseExists) { - $case = $this->file . '.test.php'; - } else { - $case = 'libs' . DS . $this->file . '.test.php'; - } - } elseif ($this->category === 'app') { - $case = $this->file . '.test.php'; - } elseif ($this->isPluginTest) { - $case = $this->file . '.test.php'; - } + + $folder = $folder = $this->__findFolderByCategory($this->category); + $case = $this->__getFileName($folder, $this->isPluginTest); if ($this->doCoverage) { require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php'; CodeCoverageManager::init($case, $Reporter); CodeCoverageManager::start(); } - $result = $this->Manager->runTestCase($case, $Reporter); - if ($this->doCoverage) { - CodeCoverageManager::report(); - $this->out(); - } - return $result; } /** - * Finds the correct folder to look for tests for based on the input category + * Gets the concrete filename for the inputted test name and category/type * + * @param string $folder Folder name to look for files in. + * @param boolean $isPlugin If the test case is a plugin. + * @return mixed Either string filename or boolean false on failure. Or true if the type is 'all' + * @access private + */ + function __getFileName($folder, $isPlugin) { + $ext = $this->Manager->getExtension($this->type); + switch ($this->type) { + case 'all': + return true; + case 'group': + return $this->file . $ext; + case 'case': + if ($this->category == 'app' || $isPlugin) { + return $this->file . $ext; + } + $coreCase = $this->file . $ext; + $coreLibCase = 'libs' . DS . $this->file . $ext; + + if ($this->category == 'core' && file_exists($folder . DS . $coreCase)) { + return $coreCase; + } elseif ($this->category == 'core' && file_exists($folder . DS . $coreLibCase)) { + return $coreLibCase; + } + } + return false; + } + +/** + * Finds the correct folder to look for tests for based on the input category and type. + * + * @param string $category The category of the test. Either 'app', 'core' or a plugin name. * @return string the folder path * @access private */ @@ -356,13 +342,14 @@ class TestSuiteShell extends Shell { 'core' => CAKE, 'app' => APP ); + $typeDir = $this->type === 'group' ? 'groups' : 'cases'; if (array_key_exists($category, $paths)) { - $folder = $paths[$category] . 'tests'; + $folder = $paths[$category] . 'tests' . DS . $typeDir . DS; } else { $pluginPath = App::pluginPath($category); if (is_dir($pluginPath . 'tests')) { - $folder = $pluginPath . 'tests' . DS; + $folder = $pluginPath . 'tests' . DS . $typeDir . DS; } } return $folder; From a0c3c4b8036faebc000b4112515a225a8bc0d54a Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 11 Jan 2010 23:54:06 -0500 Subject: [PATCH 112/137] Updating AuthComponent::startup() so that being redirected to loginAction with no Auth.redirect value in the session and a non empty loginRedirect defined, the Auth.redirect value is not overwritten. This prevents redirection to already accessible pages. Test cases updated. Fixes #173 --- cake/libs/controller/components/auth.php | 2 +- .../libs/controller/components/auth.test.php | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 13a6fb29a..b391b972b 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -337,7 +337,7 @@ class AuthComponent extends Object { if ($loginAction == $url) { $model =& $this->getModel(); if (empty($controller->data) || !isset($controller->data[$model->alias])) { - if (!$this->Session->check('Auth.redirect') && env('HTTP_REFERER')) { + if (!$this->Session->check('Auth.redirect') && !$this->loginRedirect && env('HTTP_REFERER')) { $this->Session->write('Auth.redirect', $controller->referer(null, true)); } return false; diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 202c53043..874fb1e13 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -623,6 +623,31 @@ class AuthTest extends CakeTestCase { $this->Controller->Session->delete('Auth'); } +/** + * test that being redirected to the login page, with no post data does + * not set the session value. Saving the session value in this circumstance + * can cause the user to be redirected to an already public page. + * + * @return void + */ + function testLoginActionNotSettingAuthRedirect() { + $_referer = $_SERVER['HTTP_REFERER']; + $_SERVER['HTTP_REFERER'] = '/pages/display/about'; + + $this->Controller->data = array(); + $this->Controller->params = Router::parse('auth_test/login'); + $this->Controller->params['url']['url'] = 'auth_test/login'; + $this->Controller->Session->delete('Auth'); + + $this->Controller->Auth->loginRedirect = '/users/dashboard'; + $this->Controller->Auth->loginAction = 'auth_test/login'; + $this->Controller->Auth->userModel = 'AuthUser'; + + $this->Controller->Auth->startup($this->Controller); + $redirect = $this->Controller->Session->read('Auth.redirect'); + $this->assertNull($redirect); + } + /** * testAuthorizeFalse method * From 637b0133a8b706bffa09f41071cc7bd6a5e8f7b4 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 12 Jan 2010 09:30:40 -0500 Subject: [PATCH 113/137] Removing memory limit configuration from test.php. Was problematic in that it would override php.ini settings which could be higher. --- app/webroot/test.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/webroot/test.php b/app/webroot/test.php index 7bdd62463..2e0aacb49 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -18,7 +18,6 @@ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ set_time_limit(0); -ini_set('memory_limit','128M'); ini_set('display_errors', 1); /** * Use the DS to separate the directories in other defines From dc00cfe539b5511522ed3d947c0dd2b221d15b8b Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 12 Jan 2010 18:28:16 -0500 Subject: [PATCH 114/137] Adding   to baked index files to fix rendering issues in IE. --- cake/console/templates/default/views/index.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/console/templates/default/views/index.ctp b/cake/console/templates/default/views/index.ctp index c0e7222ed..430f8ee17 100644 --- a/cake/console/templates/default/views/index.ctp +++ b/cake/console/templates/default/views/index.ctp @@ -48,7 +48,7 @@ } } if ($isKey !== true) { - echo "\t\t\n\t\t\t\n\t\t\n"; + echo "\t\t \n"; } } From 6ba16f31bf994dbff7a7ca8b0b77082348a449b9 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 12 Jan 2010 18:28:41 -0500 Subject: [PATCH 115/137] Updating generic css to work with IE7. --- app/webroot/css/cake.generic.css | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index ff38ae761..c9340ac63 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -1,6 +1,6 @@ /** * - * PHP versions 4 and 5 + * Generic CSS for CakePHP * * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) @@ -160,9 +160,11 @@ table tr td { vertical-align: top; border-bottom:1px solid #ddd; } -table tr:nth-child(2n) td, -table tr.altrow td { - background: #fafafa; +table tr:nth-child(2n) td { + background: #f5f5f5; +} +table .altrow td { + background: #f5f5f5; } td.actions { text-align: center; From 84840c7b04a30b0fab4651f99e3d38d8aa313180 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 12 Jan 2010 23:27:17 -0500 Subject: [PATCH 116/137] Fixing issues with magic input() type detection and adding/updating tests. --- cake/libs/view/helpers/form.php | 14 ++++++------- .../cases/libs/view/helpers/form.test.php | 21 ++++++++++++++----- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 69c207db2..bc4cf6b85 100755 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -661,9 +661,7 @@ class FormHelper extends AppHelper { $this->_introspectModel($modelKey); } - $userType = isset($options['type']) ? true : false; - - if (!$userType) { + if (!isset($options['type'])) { $options['type'] = 'text'; $fieldDef = array(); if (isset($options['options'])) { @@ -693,6 +691,9 @@ class FormHelper extends AppHelper { $options['type'] = 'hidden'; } } + if (preg_match('/_id$/', $fieldKey)) { + $options['type'] = 'select'; + } if ($modelKey === $fieldKey) { $options['type'] = 'select'; @@ -701,18 +702,15 @@ class FormHelper extends AppHelper { } } } - $types = array('text', 'checkbox', 'radio', 'select'); + $types = array('checkbox', 'radio', 'select'); - if (!isset($options['options']) && in_array($options['type'], $types) && !$userType) { + if (!isset($options['options']) && in_array($options['type'], $types)) { $view =& ClassRegistry::getObject('view'); $varName = Inflector::variable( Inflector::pluralize(preg_replace('/_id$/', '', $fieldKey)) ); $varOptions = $view->getVar($varName); if (is_array($varOptions)) { - if ($options['type'] !== 'radio') { - $options['type'] = 'select'; - } $options['options'] = $varOptions; } } diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 4fa394c50..0cd3fe540 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -2049,6 +2049,18 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * Test that magic input() selects can easily be converted into radio types without error. + * + * @return void + */ + function testInputMagicSelectChangeToRadio() { + $view =& ClassRegistry::getObject('view'); + $view->viewVars['users'] = array('value' => 'good', 'other' => 'bad'); + $result = $this->Form->input('Model.user_id', array('type' => 'radio')); + $this->assertPattern('/input type="radio"/', $result); + } + /** * testFormInputs method * @@ -5930,17 +5942,16 @@ class FormHelperTest extends CakeTestCase { $this->Form->data['ValidateProfile'][1]['ValidateItem'][2]['profile_id'] = '1'; $result = $this->Form->input('ValidateProfile.1.ValidateItem.2.profile_id'); $expected = array( - 'div' => array('class' => 'input text error'), + 'div' => array('class' => 'input select error'), 'label' => array('for' => 'ValidateProfile1ValidateItem2ProfileId'), 'Profile', '/label', - 'input' => array( - 'name' => 'data[ValidateProfile][1][ValidateItem][2][profile_id]', 'type' => 'text', - 'value' => '1', + 'select' => array( + 'name' => 'data[ValidateProfile][1][ValidateItem][2][profile_id]', 'id' => 'ValidateProfile1ValidateItem2ProfileId', - 'maxlength' => 8, 'class' => 'form-error' ), + '/select', array('div' => array('class' => 'error-message')), 'Error', '/div', From 54b566fcabde5815c8f6a2f4fa68d9437e7a5c31 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 00:07:53 -0500 Subject: [PATCH 117/137] Updating generic CSS fixing issues in IE7 and making actions column slightly wider. --- app/webroot/css/cake.generic.css | 40 ++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index c9340ac63..a968da7ab 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -21,7 +21,7 @@ padding:0; } -/* General Style Info */ +/** General Style Info **/ body { background: #003d4c; color: #fff; @@ -69,7 +69,7 @@ ul, li { margin: 0 12px; } -/* Layout */ +/** Layout **/ #container { text-align: left; } @@ -112,13 +112,13 @@ div.form, div.index, div.view { float:right; - width:81%; + width:76%; border-left:1px solid #666; padding:10px 2%; } div.actions { float:left; - width:11%; + width:16%; padding:10px 1.5%; } div.actions h3 { @@ -127,7 +127,7 @@ div.actions h3 { } -/* Tables */ +/** Tables **/ table { background: #fff; border-right:0; @@ -186,7 +186,7 @@ table td.actions a { color:#fff; } -/* Paging */ +/** Paging **/ div.paging { background:#fff; color: #ccc; @@ -203,7 +203,7 @@ div.paging span.current { div.paging span a { } -/* Scaffold View */ +/** Scaffold View **/ dl { line-height: 2em; margin: 0em 0em; @@ -223,12 +223,12 @@ dd { vertical-align: top; } -/* Forms */ +/** Forms **/ form { clear: both; margin-right: 20px; padding: 0; - width: 80%; + width: 95%; } fieldset { border: 1px solid #ccc; @@ -306,6 +306,9 @@ input[type=checkbox] { margin: 0px 6px 7px 2px; width: auto; } +div.checkbox label { + display: inline; +} input[type=radio] { float:left; width:auto; @@ -324,7 +327,7 @@ form .submit input[type=submit] { background: -webkit-gradient(linear, left top, left bottom, from(#a8ea9c), to(#62af56)); background-image: -moz-linear-gradient(top, #a8ea9c, #62af56); border-color: #2d6324; - color: #111; + color: #000; text-shadow: #8cee7c 0px 1px 0px; } form .submit input[type=submit]:hover { @@ -333,7 +336,7 @@ form .submit input[type=submit]:hover { background-image: -moz-linear-gradient(top, #85e573, #4ca83d); } -/* Notices and Errors */ +/** Notices and Errors **/ div.message { clear: both; color: #fff; @@ -378,19 +381,21 @@ p.error em { color: #fff; } -/* Actions */ +/** Actions **/ div.actions ul { - margin: 0px 0; + margin: 0; padding: 0; } div.actions li { margin:0 0 0.5em 0; list-style-type: none; white-space: nowrap; + padding: 0; } div.actions ul li a { - font-weight:normal; - display:block; + font-weight: normal; + display: block; + clear: both; } div.actions ul li a:hover { text-decoration: underline; @@ -411,6 +416,7 @@ td.actions a { border-radius:8px; text-decoration:none; text-shadow: #fff 0px 1px 0px; + min-width: 0; } input[type=submit]:hover, div.actions ul li a:hover, @@ -419,13 +425,13 @@ td.actions a:hover { background: -webkit-gradient(linear, left top, left bottom, from(#f7f7e1), to(#eeeca9)); } -/* Related */ +/** Related **/ div.related { clear: both; display: block; } -/* Debugging */ +/** Debugging **/ pre { color: #000; background: #f0f0f0; From 2de96390911cae311335c4ab1ebf4f59be59fdbc Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 00:12:45 -0500 Subject: [PATCH 118/137] Updating scaffolds to match new bake design. --- cake/libs/view/scaffolds/edit.ctp | 1 + cake/libs/view/scaffolds/index.ctp | 21 +++++++++++---------- cake/libs/view/scaffolds/view.ctp | 1 + 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cake/libs/view/scaffolds/edit.ctp b/cake/libs/view/scaffolds/edit.ctp index 0faa8c591..3bbaa3291 100644 --- a/cake/libs/view/scaffolds/edit.ctp +++ b/cake/libs/view/scaffolds/edit.ctp @@ -25,6 +25,7 @@ ?>
    +

      action != 'add'):?>
    • Html->link(__('Delete', true), array('action' => 'delete', $this->Form->value($modelClass.'.'.$primaryKey)), null, __('Are you sure you want to delete', true).' #' . $this->Form->value($modelClass.'.'.$primaryKey)); ?>
    • diff --git a/cake/libs/view/scaffolds/index.ctp b/cake/libs/view/scaffolds/index.ctp index d38bd9738..b94cc9110 100644 --- a/cake/libs/view/scaffolds/index.ctp +++ b/cake/libs/view/scaffolds/index.ctp @@ -19,11 +19,6 @@ ?>

      -

      Paginator->counter(array( - 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) -)); -?>

      @@ -67,13 +62,19 @@ endforeach; echo "\n"; ?>
      -
      -
      -Paginator->prev('<< ' . __('previous', true), array(), null, array('class' => 'disabled')) . "\n";?> - | Paginator->numbers() . "\n"?> -Paginator->next(__('next', true) .' >>', array(), null, array('class' => 'disabled')) . "\n";?> +

      Paginator->counter(array( + 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) + )); + ?>

      +
      + Paginator->prev('<< ' . __('previous', true), array(), null, array('class' => 'disabled')) . "\n";?> + | Paginator->numbers() . "\n"?> + Paginator->next(__('next', true) .' >>', array(), null, array('class' => 'disabled')) . "\n";?> +
      +

      • Html->link(sprintf(__('New %s', true), $singularHumanName), array('action' => 'add')); ?>
      +

        " .$this->Html->link(sprintf(__('Edit %s', true), $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " \n"; From 53f0771a48325e3e08b8d73d1270498a32052b8d Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 00:14:57 -0500 Subject: [PATCH 119/137] Fixing output of 'Actions' in bake templates. Now outputs a __() call. --- cake/console/templates/default/views/form.ctp | 2 +- cake/console/templates/default/views/index.ctp | 2 +- cake/console/templates/default/views/view.ctp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/console/templates/default/views/form.ctp b/cake/console/templates/default/views/form.ctp index 4438f9487..1f445f2a3 100644 --- a/cake/console/templates/default/views/form.ctp +++ b/cake/console/templates/default/views/form.ctp @@ -43,7 +43,7 @@ ?>
      -

      +

      "; ?>

      • Html->link(__('Delete', true), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?', true), \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>";?>
      • diff --git a/cake/console/templates/default/views/index.ctp b/cake/console/templates/default/views/index.ctp index 430f8ee17..35e059b8c 100644 --- a/cake/console/templates/default/views/index.ctp +++ b/cake/console/templates/default/views/index.ctp @@ -77,7 +77,7 @@
    -

    +

    "; ?>

    • Html->link(sprintf(__('New %s', true), __('{$singularHumanName}', true)), array('action' => 'add')); ?>";?>
    -

    +

    "; ?>

      Html->link(sprintf(__('Edit %s', true), __('{$singularHumanName}', true)), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> \n"; From f93094b6eaa860236db4903c234cc90a04af073a Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 00:17:15 -0500 Subject: [PATCH 120/137] Moving skel/config/sql to skel/config/schema Updating index.php and test.php in skel dir. --- .../skel/config/{sql => schema}/db_acl.php | 0 .../skel/config/{sql => schema}/db_acl.sql | 0 .../skel/config/{sql => schema}/i18n.php | 0 .../skel/config/{sql => schema}/i18n.sql | 0 .../skel/config/{sql => schema}/sessions.php | 0 .../skel/config/{sql => schema}/sessions.sql | 0 cake/console/templates/skel/webroot/index.php | 12 ++- cake/console/templates/skel/webroot/test.php | 85 +------------------ 8 files changed, 9 insertions(+), 88 deletions(-) rename cake/console/templates/skel/config/{sql => schema}/db_acl.php (100%) rename cake/console/templates/skel/config/{sql => schema}/db_acl.sql (100%) rename cake/console/templates/skel/config/{sql => schema}/i18n.php (100%) rename cake/console/templates/skel/config/{sql => schema}/i18n.sql (100%) rename cake/console/templates/skel/config/{sql => schema}/sessions.php (100%) rename cake/console/templates/skel/config/{sql => schema}/sessions.sql (100%) diff --git a/cake/console/templates/skel/config/sql/db_acl.php b/cake/console/templates/skel/config/schema/db_acl.php similarity index 100% rename from cake/console/templates/skel/config/sql/db_acl.php rename to cake/console/templates/skel/config/schema/db_acl.php diff --git a/cake/console/templates/skel/config/sql/db_acl.sql b/cake/console/templates/skel/config/schema/db_acl.sql similarity index 100% rename from cake/console/templates/skel/config/sql/db_acl.sql rename to cake/console/templates/skel/config/schema/db_acl.sql diff --git a/cake/console/templates/skel/config/sql/i18n.php b/cake/console/templates/skel/config/schema/i18n.php similarity index 100% rename from cake/console/templates/skel/config/sql/i18n.php rename to cake/console/templates/skel/config/schema/i18n.php diff --git a/cake/console/templates/skel/config/sql/i18n.sql b/cake/console/templates/skel/config/schema/i18n.sql similarity index 100% rename from cake/console/templates/skel/config/sql/i18n.sql rename to cake/console/templates/skel/config/schema/i18n.sql diff --git a/cake/console/templates/skel/config/sql/sessions.php b/cake/console/templates/skel/config/schema/sessions.php similarity index 100% rename from cake/console/templates/skel/config/sql/sessions.php rename to cake/console/templates/skel/config/schema/sessions.php diff --git a/cake/console/templates/skel/config/sql/sessions.sql b/cake/console/templates/skel/config/schema/sessions.sql similarity index 100% rename from cake/console/templates/skel/config/sql/sessions.sql rename to cake/console/templates/skel/config/schema/sessions.sql diff --git a/cake/console/templates/skel/webroot/index.php b/cake/console/templates/skel/webroot/index.php index ebb3c6c72..5935a869c 100644 --- a/cake/console/templates/skel/webroot/index.php +++ b/cake/console/templates/skel/webroot/index.php @@ -1,6 +1,8 @@ dispatch(); -if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { - CakePHPTestHeader(); - include CAKE_TESTS_LIB . 'simpletest.php'; - CakePHPTestSuiteFooter(); - exit(); -} - -$analyzeCodeCoverage = false; -if (isset($_GET['code_coverage'])) { - $analyzeCodeCoverage = true; - require_once CAKE_TESTS_LIB . 'code_coverage_manager.php'; - if (!extension_loaded('xdebug')) { - CakePHPTestHeader(); - include CAKE_TESTS_LIB . 'xdebug.php'; - CakePHPTestSuiteFooter(); - exit(); - } -} - -CakePHPTestHeader(); -CakePHPTestSuiteHeader(); -define('RUN_TEST_LINK', $_SERVER['PHP_SELF']); - -if (isset($_GET['group'])) { - if ('all' == $_GET['group']) { - TestManager::runAllTests(CakeTestsGetReporter()); - } else { - if ($analyzeCodeCoverage) { - CodeCoverageManager::start($_GET['group'], CakeTestsGetReporter()); - } - TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter()); - if ($analyzeCodeCoverage) { - CodeCoverageManager::report(); - } - } - - CakePHPTestRunMore(); - CakePHPTestAnalyzeCodeCoverage(); -} elseif (isset($_GET['case'])) { - if ($analyzeCodeCoverage) { - CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter()); - } - - TestManager::runTestCase($_GET['case'], CakeTestsGetReporter()); - - if ($analyzeCodeCoverage) { - CodeCoverageManager::report(); - } - - CakePHPTestRunMore(); - CakePHPTestAnalyzeCodeCoverage(); -} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') { - CakePHPTestCaseList(); -} else { - CakePHPTestGroupTestList(); -} -CakePHPTestSuiteFooter(); -$output = ob_get_clean(); -echo $output; ?> \ No newline at end of file From 1c542b6ea595956922d0ea9011b3a6300fc5e7d5 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 13 Jan 2010 11:02:45 -0200 Subject: [PATCH 121/137] Fixing var name when not have SimpleTest or XDebug installed. Signed-off-by: Mark Story --- cake/tests/lib/cake_test_suite_dispatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 445636693..cbbd6d4a6 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -109,7 +109,7 @@ class CakeTestSuiteDispatcher { */ function _checkSimpleTest() { if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { - $basePath = $this->_baseDir; + $baseDir = $this->_baseDir; include CAKE_TESTS_LIB . 'templates' . DS . 'simpletest.php'; exit(); } @@ -123,7 +123,7 @@ class CakeTestSuiteDispatcher { */ function _checkXdebug() { if (!extension_loaded('xdebug')) { - $basePath = $this->_baseDir; + $baseDir = $this->_baseDir; include CAKE_TESTS_LIB . 'templates' . DS . 'xdebug.php'; exit(); } From d8257518ded3be18d31ab88b4e61f6f1d15f5fea Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 13 Jan 2010 10:52:46 -0200 Subject: [PATCH 122/137] Fixing include in test of CodeCoverageManager. Fixes #196 Signed-off-by: Mark Story --- cake/tests/cases/libs/code_coverage_manager.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/code_coverage_manager.test.php b/cake/tests/cases/libs/code_coverage_manager.test.php index 29caa3c7a..a2e730c60 100644 --- a/cake/tests/cases/libs/code_coverage_manager.test.php +++ b/cake/tests/cases/libs/code_coverage_manager.test.php @@ -18,7 +18,7 @@ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php'; -require_once CAKE . 'tests' . DS . 'lib' . DS . 'cli_reporter.php'; +require_once CAKE . 'tests' . DS . 'lib' . DS . 'reporter' . DS . 'cake_cli_reporter.php'; /** * CodeCoverageManagerTest class From 8496055059ca46bcfc04c300076ca987643181ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 13 Jan 2010 12:57:41 -0430 Subject: [PATCH 123/137] Adding php5 check to avoid errors when using __get() or __isset() methods in models --- cake/libs/model/behaviors/acl.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/behaviors/acl.php b/cake/libs/model/behaviors/acl.php index 8bc2c3969..a103c5008 100644 --- a/cake/libs/model/behaviors/acl.php +++ b/cake/libs/model/behaviors/acl.php @@ -53,7 +53,11 @@ class AclBehavior extends ModelBehavior { if (!class_exists('AclNode')) { require LIBS . 'model' . DS . 'db_acl.php'; } - $model->{$type} =& ClassRegistry::init($type); + if (PHP5) { + $model->{$type} = ClassRegistry::init($type); + } else { + $model->{$type} =& ClassRegistry::init($type); + } if (!method_exists($model, 'parentNode')) { trigger_error("Callback parentNode() not defined in {$model->alias}", E_USER_WARNING); } From 848dc518abfde025faa48a1f5f2ae83a0199aad4 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 14 Jan 2010 04:13:39 +0530 Subject: [PATCH 124/137] Adding 'id' attribute to hidden field generated for multiple select and multiple checkboxes. Fixes issue where invalid markup was generated in case to multiple checkboxes --- cake/libs/view/helpers/form.php | 7 +++- .../cases/libs/view/helpers/form.test.php | 32 +++++++++---------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index bc4cf6b85..e8023ba96 100755 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -1310,7 +1310,12 @@ class FormHelper extends AppHelper { $style = ($attributes['multiple'] === 'checkbox') ? 'checkbox' : null; $template = ($style) ? 'checkboxmultiplestart' : 'selectmultiplestart'; $tag = $this->Html->tags[$template]; - $select[] = $this->hidden(null, array('value' => '', 'id' => null, 'secure' => false)); + $hiddenAttributes = array( + 'value' => '', + 'id' => $attributes['id'] . ($style ? '' : '_'), + 'secure' => false + ); + $select[] = $this->hidden(null, $hiddenAttributes); } else { $tag = $this->Html->tags['selectstart']; } diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 0cd3fe540..b9ee7dc99 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -1860,7 +1860,7 @@ class FormHelperTest extends CakeTestCase { $this->Form->data = array('Contact' => array('created' => null)); $result = $this->Form->input('Contact.created', array('type' => 'datetime', 'dateFormat' => 'NONE')); $this->assertPattern('/for\="ContactCreatedHour"/', $result); - + $this->Form->data = array('Contact' => array('created' => null)); $result = $this->Form->input('Contact.created', array('type' => 'datetime', 'timeFormat' => 'NONE')); $this->assertPattern('/for\="ContactCreatedMonth"/', $result); @@ -2015,7 +2015,7 @@ class FormHelperTest extends CakeTestCase { 'label' => array('for' => 'UserUser'), 'User', '/label', - 'input' => array('type' => 'hidden', 'name' => 'data[User][User]', 'value' => ''), + 'input' => array('type' => 'hidden', 'name' => 'data[User][User]', 'value' => '', 'id' => 'UserUser_'), 'select' => array('name' => 'data[User][User][]', 'id' => 'UserUser', 'multiple' => 'multiple'), array('option' => array('value' => '')), '/option', @@ -2267,7 +2267,7 @@ class FormHelperTest extends CakeTestCase { function testSelectAsCheckbox() { $result = $this->Form->select('Model.multi_field', array('first', 'second', 'third'), array(0, 1), array('multiple' => 'checkbox')); $expected = array( - 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => ''), + 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField'), array('div' => array('class' => 'checkbox')), array('input' => array('type' => 'checkbox', 'name' => 'data[Model][multi_field][]', 'checked' => 'checked', 'value' => '0', 'id' => 'ModelMultiField0')), array('label' => array('for' => 'ModelMultiField0', 'class' => 'selected')), @@ -2978,7 +2978,7 @@ class FormHelperTest extends CakeTestCase { ); $expected = array( 'input' => array( - 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '' + 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField_' ), 'select' => array( 'name' => 'data[Model][multi_field][]', @@ -3002,7 +3002,7 @@ class FormHelperTest extends CakeTestCase { ); $expected = array( 'input' => array( - 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '' + 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField_' ), 'select' => array( 'name' => 'data[Model][multi_field][]', @@ -3026,7 +3026,7 @@ class FormHelperTest extends CakeTestCase { ); $expected = array( 'input' => array( - 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '' + 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField_' ), 'select' => array( 'name' => 'data[Model][multi_field][]', 'id' => 'ModelMultiField', @@ -3075,7 +3075,7 @@ class FormHelperTest extends CakeTestCase { $result = $this->Form->input('ContactTag', array('div' => false, 'label' => false)); $expected = array( 'input' => array( - 'type' => 'hidden', 'name' => 'data[ContactTag][ContactTag]', 'value' => '' + 'type' => 'hidden', 'name' => 'data[ContactTag][ContactTag]', 'value' => '', 'id' => 'ContactTagContactTag_' ), 'select' => array( 'name' => 'data[ContactTag][ContactTag][]', 'id' => 'ContactTagContactTag', @@ -3110,7 +3110,7 @@ class FormHelperTest extends CakeTestCase { $expected = array( 'input' => array( - 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '' + 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField' ), array('div' => array('class' => 'checkbox')), array('input' => array( @@ -3149,7 +3149,7 @@ class FormHelperTest extends CakeTestCase { ); $expected = array( 'input' => array( - 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '' + 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField' ), array('div' => array('class' => 'checkbox')), array('input' => array( @@ -3186,7 +3186,7 @@ class FormHelperTest extends CakeTestCase { ); $expected = array( 'input' => array( - 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '' + 'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField' ), array('div' => array('class' => 'checkbox')), array('input' => array( @@ -3237,7 +3237,7 @@ class FormHelperTest extends CakeTestCase { array('label' => array('for' => 'ModelMultiField')), 'Multi Field', '/label', - 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => ''), + 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField'), array('div' => array('class' => 'checkbox')), array('input' => array('type' => 'checkbox', 'name' => 'data[Model][multi_field][]', 'value' => '0', 'id' => 'ModelMultiField0')), array('label' => array('for' => 'ModelMultiField0')), @@ -3266,7 +3266,7 @@ class FormHelperTest extends CakeTestCase { array('label' => array('for' => 'ModelMultiField')), 'Multi Field', '/label', - 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => ''), + 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField'), array('div' => array('class' => 'checkbox')), array('input' => array('type' => 'checkbox', 'name' => 'data[Model][multi_field][]', 'value' => 'a', 'id' => 'ModelMultiFieldA')), array('label' => array('for' => 'ModelMultiFieldA')), @@ -3291,7 +3291,7 @@ class FormHelperTest extends CakeTestCase { $result = $this->Form->input('Model.multi_field', array('options' => array('1' => 'first'), 'multiple' => 'checkbox', 'label' => false, 'div' => false)); $expected = array( - 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => ''), + 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField'), array('div' => array('class' => 'checkbox')), array('input' => array('type' => 'checkbox', 'name' => 'data[Model][multi_field][]', 'value' => '1', 'id' => 'ModelMultiField1')), array('label' => array('for' => 'ModelMultiField1')), @@ -3303,7 +3303,7 @@ class FormHelperTest extends CakeTestCase { $result = $this->Form->input('Model.multi_field', array('options' => array('2' => 'second'), 'multiple' => 'checkbox', 'label' => false, 'div' => false)); $expected = array( - 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => ''), + 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField'), array('div' => array('class' => 'checkbox')), array('input' => array('type' => 'checkbox', 'name' => 'data[Model][multi_field][]', 'value' => '2', 'id' => 'ModelMultiField2')), array('label' => array('for' => 'ModelMultiField2')), @@ -3923,7 +3923,7 @@ class FormHelperTest extends CakeTestCase { 'label' => array('for' => 'ContactTagContactTag'), 'Contact Tag', '/label', - array('input' => array('type' => 'hidden', 'name' => 'data[ContactTag][ContactTag]', 'value' => '')), + array('input' => array('type' => 'hidden', 'name' => 'data[ContactTag][ContactTag]', 'value' => '', 'id' => 'ContactTagContactTag_')), array('select' => array('name' => 'data[ContactTag][ContactTag][]', 'multiple' => 'multiple', 'id' => 'ContactTagContactTag')), '/select', '/div' @@ -5232,7 +5232,7 @@ class FormHelperTest extends CakeTestCase { $this->Form->create(); $result = $this->Form->select('People.People', $options, null, array('multiple' => true)); $expected = array( - 'input' => array('type' => 'hidden', 'name' => 'data[People][People]', 'value' => ''), + 'input' => array('type' => 'hidden', 'name' => 'data[People][People]', 'value' => '', 'id' => 'PeoplePeople_'), 'select' => array( 'name' => 'data[People][People][]', 'multiple' => 'multiple', 'id' => 'PeoplePeople' ), From 619f9210f36ab4e8665ba0e84b71c1904e1ae8c2 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 21:55:32 -0500 Subject: [PATCH 125/137] Removing orphaned method. --- cake/console/libs/testsuite.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php index 0eee7555f..e9a3c30ba 100644 --- a/cake/console/libs/testsuite.php +++ b/cake/console/libs/testsuite.php @@ -355,25 +355,6 @@ class TestSuiteShell extends Shell { return $folder; } -/** - * Sets some get vars needed for TestManager - * - * @return void - * @access private - */ - function __setGetVars() { - if (in_array($this->category, $this->plugins)) { - $_GET['plugin'] = $this->category; - } elseif (in_array(Inflector::humanize($this->category), $this->plugins)) { - $_GET['plugin'] = Inflector::humanize($this->category); - } elseif ($this->category == 'app') { - $_GET['app'] = true; - } - if ($this->type == 'group') { - $_GET['group'] = true; - } - } - /** * tries to install simpletest and exits gracefully if it is not there * From 943af988f679d12c5b383fa7362a7deb82835d84 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 22:37:30 -0500 Subject: [PATCH 126/137] Fixing alignment issues in tables. --- app/webroot/css/cake.generic.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index a968da7ab..3de408a0c 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -139,7 +139,7 @@ table { th { border:0; border-bottom:2px solid #555; - text-align: center; + text-align: left; padding:4px; } th a { From 8243afa38364ee5ee1aec91614cc834386560437 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 23:03:02 -0500 Subject: [PATCH 127/137] Updating css file in skel dir. --- .../skel/webroot/css/cake.generic.css | 196 ++++++++++++------ 1 file changed, 128 insertions(+), 68 deletions(-) diff --git a/cake/console/templates/skel/webroot/css/cake.generic.css b/cake/console/templates/skel/webroot/css/cake.generic.css index 6c68821e9..3de408a0c 100644 --- a/cake/console/templates/skel/webroot/css/cake.generic.css +++ b/cake/console/templates/skel/webroot/css/cake.generic.css @@ -1,6 +1,6 @@ /** * - * PHP versions 4 and 5 + * Generic CSS for CakePHP * * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) @@ -16,13 +16,12 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - * { margin:0; padding:0; } -/* General Style Info */ +/** General Style Info **/ body { background: #003d4c; color: #fff; @@ -31,14 +30,12 @@ body { margin: 0; } a { - background:#fff; color: #003d4c; text-decoration: underline; font-weight: bold; } a:hover { - background:#fff; - color: #003d4c; + color: #367889; text-decoration:none; } a img { @@ -46,37 +43,33 @@ a img { } h1, h2, h3, h4 { font-weight: normal; + margin-bottom:0.5em; } h1 { background:#fff; color: #003d4c; font-size: 100%; - margin: 0.1em 0; } h2 { background:#fff; color: #e32; - font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; + font-family:'Gill Sans','lucida grande', helvetica, arial, sans-serif; font-size: 190%; - margin: 0.3em 0; - padding-top: 0.8em; } h3 { color: #993; - font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; + font-family:'Gill Sans','lucida grande', helvetica, arial, sans-serif; font-size: 165%; - padding-top: 1.5em; } h4 { color: #993; font-weight: normal; - padding-top: 0.5em; } ul, li { margin: 0 12px; } -/* Layout */ +/** Layout **/ #container { text-align: left; } @@ -85,7 +78,8 @@ ul, li { padding: 10px 20px; } #header h1 { - background: #003d4c url('../img/cake.icon.gif') no-repeat left; + line-height:20px; + background: #003d4c url('../img/cake.icon.png') no-repeat left; color: #fff; padding: 0px 30px; } @@ -113,10 +107,29 @@ ul, li { text-align: right; } -/* Tables */ +/** containers **/ +div.form, +div.index, +div.view { + float:right; + width:76%; + border-left:1px solid #666; + padding:10px 2%; +} +div.actions { + float:left; + width:16%; + padding:10px 1.5%; +} +div.actions h3 { + padding-top:0; + color:#777; +} + + +/** Tables **/ table { background: #fff; - border:1px solid #ccc; border-right:0; clear: both; color: #333; @@ -124,39 +137,42 @@ table { width: 100%; } th { - background: #f2f2f2; - border:1px solid #bbb; - border-top: 1px solid #fff; - border-left: 1px solid #fff; - text-align: center; + border:0; + border-bottom:2px solid #555; + text-align: left; + padding:4px; } th a { - background:#f2f2f2; display: block; padding: 2px 4px; text-decoration: none; } -th a:hover { - background: #ccc; - color: #333; - text-decoration: none; +th a.asc:after { + content: ' ⇣'; +} +th a.desc:after { + content: ' ⇡'; } table tr td { background: #fff; - border-right: 1px solid #ccc; - padding: 4px; - text-align: center; + padding: 6px; + text-align: left; vertical-align: top; + border-bottom:1px solid #ddd; } -table tr.altrow td { - background: #f4f4f4; +table tr:nth-child(2n) td { + background: #f5f5f5; +} +table .altrow td { + background: #f5f5f5; } td.actions { text-align: center; white-space: nowrap; } -td.actions a { +table td.actions a { margin: 0px 6px; + padding:2px 5px; } .cake-sql-log table { background: #f4f4f4; @@ -164,27 +180,30 @@ td.actions a { .cake-sql-log td { padding: 4px 8px; text-align: left; + font-family: Monaco, Consolas, "Courier New", monospaced; +} +.cake-sql-log caption { + color:#fff; } -/* Paging */ +/** Paging **/ div.paging { background:#fff; color: #ccc; - margin-bottom: 2em; + margin-top: 1em; + clear:both; } -div.paging div.disabled { +div.paging span.disabled { color: #ddd; display: inline; } -div.paging span { -} div.paging span.current { - color: #000; + color: #c73e14; } div.paging span a { } -/* Scaffold View */ +/** Scaffold View **/ dl { line-height: 2em; margin: 0em 0em; @@ -204,16 +223,16 @@ dd { vertical-align: top; } -/* Forms */ +/** Forms **/ form { clear: both; margin-right: 20px; padding: 0; - width: 80%; + width: 95%; } fieldset { border: 1px solid #ccc; - margin-top: 30px; + margin-bottom: 1em; padding: 16px 20px; } fieldset legend { @@ -241,30 +260,33 @@ form div { padding: .5em; vertical-align: text-top; } -form div.input { +form .input { color: #444; } -form div.required { - color: #333; +form .required { font-weight: bold; } +form .required label:after { + color: #e32; + content: '*'; + display:inline; +} form div.submit { border: 0; clear: both; margin-top: 10px; - margin-left: 140px; } label { display: block; font-size: 110%; - padding-right: 20px; + margin-bottom:3px; } input, textarea { clear: both; font-size: 140%; font-family: "frutiger linotype", "lucida grande", "verdana", sans-serif; - padding: 2px; - width: 100%; + padding: 1%; + width:98%; } select { clear: both; @@ -284,6 +306,9 @@ input[type=checkbox] { margin: 0px 6px 7px 2px; width: auto; } +div.checkbox label { + display: inline; +} input[type=radio] { float:left; width:auto; @@ -295,23 +320,37 @@ div.radio label { input[type=submit] { display: inline; font-size: 110%; - padding: 2px 5px; width: auto; - vertical-align: bottom; +} +form .submit input[type=submit] { + background:#62af56; + background: -webkit-gradient(linear, left top, left bottom, from(#a8ea9c), to(#62af56)); + background-image: -moz-linear-gradient(top, #a8ea9c, #62af56); + border-color: #2d6324; + color: #000; + text-shadow: #8cee7c 0px 1px 0px; +} +form .submit input[type=submit]:hover { + background:#4ca83d; + background: -webkit-gradient(linear, left top, left bottom, from(#85e573), to(#4ca83d)); + background-image: -moz-linear-gradient(top, #85e573, #4ca83d); } -/* Notices and Errors */ +/** Notices and Errors **/ div.message { clear: both; - color: #900; + color: #fff; font-size: 140%; font-weight: bold; - margin: 1em 0; + margin: 0 0 1em 0; + background: #c73e14; + padding: 5px; } div.error-message { clear: both; - color: #900; + color: #fff; font-weight: bold; + background: #c73e14; } p.error { background-color: #e32; @@ -342,35 +381,57 @@ p.error em { color: #fff; } -/* Actions */ +/** Actions **/ div.actions ul { - margin: 0px 0; + margin: 0; padding: 0; } div.actions li { - display: inline; + margin:0 0 0.5em 0; list-style-type: none; - line-height: 2em; - margin: 0 2em 0 0; white-space: nowrap; + padding: 0; } div.actions ul li a { - background:#fff; - color: #003d4c; - text-decoration: none; + font-weight: normal; + display: block; + clear: both; } div.actions ul li a:hover { - color: #333; text-decoration: underline; } -/* Related */ +input[type=submit], +div.actions ul li a, +td.actions a { + font-weight:normal; + padding: 4px 8px; + background:#e6e49f; + background: -webkit-gradient(linear, left top, left bottom, from(#f1f1d4), to(#e6e49f)); + background-image: -moz-linear-gradient(top, #f1f1d4, #e6e49f); + color:#333; + border:1px solid #aaac62; + -webkit-border-radius:8px; + -moz-border-radius:8px; + border-radius:8px; + text-decoration:none; + text-shadow: #fff 0px 1px 0px; + min-width: 0; +} +input[type=submit]:hover, +div.actions ul li a:hover, +td.actions a:hover { + background: #f0f09a; + background: -webkit-gradient(linear, left top, left bottom, from(#f7f7e1), to(#eeeca9)); +} + +/** Related **/ div.related { clear: both; display: block; } -/* Debugging */ +/** Debugging **/ pre { color: #000; background: #f0f0f0; @@ -386,7 +447,6 @@ pre.cake-debug { } div.cake-stack-trace { background: #fff; - border: 4px dotted #ffcc00; color: #333; margin: 0px; padding: 6px; From ff3aefe93a0a37f55fdd0a2a62bb476293f3afd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Perras?= Date: Wed, 13 Jan 2010 21:53:44 -0500 Subject: [PATCH 128/137] Adding missing

      to Html test reporter template. --- cake/tests/lib/templates/footer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cake/tests/lib/templates/footer.php b/cake/tests/lib/templates/footer.php index eb970a657..0b443da0c 100644 --- a/cake/tests/lib/templates/footer.php +++ b/cake/tests/lib/templates/footer.php @@ -20,9 +20,11 @@ ?>
    Date: Wed, 13 Jan 2010 22:29:10 -0500 Subject: [PATCH 129/137] Updating CakeTestSuiteDispatcher parsing of . Better handling of cases where dirname() of PHP_SELF returns only '/'. --- cake/tests/lib/cake_test_suite_dispatcher.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index cbbd6d4a6..8b30cb6fa 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -76,7 +76,8 @@ class CakeTestSuiteDispatcher { */ function CakeTestSuiteDispatcher() { $this->_baseUrl = $_SERVER['PHP_SELF']; - $this->_baseDir = dirname($this->_baseUrl) . '/'; + $dir = dirname($this->_baseUrl); + $this->_baseDir = ($dir === '/') ? $dir : $dir . '/'; } /** From 4d1f6b82e809a8c5657d7d92e8b2e8a3b2a8a334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Perras?= Date: Wed, 13 Jan 2010 23:14:06 -0500 Subject: [PATCH 130/137] Removing use of subclass method 'fullTableName()' in Datasource superclass. Fixes #100. --- cake/libs/model/datasources/datasource.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index f016e2d18..99d3e8568 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -123,9 +123,9 @@ class DataSource extends Object { var $_queriesLog = array(); /** - * Maximum number of items in query log, to prevent query log taking over - * too much memory on large amounts of queries -- I we've had problems at - * >6000 queries on one system. + * Maximum number of items in query log + * + * This is to prevent query log taking over too much memory. * * @var int Maximum number of queries in the queries log. * @access protected @@ -270,7 +270,8 @@ class DataSource extends Object { if ($this->cacheSources === false) { return null; } - $table = $this->fullTableName($model, false); + $table = $model->tablePrefix . $model->table; + if (isset($this->__descriptions[$table])) { return $this->__descriptions[$table]; } @@ -374,7 +375,7 @@ class DataSource extends Object { * To-be-overridden in subclasses. * * @param Model $model The model class having record(s) deleted - * @param mixed $id Primary key of the model + * @param mixed $id Primary key of the model * @access public */ function delete(&$model, $id = null) { @@ -489,7 +490,7 @@ class DataSource extends Object { * @param array $data Array of data with values that will be inserted in placeholders. * @param string $association Name of association model being replaced * @param unknown_type $assocData - * @param Model $model Instance of the model to replace $__cakeID__$ + * @param Model $model Instance of the model to replace $__cakeID__$ * @param Model $linkModel Instance of model to replace $__cakeForeignKey__$ * @param array $stack * @return string String of query data with placeholders replaced. From 67b69b3106b373a9e6819c464d292c730a411ce3 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 23:47:31 -0500 Subject: [PATCH 131/137] Fixing failing tests due to deleted assets. --- cake/tests/cases/libs/view/helpers/html.test.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index 1f88bab7b..2b29ff8ea 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -301,23 +301,23 @@ class HtmlHelperTest extends CakeTestCase { * * @return void */ - function testImageTagWithTimestampping() { + function testImageWithTimestampping() { Configure::write('Asset.timestamp', 'force'); - $result = $this->Html->image('cake.icon.gif'); - $this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => ''))); + $result = $this->Html->image('cake.icon.png'); + $this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.png\?\d+/', 'alt' => ''))); Configure::write('debug', 0); Configure::write('Asset.timestamp', 'force'); - $result = $this->Html->image('cake.icon.gif'); - $this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => ''))); + $result = $this->Html->image('cake.icon.png'); + $this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.png\?\d+/', 'alt' => ''))); $webroot = $this->Html->webroot; $this->Html->webroot = '/testing/longer/'; - $result = $this->Html->image('cake.icon.gif'); + $result = $this->Html->image('cake.icon.png'); $expected = array( - 'img' => array('src' => 'preg:/\/testing\/longer\/img\/cake\.icon\.gif\?[0-9]+/', 'alt' => '') + 'img' => array('src' => 'preg:/\/testing\/longer\/img\/cake\.icon\.png\?[0-9]+/', 'alt' => '') ); $this->assertTags($result, $expected); $this->Html->webroot = $webroot; From ebf99de965c115c2213d22a731c6b8930e344012 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 23:16:51 -0500 Subject: [PATCH 132/137] Removing the magical addition of SessionComponent to components array. This makes components more declarative, and removes magic that cannot be undone by the end developer. --- cake/libs/controller/component.php | 3 --- cake/libs/controller/controller.php | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/cake/libs/controller/component.php b/cake/libs/controller/component.php index 6c26a9ddd..b6e3a2c93 100644 --- a/cake/libs/controller/component.php +++ b/cake/libs/controller/component.php @@ -185,9 +185,6 @@ class Component extends Object { function _loadComponents(&$object, $parent = null) { $base = $this->__controllerVars['base']; $normal = Set::normalize($object->components); - if ($parent == null) { - $normal = Set::merge(array('Session' => null), $normal); - } foreach ((array)$normal as $component => $config) { $plugin = isset($this->__controllerVars['plugin']) ? $this->__controllerVars['plugin'] . '.' : null; list($plugin, $component) = pluginSplit($component, true, $plugin); diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 6f12da1e4..397eae4ab 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -229,7 +229,7 @@ class Controller extends Object { * @access public * @link http://book.cakephp.org/view/53/components-helpers-and-uses */ - var $components = array(); + var $components = array('Session'); /** * The name of the View class this controller sends output to. From 540e81b1b0a33bf6fc3de2a1bbb279be16adce7c Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 23:33:56 -0500 Subject: [PATCH 133/137] Fixing component and controller test cases to work with less magical session component. --- cake/tests/cases/libs/controller/component.test.php | 2 +- cake/tests/cases/libs/controller/components/auth.test.php | 8 +++++--- .../tests/cases/libs/controller/components/email.test.php | 2 +- .../cases/libs/controller/components/security.test.php | 2 +- cake/tests/cases/libs/controller/controller.test.php | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cake/tests/cases/libs/controller/component.test.php b/cake/tests/cases/libs/controller/component.test.php index eaa19895f..50e63d9b9 100644 --- a/cake/tests/cases/libs/controller/component.test.php +++ b/cake/tests/cases/libs/controller/component.test.php @@ -452,7 +452,7 @@ class ComponentTest extends CakeTestCase { $this->assertTrue(is_a($Controller->ParamTest, 'ParamTestComponent')); $this->assertTrue(is_a($Controller->ParamTest->Banana, 'BananaComponent')); $this->assertTrue(is_a($Controller->Orange, 'OrangeComponent')); - $this->assertTrue(is_a($Controller->Session, 'SessionComponent')); + $this->assertFalse(isset($Controller->Session)); $this->assertEqual($Controller->Orange->settings, array('colour' => 'blood orange')); $this->assertEqual($Controller->ParamTest->test, 'value'); $this->assertEqual($Controller->ParamTest->flag, true); diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 874fb1e13..9f819fd01 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -237,7 +237,7 @@ class AuthTestController extends Controller { * @var array * @access public */ - var $components = array('Auth', 'Acl'); + var $components = array('Session', 'Auth', 'Acl'); /** * testUrl property @@ -382,7 +382,7 @@ class AjaxAuthController extends Controller { * @var array * @access public */ - var $components = array('TestAuth'); + var $components = array('Session', 'TestAuth'); /** * uses property @@ -514,6 +514,7 @@ class AuthTest extends CakeTestCase { $_ENV = $this->_env; Configure::write('Acl', $this->_acl); Configure::write('Security.salt', $this->_securitySalt); + $this->Controller->Session->delete('Auth'); $this->Controller->Session->delete('Message.auth'); ClassRegistry::flush(); @@ -1539,7 +1540,8 @@ class AuthTest extends CakeTestCase { 'loginAction' => array('controller' => 'people', 'action' => 'login'), 'userModel' => 'AuthUserCustomField', 'sessionKey' => 'AltAuth.AuthUserCustomField' - ) + ), + 'Session' ); $this->Controller->Component->init($this->Controller); $this->Controller->Component->initialize($this->Controller); diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 073d120db..8c86600f4 100644 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -150,7 +150,7 @@ class EmailTestController extends Controller { * @var array * @access public */ - var $components = array('EmailTest'); + var $components = array('Session', 'EmailTest'); /** * pageTitle property diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index 6f5976d6f..cb83f947c 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -60,7 +60,7 @@ class SecurityTestController extends Controller { * @var array * @access public */ - var $components = array('TestSecurity'); + var $components = array('Session', 'TestSecurity'); /** * failed property diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index d07930815..3b8bdfec8 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -1077,7 +1077,7 @@ class ControllerTest extends CakeTestCase { $Controller->uses = array(); $Controller->constructClasses(); - $this->assertTrue(isset($Controller->Session)); + $this->assertFalse(isset($Controller->Session)); } /** From 32832f481005623518d93ec1b26f72f6dc83b938 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 23:35:56 -0500 Subject: [PATCH 134/137] Fixing Pagescontroller test and removal of pageTitle from controller. --- cake/tests/cases/libs/controller/pages_controller.test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/controller/pages_controller.test.php b/cake/tests/cases/libs/controller/pages_controller.test.php index a1b5f5a87..7e24151ad 100644 --- a/cake/tests/cases/libs/controller/pages_controller.test.php +++ b/cake/tests/cases/libs/controller/pages_controller.test.php @@ -53,21 +53,21 @@ class PagesControllerTest extends CakeTestCase { return; } - App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS))); + App::build(array( + 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS) + )); $Pages =& new PagesController(); $Pages->viewPath = 'posts'; $Pages->display('index'); $this->assertPattern('/posts index/', $Pages->output); $this->assertEqual($Pages->viewVars['page'], 'index'); - $this->assertEqual($Pages->pageTitle, 'Index'); $Pages->viewPath = 'themed'; $Pages->display('test_theme', 'posts', 'index'); $this->assertPattern('/posts index themed view/', $Pages->output); $this->assertEqual($Pages->viewVars['page'], 'test_theme'); $this->assertEqual($Pages->viewVars['subpage'], 'posts'); - $this->assertEqual($Pages->pageTitle, 'Index'); } } ?> \ No newline at end of file From a85da639565d7df877d4175f90afd8a40be08a65 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 23:48:57 -0500 Subject: [PATCH 135/137] Fixing merge var test case for non magic session component. --- cake/tests/cases/libs/controller/controller_merge_vars.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/controller/controller_merge_vars.test.php b/cake/tests/cases/libs/controller/controller_merge_vars.test.php index 9009f00f6..200ce40f9 100644 --- a/cake/tests/cases/libs/controller/controller_merge_vars.test.php +++ b/cake/tests/cases/libs/controller/controller_merge_vars.test.php @@ -233,6 +233,6 @@ class ControllerMergeVarsTestCase extends CakeTestCase { $Controller->uses = array(); $Controller->constructClasses(); - $this->assertTrue(isset($Controller->Session)); + $this->assertFalse(isset($Controller->Session)); } } \ No newline at end of file From a56bc5585caf00824c740b58961998f66401c86e Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Jan 2010 23:55:09 -0500 Subject: [PATCH 136/137] Removing SessionHelper's magical inclusion into the helpers array. Use of SessionHelper must now be explicitly done. Tests updated. --- cake/libs/controller/controller.php | 2 +- cake/libs/view/view.php | 4 ---- cake/tests/cases/libs/view/view.test.php | 12 ++++++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 397eae4ab..98e1b3a6c 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -93,7 +93,7 @@ class Controller extends Object { * @access protected * @link http://book.cakephp.org/view/53/components-helpers-and-uses */ - var $helpers = array('Html', 'Form'); + var $helpers = array('Session', 'Html', 'Form'); /** * Parameters received in the current request: GET and POST data, information diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index e435eb23b..05917c107 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -732,10 +732,6 @@ class View extends Object { * @return array */ function &_loadHelpers(&$loaded, $helpers, $parent = null) { - if (empty($loaded)) { - $helpers[] = 'Session'; - } - foreach ($helpers as $i => $helper) { $options = array(); diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 42e315819..235081efe 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -583,7 +583,7 @@ class ViewTest extends CakeTestCase { * @return void */ function testHelperCallbackTriggering() { - $this->PostsController->helpers = array('Html', 'CallbackMock'); + $this->PostsController->helpers = array('Session', 'Html', 'CallbackMock'); $View =& new TestView($this->PostsController); $loaded = array(); $View->loaded = $View->loadHelpers($loaded, $this->PostsController->helpers); @@ -601,7 +601,7 @@ class ViewTest extends CakeTestCase { * @return void */ function testBeforeLayout() { - $this->PostsController->helpers = array('TestAfter', 'Html'); + $this->PostsController->helpers = array('Session', 'TestAfter', 'Html'); $View =& new View($this->PostsController); $out = $View->render('index'); $this->assertEqual($View->loaded['testAfter']->property, 'Valuation'); @@ -614,7 +614,7 @@ class ViewTest extends CakeTestCase { * @return void */ function testAfterLayout() { - $this->PostsController->helpers = array('TestAfter', 'Html'); + $this->PostsController->helpers = array('Session', 'TestAfter', 'Html'); $this->PostsController->set('variable', 'values'); $View =& new View($this->PostsController); @@ -633,7 +633,7 @@ class ViewTest extends CakeTestCase { * @return void */ function testRenderLoadHelper() { - $this->PostsController->helpers = array('Html', 'Form', 'Ajax'); + $this->PostsController->helpers = array('Session', 'Html', 'Form', 'Ajax'); $View = new TestView($this->PostsController); $result = $View->_render($View->getViewFileName('index'), array()); @@ -694,7 +694,7 @@ class ViewTest extends CakeTestCase { $this->assertTrue($View->render(false, 'flash')); - $this->PostsController->helpers = array('Cache', 'Html'); + $this->PostsController->helpers = array('Session', 'Cache', 'Html'); $this->PostsController->constructClasses(); $this->PostsController->cacheAction = array('index' => 3600); $this->PostsController->params['action'] = 'index'; @@ -737,7 +737,7 @@ class ViewTest extends CakeTestCase { */ function testViewVarOverwritingLocalHelperVar() { $Controller = new ViewPostsController(); - $Controller->helpers = array('Html'); + $Controller->helpers = array('Session', 'Html'); $Controller->set('html', 'I am some test html'); $View = new View($Controller); $result = $View->render('helper_overwrite', false); From 1980a46b46289d568c4274ecf2ae414f37e7d7da Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 14 Jan 2010 00:09:14 -0500 Subject: [PATCH 137/137] Updating tests to reflect SessionHelper's loss of magic inclusion. --- cake/tests/cases/libs/controller/controller.test.php | 2 +- cake/tests/cases/libs/controller/scaffold.test.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 3b8bdfec8..1bbd3c6f8 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -318,7 +318,7 @@ class TestController extends AppController { * @var array * @access public */ - var $helpers = array('Xml'); + var $helpers = array('Session', 'Xml'); /** * components property diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index a7d1fe1f3..7604792b2 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -495,11 +495,12 @@ class ScaffoldViewTest extends CakeTestCase { $this->assertPattern('/Edit Scaffold Mock<\/legend>/', $result); $this->assertPattern('/input type="hidden" name="data\[ScaffoldMock\]\[id\]" value="1" id="ScaffoldMockId"/', $result); - $this->assertPattern('/input name="data\[ScaffoldMock\]\[user_id\]" type="text" maxlength="11" value="1" id="ScaffoldMockUserId"/', $result); + $this->assertPattern('/select name="data\[ScaffoldMock\]\[user_id\]" id="ScaffoldMockUserId"/', $result); $this->assertPattern('/input name="data\[ScaffoldMock\]\[title\]" type="text" maxlength="255" value="First Article" id="ScaffoldMockTitle"/', $result); $this->assertPattern('/input name="data\[ScaffoldMock\]\[published\]" type="text" maxlength="1" value="Y" id="ScaffoldMockPublished"/', $result); $this->assertPattern('/textarea name="data\[ScaffoldMock\]\[body\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result); $this->assertPattern('/
  • ]*>Delete<\/a>\s*<\/li>/', $result); + debug($result); } /**