mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merge branch '1.3' into scaffold-design
This commit is contained in:
commit
ee8ebce837
56 changed files with 2442 additions and 1551 deletions
|
@ -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
|
||||
|
@ -85,89 +84,13 @@ if (isset($corePath[0])) {
|
|||
define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
|
||||
}
|
||||
|
||||
require_once CAKE_TESTS_LIB . 'test_manager.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
|
||||
*/
|
||||
define('CAKE_TEST_OUTPUT_HTML', 1);
|
||||
define('CAKE_TEST_OUTPUT_TEXT', 2);
|
||||
require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php';
|
||||
|
||||
if (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);
|
||||
}
|
||||
$Dispatcher = new CakeTestSuiteDispatcher();
|
||||
$Dispatcher->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;
|
||||
?>
|
|
@ -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) {
|
||||
|
@ -378,7 +385,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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
@ -94,12 +86,60 @@ 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) {
|
||||
$this->plugins[] = Inflector::underscore($p);
|
||||
}
|
||||
$this->parseArgs();
|
||||
$this->getManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the arguments given into the Shell object properties.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function parseArgs() {
|
||||
if (empty($this->args)) {
|
||||
return;
|
||||
}
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,46 +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->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 {
|
||||
$this->err('Sorry, you did not pass any arguments!');
|
||||
if (count($this->args) == 0) {
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,50 +219,37 @@ 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;
|
||||
}
|
||||
|
||||
switch ($this->type) {
|
||||
case 'all':
|
||||
return true;
|
||||
break;
|
||||
case 'group':
|
||||
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')) {
|
||||
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');
|
||||
if ($this->category == 'core' && ($coreCaseExists || $coreLibCaseExists)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($isPlugin && file_exists($folder.DS.'cases'.DS.$this->file.'.test.php')) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
$fileName = $this->__getFileName($folder, $this->isPluginTest);
|
||||
if ($fileName === true || file_exists($folder . $fileName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the tests depending on our settings
|
||||
*
|
||||
|
@ -252,69 +257,82 @@ class TestSuiteShell extends Shell {
|
|||
* @access private
|
||||
*/
|
||||
function __run() {
|
||||
$reporter = new CLIReporter();
|
||||
$this->__setGetVars();
|
||||
$Reporter = new CakeCliReporter('utf-8', array(
|
||||
'app' => $this->Manager->appTest,
|
||||
'plugin' => $this->Manager->pluginTest,
|
||||
'group' => ($this->type === 'group'),
|
||||
'codeCoverage' => $this->doCoverage
|
||||
));
|
||||
|
||||
if ($this->type == 'all') {
|
||||
return TestManager::runAllTests($reporter);
|
||||
return $this->Manager->runAllTests($Reporter);
|
||||
}
|
||||
|
||||
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');
|
||||
exit(0);
|
||||
$this->out(__('You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation. Download it from http://www.xdebug.org/docs/install', true));
|
||||
$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::start($ucFirstGroup, $reporter);
|
||||
}
|
||||
$result = TestManager::runGroupTest($ucFirstGroup, $reporter);
|
||||
if ($this->doCoverage) {
|
||||
CodeCoverageManager::report();
|
||||
CodeCoverageManager::init($ucFirstGroup, $Reporter);
|
||||
CodeCoverageManager::start();
|
||||
}
|
||||
$result = $this->Manager->runGroupTest($ucFirstGroup, $Reporter);
|
||||
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::start($case, $reporter);
|
||||
CodeCoverageManager::init($case, $Reporter);
|
||||
CodeCoverageManager::start();
|
||||
}
|
||||
|
||||
$result = TestManager::runTestCase($case, $reporter);
|
||||
if ($this->doCoverage) {
|
||||
CodeCoverageManager::report();
|
||||
}
|
||||
|
||||
$result = $this->Manager->runTestCase($case, $Reporter);
|
||||
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
|
||||
*/
|
||||
|
@ -322,20 +340,16 @@ class TestSuiteShell extends Shell {
|
|||
$folder = '';
|
||||
$paths = array(
|
||||
'core' => CAKE,
|
||||
'app' => APP
|
||||
'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 {
|
||||
$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 . $typeDir . DS;
|
||||
}
|
||||
}
|
||||
return $folder;
|
||||
|
@ -350,8 +364,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;
|
||||
}
|
||||
|
@ -368,7 +382,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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,14 @@ if (!empty($validate)):
|
|||
foreach ($validate as $field => $validations):
|
||||
echo "\t\t'$field' => array(\n";
|
||||
foreach ($validations as $key => $validator):
|
||||
echo "\t\t\t'$key' => array('rule' => array('$validator')),\n";
|
||||
echo "\t\t\t'$key' => array(\n";
|
||||
echo "\t\t\t\t'rule' => array('$validator'),\n";
|
||||
echo "\t\t\t\t//'message' => 'Your custom message here',\n";
|
||||
echo "\t\t\t\t//'allowEmpty' => false,\n";
|
||||
echo "\t\t\t\t//'required' => false,\n";
|
||||
echo "\t\t\t\t//'last' => false, // Stop validation after this rule\n";
|
||||
echo "\t\t\t\t//'on' => 'create', // Limit validation to 'create' or 'update' operations\n";
|
||||
echo "\t\t\t),\n";
|
||||
endforeach;
|
||||
echo "\t\t),\n";
|
||||
endforeach;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for filec
|
||||
* App and Configure classes
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
|
@ -217,7 +215,7 @@ class Configure extends Object {
|
|||
* Loads a file from app/config/configure_file.php.
|
||||
* Config file variables should be formated like:
|
||||
* `$config['name'] = 'value';`
|
||||
* These will be used to create dynamic Configure vars. load() is also used to
|
||||
* These will be used to create dynamic Configure vars. load() is also used to
|
||||
* load stored config files created with Configure::store()
|
||||
*
|
||||
* - To load config files from app/config use `Configure::load('configure_file');`.
|
||||
|
@ -236,7 +234,7 @@ class Configure extends Object {
|
|||
$pluginPath = App::pluginPath($plugin);
|
||||
}
|
||||
$pos = strpos($fileName, '..');
|
||||
|
||||
|
||||
if ($pos === false) {
|
||||
if ($pluginPath && file_exists($pluginPath . 'config' . DS . $fileName . '.php')) {
|
||||
include($pluginPath . 'config' . DS . $fileName . '.php');
|
||||
|
@ -450,7 +448,7 @@ class Configure extends Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* Class and file loader.
|
||||
* Class/file loader and path management.
|
||||
*
|
||||
* @link http://book.cakephp.org/view/499/The-App-Class
|
||||
* @since CakePHP(tm) v 1.2.0.6001
|
||||
|
@ -634,8 +632,9 @@ class App extends Object {
|
|||
/**
|
||||
* Used to read information stored path
|
||||
*
|
||||
* Usage
|
||||
* App::path('models'); will return all paths for models
|
||||
* Usage:
|
||||
*
|
||||
* `App::path('models'); will return all paths for models`
|
||||
*
|
||||
* @param string $type type of path
|
||||
* @return string array
|
||||
|
@ -731,7 +730,7 @@ class App extends Object {
|
|||
* Passing $type only returns the values for a given value of $key.
|
||||
*
|
||||
* @param string $type valid values are: 'model', 'behavior', 'controller', 'component',
|
||||
* 'view', 'helper', 'datasource', 'libs', and 'cake'
|
||||
* 'view', 'helper', 'datasource', 'libs', and 'cake'
|
||||
* @return array numeric keyed array of core lib paths
|
||||
* @access public
|
||||
*/
|
||||
|
@ -783,9 +782,11 @@ class App extends Object {
|
|||
/**
|
||||
* Returns an index of objects of the given type, with the physical path to each object.
|
||||
*
|
||||
* @param string $type Type of object, i.e. 'model', 'controller', 'helper', or 'plugin'
|
||||
* @param mixed $path Optional
|
||||
* @return Configure instance
|
||||
* @param string $type Type of object, i.e. 'model', 'controller', 'helper', or 'plugin'
|
||||
* @param mixed $path Optional Scan only the path given. If null, paths for the chosen
|
||||
* type will be used.
|
||||
* @param boolean $cache Set to false to rescan objects of the chosen type. Defaults to true.
|
||||
* @return mixed Either false on incorrect / miss. Or an array of found objects.
|
||||
* @access public
|
||||
*/
|
||||
function objects($type, $path = null, $cache = true) {
|
||||
|
@ -822,7 +823,7 @@ class App extends Object {
|
|||
$items = array();
|
||||
|
||||
foreach ((array)$path as $dir) {
|
||||
if ($type === 'file' || $type === 'class' || strpos($dir, $type) !== false) {
|
||||
if ($dir != APP) {
|
||||
$items = $_this->__list($dir, $types[$type]['suffix'], $extension);
|
||||
$objects = array_merge($items, array_diff($objects, $items));
|
||||
}
|
||||
|
@ -1074,6 +1075,7 @@ class App extends Object {
|
|||
* @param string $name unique name for this map
|
||||
* @param string $type type object being mapped
|
||||
* @param string $plugin camelized if object is from a plugin, the name of the plugin
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function __map($file, $name, $type, $plugin) {
|
||||
|
@ -1254,6 +1256,7 @@ class App extends Object {
|
|||
* @param string $path Path to scan for files
|
||||
* @param string $suffix if false, return only directories. if string, match and return files
|
||||
* @return array List of directories or files in directory
|
||||
* @access private
|
||||
*/
|
||||
function __list($path, $suffix = false, $extension = false) {
|
||||
if (!class_exists('Folder')) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,12 +189,12 @@ class Inflector {
|
|||
var $_singularized = array();
|
||||
|
||||
/**
|
||||
* Cached Underscored Inflections
|
||||
* Cached Underscore Inflections
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
var $_underscored = array();
|
||||
var $_underscore = array();
|
||||
|
||||
/**
|
||||
* Cached Camelize Inflections
|
||||
|
@ -213,7 +213,7 @@ class Inflector {
|
|||
var $_classify = array();
|
||||
|
||||
/**
|
||||
* Tablized cached inflections
|
||||
* Tablize cached inflections
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
|
@ -243,6 +243,31 @@ class Inflector {
|
|||
return $instance[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache inflected values, and return if already available
|
||||
*
|
||||
* @param string $type Inflection type
|
||||
* @param string $key Original value
|
||||
* @param string $value Inflected value
|
||||
* @return string Inflected value, from cache
|
||||
* @access protected
|
||||
*/
|
||||
function _cache($type, $key, $value = false) {
|
||||
$_this =& Inflector::getInstance();
|
||||
|
||||
$key = '_' . $key;
|
||||
$type = '_' . $type;
|
||||
if ($value !== false) {
|
||||
$_this->{$type}[$key] = $value;
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!isset($_this->{$type}[$key])) {
|
||||
return false;
|
||||
}
|
||||
return $_this->{$type}[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom inflection $rules, of either 'plural' or 'singular' $type.
|
||||
*
|
||||
|
@ -379,11 +404,11 @@ class Inflector {
|
|||
*/
|
||||
function camelize($lowerCaseAndUnderscoredWord) {
|
||||
$_this =& Inflector::getInstance();
|
||||
|
||||
if (!isset($_this->_camelize[$lowerCaseAndUnderscoredWord])) {
|
||||
$_this->_camelize[$lowerCaseAndUnderscoredWord] = str_replace(" ", "", ucwords(str_replace("_", " ", $lowerCaseAndUnderscoredWord)));
|
||||
if (!($result = $_this->_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) {
|
||||
$result = str_replace(' ', '', Inflector::humanize($lowerCaseAndUnderscoredWord));
|
||||
$_this->_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result);
|
||||
}
|
||||
return $_this->_camelize[$lowerCaseAndUnderscoredWord];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -397,11 +422,11 @@ class Inflector {
|
|||
*/
|
||||
function underscore($camelCasedWord) {
|
||||
$_this =& Inflector::getInstance();
|
||||
|
||||
if (!isset($_this->_underscored[$camelCasedWord])) {
|
||||
$_this->_underscored[$camelCasedWord] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord));
|
||||
if (!($result = $_this->_cache(__FUNCTION__, $camelCasedWord))) {
|
||||
$result = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord));
|
||||
$_this->_cache(__FUNCTION__, $camelCasedWord, $result);
|
||||
}
|
||||
return $_this->_underscored[$camelCasedWord];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -416,11 +441,11 @@ class Inflector {
|
|||
*/
|
||||
function humanize($lowerCaseAndUnderscoredWord) {
|
||||
$_this =& Inflector::getInstance();
|
||||
|
||||
if (!isset($_this->_humanize[$lowerCaseAndUnderscoredWord])) {
|
||||
$_this->_humanize[$lowerCaseAndUnderscoredWord] = ucwords(str_replace("_", " ", $lowerCaseAndUnderscoredWord));
|
||||
if (!($result = $_this->_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) {
|
||||
$result = ucwords(str_replace('_', ' ', $lowerCaseAndUnderscoredWord));
|
||||
$_this->_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result);
|
||||
}
|
||||
return $_this->_humanize[$lowerCaseAndUnderscoredWord];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -434,11 +459,11 @@ class Inflector {
|
|||
*/
|
||||
function tableize($className) {
|
||||
$_this =& Inflector::getInstance();
|
||||
|
||||
if (!isset($_this->_tableize[$className])) {
|
||||
$_this->_tableize[$className] = Inflector::pluralize(Inflector::underscore($className));
|
||||
if (!($result = $_this->_cache(__FUNCTION__, $className))) {
|
||||
$result = Inflector::pluralize(Inflector::underscore($className));
|
||||
$_this->_cache(__FUNCTION__, $className, $result);
|
||||
}
|
||||
return $_this->_tableize[$className];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -452,11 +477,11 @@ class Inflector {
|
|||
*/
|
||||
function classify($tableName) {
|
||||
$_this =& Inflector::getInstance();
|
||||
|
||||
if (!isset($_this->_classify[$tableName])) {
|
||||
$_this->_classify[$tableName] = Inflector::camelize(Inflector::singularize($tableName));
|
||||
if (!($result = $_this->_cache(__FUNCTION__, $tableName))) {
|
||||
$result = Inflector::camelize(Inflector::singularize($tableName));
|
||||
$_this->_cache(__FUNCTION__, $tableName, $result);
|
||||
}
|
||||
return $_this->_classify[$tableName];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -470,13 +495,13 @@ class Inflector {
|
|||
*/
|
||||
function variable($string) {
|
||||
$_this =& Inflector::getInstance();
|
||||
|
||||
if (!isset($_this->_variable[$string])) {
|
||||
$string = Inflector::camelize(Inflector::underscore($string));
|
||||
$replace = strtolower(substr($string, 0, 1));
|
||||
$_this->_variable[$string] = preg_replace('/\\w/', $replace, $string, 1);
|
||||
if (!($result = $_this->_cache(__FUNCTION__, $string))) {
|
||||
$string2 = Inflector::camelize(Inflector::underscore($string));
|
||||
$replace = strtolower(substr($string2, 0, 1));
|
||||
$result = preg_replace('/\\w/', $replace, $string2, 1);
|
||||
$_this->_cache(__FUNCTION__, $string, $result);
|
||||
}
|
||||
return $_this->_variable[$string];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -141,7 +141,12 @@ class ConnectionManager extends Object {
|
|||
*/
|
||||
function getSourceName(&$source) {
|
||||
$_this =& ConnectionManager::getInstance();
|
||||
return array_search($source, $_this->_dataSources);
|
||||
foreach ($_this->_dataSources as $name => $ds) {
|
||||
if ($ds == $source) {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,8 +81,20 @@ class DboPostgres extends DboSource {
|
|||
'inet' => array('name' => 'inet')
|
||||
);
|
||||
|
||||
/**
|
||||
* Starting Quote
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $startQuote = '"';
|
||||
|
||||
/**
|
||||
* Ending Quote
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $endQuote = '"';
|
||||
|
||||
/**
|
||||
|
|
18
cake/libs/model/datasources/dbo_source.php
Normal file → Executable file
18
cake/libs/model/datasources/dbo_source.php
Normal file → Executable file
|
@ -1413,7 +1413,7 @@ class DboSource extends DataSource {
|
|||
'order' => $this->order($query['order'], 'ASC', $model),
|
||||
'limit' => $this->limit($query['limit'], $query['offset']),
|
||||
'joins' => implode(' ', $query['joins']),
|
||||
'group' => $this->group($query['group'])
|
||||
'group' => $this->group($query['group'], $model)
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -1884,7 +1884,7 @@ class DboSource extends DataSource {
|
|||
|
||||
if ($count >= 1 && !in_array($fields[0], array('*', 'COUNT(*)'))) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (in_array($fields[$i], $virtual)) {
|
||||
if (is_string($fields[$i]) && in_array($fields[$i], $virtual)) {
|
||||
unset($fields[$i]);
|
||||
continue;
|
||||
}
|
||||
|
@ -2258,7 +2258,7 @@ class DboSource extends DataSource {
|
|||
* @return string ORDER BY clause
|
||||
* @access public
|
||||
*/
|
||||
function order($keys, $direction = 'ASC', &$model = null) {
|
||||
function order($keys, $direction = 'ASC', $model = null) {
|
||||
if (!is_array($keys)) {
|
||||
$keys = array($keys);
|
||||
}
|
||||
|
@ -2328,11 +2328,17 @@ class DboSource extends DataSource {
|
|||
* @return mixed string condition or null
|
||||
* @access public
|
||||
*/
|
||||
function group($group) {
|
||||
function group($group, $model = null) {
|
||||
if ($group) {
|
||||
if (is_array($group)) {
|
||||
$group = implode(', ', $group);
|
||||
if (!is_array($group)) {
|
||||
$group = array($group);
|
||||
}
|
||||
foreach($group as $index => $key) {
|
||||
if ($model->isVirtualField($key)) {
|
||||
$group[$index] = '(' . $model->getVirtualField($key) . ')';
|
||||
}
|
||||
}
|
||||
$group = implode(', ', $group);
|
||||
return ' GROUP BY ' . $this->__quoteFields($group);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -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();
|
||||
|
@ -462,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) {
|
||||
|
|
|
@ -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['paging'], $params['models'], $params['url'], $url['url']);
|
||||
$params = array_merge($params, $pass, $named);
|
||||
if (!empty($url)) {
|
||||
$params['?'] = $url;
|
||||
}
|
||||
return Router::url($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a URL for purposes of comparison
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
@ -79,22 +80,39 @@ class Sanitize {
|
|||
|
||||
/**
|
||||
* Returns given string safe for display as HTML. Renders entities.
|
||||
*
|
||||
* 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 boolean $remove If true, the string is stripped of all HTML tags
|
||||
* @param array $options Array of options to use.
|
||||
* @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 = preg_replace($patterns, $replacements, $string);
|
||||
}
|
||||
return $string;
|
||||
$encoding = Configure::read('App.encoding');
|
||||
if (empty($encoding)) {
|
||||
$encoding = $options['charset'];
|
||||
}
|
||||
return htmlentities($string, $options['quotes'], $encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,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 `<b>`, `<p>`, and `<div>` 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
|
||||
|
@ -175,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
|
||||
|
@ -198,6 +228,7 @@ class Sanitize {
|
|||
$options = array_merge(array(
|
||||
'connection' => 'default',
|
||||
'odd_spaces' => true,
|
||||
'remove_html' => false,
|
||||
'encode' => true,
|
||||
'dollar' => true,
|
||||
'carriage' => true,
|
||||
|
@ -216,7 +247,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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -541,22 +546,63 @@ class Validation extends Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* Validation of an IPv4 address.
|
||||
* Validation of an IP address.
|
||||
*
|
||||
* Valid IP version strings for type restriction are:
|
||||
* - both: Check both IPv4 and IPv6, return true if the supplied address matches either version
|
||||
* - IPv4: Version 4 (Eg: 127.0.0.1, 192.168.10.123, 203.211.24.8)
|
||||
* - IPv6: Version 6 (Eg: ::1, 2001:0db8::1428:57ab)
|
||||
*
|
||||
* @param string $check The string to test.
|
||||
* @param string $type The IP Version to test against
|
||||
* @return boolean Success
|
||||
* @access public
|
||||
*/
|
||||
function ip($check, $type = 'IPv4') {
|
||||
if (function_exists('filter_var')) {
|
||||
return filter_var($check, FILTER_VALIDATE_IP);
|
||||
}
|
||||
|
||||
function ip($check, $type = 'both') {
|
||||
$_this =& Validation::getInstance();
|
||||
$_this->check = $check;
|
||||
$_this->__populateIp();
|
||||
$_this->regex = '/^' . $_this->__pattern[$type] . '$/';
|
||||
return $_this->_check();
|
||||
$success = false;
|
||||
$type = strtolower($type);
|
||||
if ($type === 'ipv4' || $type === 'both') {
|
||||
$success |= $_this->_ipv4($check);
|
||||
}
|
||||
if ($type === 'ipv6' || $type === 'both') {
|
||||
$success |= $_this->_ipv6($check);
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation of IPv4 addresses.
|
||||
*
|
||||
* @param string $check IP Address to test
|
||||
* @return boolean Success
|
||||
* @access protected
|
||||
*/
|
||||
function _ipv4($check) {
|
||||
if (function_exists('filter_var')) {
|
||||
return filter_var($check, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)) !== false;
|
||||
}
|
||||
$this->__populateIp();
|
||||
$this->check = $check;
|
||||
$this->regex = '/^' . $this->__pattern['IPv4'] . '$/';
|
||||
return $this->_check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation of IPv6 addresses.
|
||||
*
|
||||
* @param string $check IP Address to test
|
||||
* @return boolean Success
|
||||
* @access protected
|
||||
*/
|
||||
function _ipv6($check) {
|
||||
if (function_exists('filter_var')) {
|
||||
return filter_var($check, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6)) !== false;
|
||||
}
|
||||
$this->__populateIp();
|
||||
$this->check = $check;
|
||||
$this->regex = '/^' . $this->__pattern['IPv6'] . '$/';
|
||||
return $this->_check();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -792,6 +838,20 @@ class Validation extends Object {
|
|||
return $_this->_check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that a value is a valid uuid - http://tools.ietf.org/html/rfc4122
|
||||
*
|
||||
* @param string $check Value to check
|
||||
* @return boolean Success
|
||||
* @access public
|
||||
*/
|
||||
function uuid($check) {
|
||||
$_this =& Validation::getInstance();
|
||||
$_this->check = $check;
|
||||
$_this->regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
|
||||
return $_this->_check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that a value is a valid URL according to http://www.w3.org/Addressing/URL/url-spec.txt
|
||||
*
|
||||
|
@ -816,7 +876,8 @@ class Validation extends Object {
|
|||
$_this->check = $check;
|
||||
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z]|(%[0-9a-f]{2}))';
|
||||
$_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
|
||||
'(?:' . $_this->__pattern['IPv4'] . '|' . $_this->__pattern['hostname'] . ')(?::[1-9][0-9]{0,3})?' .
|
||||
'(?:' . $_this->__pattern['IPv4'] . '|\[' . $_this->__pattern['IPv6'] . '\]|' . $_this->__pattern['hostname'] . ')' .
|
||||
'(?::[1-9][0-9]{0,4})?' .
|
||||
'(?:\/?|\/' . $validChars . '*)?' .
|
||||
'(?:\?' . $validChars . '*)?' .
|
||||
'(?:#' . $validChars . '*)?$/i';
|
||||
|
@ -954,6 +1015,7 @@ class Validation extends Object {
|
|||
* Lazily popualate the IP address patterns used for validations
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function __populateIp() {
|
||||
if (!isset($this->__pattern['IPv6'])) {
|
||||
|
|
|
@ -67,68 +67,34 @@ 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, '_');
|
||||
|
||||
$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, '_')) === 0) {
|
||||
$index = $found[$count];
|
||||
foreach ($keys as $action) {
|
||||
if ($action == $this->params['action']) {
|
||||
$index = $action;
|
||||
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';
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
@ -263,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)) . '\'));
|
||||
|
@ -286,6 +250,7 @@ class CacheHelper extends AppHelper {
|
|||
$camelBackedHelper = Inflector::variable($helper);
|
||||
${$camelBackedHelper} =& $loadedHelpers[$helper];
|
||||
$this->loaded[$camelBackedHelper] =& ${$camelBackedHelper};
|
||||
$this->{$helper} =& $loadedHelpers[$helper];
|
||||
}
|
||||
?>';
|
||||
$content = preg_replace("/(<\\?xml)/", "<?php echo '$1';?>",$content);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,6 +245,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
|||
} else {
|
||||
$success = 'function (data, textStatus) {$("' . $options['update'] . '").html(data);}';
|
||||
}
|
||||
$options['dataType'] = 'html';
|
||||
$options['success'] = $success;
|
||||
unset($options['update']);
|
||||
}
|
||||
|
|
|
@ -234,13 +234,12 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
|
|||
$type = '.Updater';
|
||||
unset($options['update'], $options['type']);
|
||||
}
|
||||
$safe = array();
|
||||
$safe = array_keys($this->_callbackArguments['request']);
|
||||
$options = $this->_prepareCallbacks('request', $options, $safe);
|
||||
if (isset($options['dataExpression'])) {
|
||||
$safe[] = 'parameters';
|
||||
unset($options['dataExpression']);
|
||||
}
|
||||
$safe = array_merge($safe, array_keys($this->_callbackArguments['request']));
|
||||
$options = $this->_prepareCallbacks('request', $options, $safe);
|
||||
$options = $this->_parseOptions($options, $safe);
|
||||
if (!empty($options)) {
|
||||
$options = ', {' . $options . '}';
|
||||
|
|
|
@ -594,8 +594,19 @@ class ModelTaskTest extends CakeTestCase {
|
|||
$this->assertPattern('/class Article extends AppModel \{/', $result);
|
||||
$this->assertPattern('/\$name \= \'Article\'/', $result);
|
||||
$this->assertPattern('/\$validate \= array\(/', $result);
|
||||
$pattern = '/' . preg_quote("'notempty' => array('rule' => array('notempty')),", '/') . '/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$expected = <<< STRINGEND
|
||||
array(
|
||||
'notempty' => array(
|
||||
'rule' => array('notempty'),
|
||||
//'message' => 'Your custom message here',
|
||||
//'allowEmpty' => false,
|
||||
//'required' => false,
|
||||
//'last' => false, // Stop validation after this rule
|
||||
//'on' => 'create', // Limit validation to 'create' or 'update' operations
|
||||
),
|
||||
STRINGEND;
|
||||
|
||||
$this->assertPattern('/' . preg_quote($expected, '/') . '/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
@ -2115,7 +2115,9 @@ class DispatcherTest extends CakeTestCase {
|
|||
$_SERVER['PHP_SELF'] = '/';
|
||||
|
||||
Router::reload();
|
||||
Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
|
||||
App::build(array(
|
||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
||||
));
|
||||
|
||||
$dispatcher =& new Dispatcher();
|
||||
$dispatcher->base = false;
|
||||
|
@ -2137,7 +2139,6 @@ class DispatcherTest extends CakeTestCase {
|
|||
|
||||
$this->assertEqual($result, $expected);
|
||||
$filename = $this->__cachePath($dispatcher->here);
|
||||
unlink($filename);
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -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::init(substr(md5(microtime()), 0, 5), $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertError();
|
||||
|
||||
CodeCoverageManager::start('tests' . DS . 'lib' . DS . basename(__FILE__), new CakeHtmlReporter());
|
||||
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, new CakeHtmlReporter());
|
||||
CodeCoverageManager::init('libs'.DS.$file, $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertNoErrors('libs'.DS.$file);
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ class ConfigureTest extends CakeTestCase {
|
|||
|
||||
$result = Configure::load('config');
|
||||
$this->assertTrue($result === null);
|
||||
|
||||
|
||||
$result = Configure::load('../../index');
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
@ -421,6 +421,17 @@ class AppImportTest extends UnitTestCase {
|
|||
|
||||
$result = App::objects('NonExistingType');
|
||||
$this->assertFalse($result);
|
||||
|
||||
App::build(array(
|
||||
'plugins' => array(
|
||||
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS
|
||||
)
|
||||
));
|
||||
$result = App::objects('plugin', null, false);
|
||||
$this->assertTrue(in_array('Cache', $result));
|
||||
$this->assertTrue(in_array('Log', $result));
|
||||
|
||||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -245,6 +245,30 @@ class InflectorTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testInflectorUnderscore method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testInflectorUnderscore() {
|
||||
$this->assertIdentical(Inflector::underscore('TestThing'), 'test_thing');
|
||||
$this->assertIdentical(Inflector::underscore('testThing'), 'test_thing');
|
||||
$this->assertIdentical(Inflector::underscore('TestThingExtra'), 'test_thing_extra');
|
||||
$this->assertIdentical(Inflector::underscore('testThingExtra'), 'test_thing_extra');
|
||||
|
||||
// Identical checks test the cache code path.
|
||||
$this->assertIdentical(Inflector::underscore('TestThing'), 'test_thing');
|
||||
$this->assertIdentical(Inflector::underscore('testThing'), 'test_thing');
|
||||
$this->assertIdentical(Inflector::underscore('TestThingExtra'), 'test_thing_extra');
|
||||
$this->assertIdentical(Inflector::underscore('testThingExtra'), 'test_thing_extra');
|
||||
|
||||
// Test stupid values
|
||||
$this->assertIdentical(Inflector::underscore(''), '');
|
||||
$this->assertIdentical(Inflector::underscore(0), '0');
|
||||
$this->assertIdentical(Inflector::underscore(false), '');
|
||||
}
|
||||
|
||||
/**
|
||||
* testVariableNaming method
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -2934,7 +2934,7 @@ class DboSourceTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testFieldsWithExpression() {
|
||||
$expression =& $this->testDb->expression("CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col");
|
||||
$expression = $this->testDb->expression("CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col");
|
||||
$result = $this->testDb->fields($this->Model, null, array("id", $expression));
|
||||
$expected = array(
|
||||
'`TestModel`.`id`',
|
||||
|
@ -4240,5 +4240,23 @@ class DboSourceTest extends CakeTestCase {
|
|||
));
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test group to generate GROUP BY statements on virtual fields
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testVirtualFieldsInGroup() {
|
||||
$this->loadFixtures('Article');
|
||||
|
||||
$Article =& ClassRegistry::init('Article');
|
||||
$Article->virtualFields = array(
|
||||
'this_year' => 'YEAR(Article.created)'
|
||||
);
|
||||
|
||||
$result = $this->db->group('this_year',$Article);
|
||||
$expected = " GROUP BY (YEAR(`Article`.`created`))";
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
}
|
||||
?>
|
23
cake/tests/cases/libs/model/model_read.test.php
Normal file → Executable file
23
cake/tests/cases/libs/model/model_read.test.php
Normal file → Executable file
|
@ -7240,6 +7240,29 @@ class ModelReadTest extends BaseModelTest {
|
|||
$Post->virtualFields = array('other_field' => 'COUNT(Post.id) + 1');
|
||||
$result = $Post->field('other_field');
|
||||
$this->assertEqual($result, 4);
|
||||
|
||||
ClassRegistry::flush();
|
||||
$Post = ClassRegistry::init('Post');
|
||||
|
||||
$Post->create();
|
||||
$Post->virtualFields = array(
|
||||
'year' => 'YEAR(Post.created)',
|
||||
'unique_test_field' => 'COUNT(Post.id)'
|
||||
);
|
||||
|
||||
$expectation = array(
|
||||
'Post' => array(
|
||||
'year' => 2007,
|
||||
'unique_test_field' => 3
|
||||
)
|
||||
);
|
||||
|
||||
$result = $Post->find('first', array(
|
||||
'fields' => array_keys($Post->virtualFields),
|
||||
'group' => array('year')
|
||||
));
|
||||
|
||||
$this->assertEqual($result, $expectation);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1942,6 +1942,58 @@ 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');
|
||||
|
||||
$params = array(
|
||||
'lang' => 'eng',
|
||||
'controller' => 'posts',
|
||||
'action' => 'view',
|
||||
'pass' => array(1),
|
||||
'named' => array(),
|
||||
'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');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -194,7 +194,8 @@ class SanitizeTest extends CakeTestCase {
|
|||
$result = Sanitize::clean($string);
|
||||
$this->assertEqual($string, $expected);
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* testHtml method
|
||||
*
|
||||
* @access public
|
||||
|
@ -202,16 +203,31 @@ class SanitizeTest extends CakeTestCase {
|
|||
*/
|
||||
function testHtml() {
|
||||
$string = '<p>This is a <em>test string</em> & so is this</p>';
|
||||
$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 <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';
|
||||
$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 <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);
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* testStripWhitespace method
|
||||
*
|
||||
* @access public
|
||||
|
@ -223,7 +239,8 @@ class SanitizeTest extends CakeTestCase {
|
|||
$result = Sanitize::stripWhitespace($string);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* testParanoid method
|
||||
*
|
||||
* @access public
|
||||
|
@ -264,7 +281,8 @@ class SanitizeTest extends CakeTestCase {
|
|||
$result = Sanitize::paranoid($string);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* testStripImages method
|
||||
*
|
||||
* @access public
|
||||
|
@ -291,7 +309,8 @@ class SanitizeTest extends CakeTestCase {
|
|||
$result = Sanitize::stripImages($string);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* testStripScripts method
|
||||
*
|
||||
* @access public
|
||||
|
@ -328,7 +347,8 @@ class SanitizeTest extends CakeTestCase {
|
|||
$result = Sanitize::stripScripts($string);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* testStripAll method
|
||||
*
|
||||
* @access public
|
||||
|
@ -359,7 +379,8 @@ class SanitizeTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* testStripTags method
|
||||
*
|
||||
* @access public
|
||||
|
@ -401,7 +422,8 @@ class SanitizeTest extends CakeTestCase {
|
|||
$result = Sanitize::stripTags($string, 'h2', 'a', 'img');
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* testFormatColumns method
|
||||
*
|
||||
* @access public
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1725,13 +1725,16 @@ class ValidationTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testIp() {
|
||||
$this->assertTrue(Validation::ip('0.0.0.0'));
|
||||
$this->assertTrue(Validation::ip('192.168.1.156'));
|
||||
$this->assertTrue(Validation::ip('255.255.255.255'));
|
||||
$this->assertFalse(Validation::ip('127.0.0'));
|
||||
$this->assertFalse(Validation::ip('127.0.0.a'));
|
||||
$this->assertFalse(Validation::ip('127.0.0.256'));
|
||||
function testIpv4() {
|
||||
$this->assertTrue(Validation::ip('0.0.0.0', 'IPv4'));
|
||||
$this->assertTrue(Validation::ip('192.168.1.156', 'IPv4'));
|
||||
$this->assertTrue(Validation::ip('255.255.255.255', 'IPv4'));
|
||||
|
||||
$this->assertFalse(Validation::ip('127.0.0', 'IPv4'));
|
||||
$this->assertFalse(Validation::ip('127.0.0.a', 'IPv4'));
|
||||
$this->assertFalse(Validation::ip('127.0.0.256', 'IPv4'));
|
||||
|
||||
$this->assertFalse(Validation::ip('2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'IPv4'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1772,6 +1775,32 @@ class ValidationTest extends CakeTestCase {
|
|||
$this->assertFalse(Validation::ip('1:2:3::4:5:6:7:8:9', 'IPv6'));
|
||||
$this->assertFalse(Validation::ip('::ffff:2.3.4', 'IPv6'));
|
||||
$this->assertFalse(Validation::ip('::ffff:257.1.2.3', 'IPv6'));
|
||||
|
||||
$this->assertFalse(Validation::ip('0.0.0.0', 'IPv6'));
|
||||
}
|
||||
|
||||
/**
|
||||
* testIpBoth method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testIpBoth() {
|
||||
$this->assertTrue(Validation::ip('0.0.0.0'));
|
||||
$this->assertTrue(Validation::ip('192.168.1.156'));
|
||||
$this->assertTrue(Validation::ip('255.255.255.255'));
|
||||
|
||||
$this->assertFalse(Validation::ip('127.0.0'));
|
||||
$this->assertFalse(Validation::ip('127.0.0.a'));
|
||||
$this->assertFalse(Validation::ip('127.0.0.256'));
|
||||
|
||||
$this->assertTrue(Validation::ip('2001:0db8:85a3:0000:0000:8a2e:0370:7334'));
|
||||
$this->assertTrue(Validation::ip('2001:db8:85a3:0:0:8a2e:370:7334'));
|
||||
$this->assertTrue(Validation::ip('2001:db8:85a3::8a2e:370:7334'));
|
||||
|
||||
$this->assertFalse(Validation::ip('2001:db8:85a3::8a2e:37023:7334'));
|
||||
$this->assertFalse(Validation::ip('2001:db8:85a3::8a2e:370k:7334'));
|
||||
$this->assertFalse(Validation::ip('1:2:3:4:5:6:7:8:9'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1847,6 +1876,34 @@ class ValidationTest extends CakeTestCase {
|
|||
$this->assertFalse(Validation::url('www.cakephp.org', true));
|
||||
$this->assertTrue(Validation::url('http://www.cakephp.org', true));
|
||||
$this->assertTrue(Validation::url('http://example.com/~userdir/'));
|
||||
|
||||
$this->assertTrue(Validation::url('http://cakephp.org:80'));
|
||||
$this->assertTrue(Validation::url('http://cakephp.org:443'));
|
||||
$this->assertTrue(Validation::url('http://cakephp.org:2000'));
|
||||
$this->assertTrue(Validation::url('http://cakephp.org:27000'));
|
||||
$this->assertTrue(Validation::url('http://cakephp.org:65000'));
|
||||
|
||||
$this->assertTrue(Validation::url('[2001:0db8::1428:57ab]'));
|
||||
$this->assertTrue(Validation::url('[::1]'));
|
||||
$this->assertTrue(Validation::url('[2001:0db8::1428:57ab]:80'));
|
||||
$this->assertTrue(Validation::url('[::1]:80'));
|
||||
$this->assertTrue(Validation::url('http://[2001:0db8::1428:57ab]'));
|
||||
$this->assertTrue(Validation::url('http://[::1]'));
|
||||
$this->assertTrue(Validation::url('http://[2001:0db8::1428:57ab]:80'));
|
||||
$this->assertTrue(Validation::url('http://[::1]:80'));
|
||||
|
||||
$this->assertFalse(Validation::url('[1::2::3]'));
|
||||
}
|
||||
|
||||
function testUuid() {
|
||||
$this->assertTrue(Validation::uuid('550e8400-e29b-11d4-a716-446655440000'));
|
||||
$this->assertFalse(Validation::uuid('BRAP-e29b-11d4-a716-446655440000'));
|
||||
$this->assertTrue(Validation::uuid('550E8400-e29b-11D4-A716-446655440000'));
|
||||
$this->assertFalse(Validation::uuid('550e8400-e29b11d4-a716-446655440000'));
|
||||
$this->assertFalse(Validation::uuid('550e8400-e29b-11d4-a716-4466440000'));
|
||||
$this->assertFalse(Validation::uuid('550e8400-e29b-11d4-a71-446655440000'));
|
||||
$this->assertFalse(Validation::uuid('550e8400-e29b-11d-a716-446655440000'));
|
||||
$this->assertFalse(Validation::uuid('550e8400-e29-11d4-a716-446655440000'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
@ -127,6 +124,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 +159,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 +186,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 +221,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 +254,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 +315,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
|
||||
);
|
||||
|
@ -302,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';
|
||||
|
@ -319,25 +358,15 @@ class CacheHelperTest extends CakeTestCase {
|
|||
|
||||
|
||||
$this->Controller->cache_parsing();
|
||||
$this->Controller->cacheAction = array(
|
||||
'cache_parsing/33' => 21600
|
||||
$this->Controller->params = array(
|
||||
'controller' => 'cache_test',
|
||||
'action' => 'cache_parsing',
|
||||
'url' => array(),
|
||||
'pass' => array(),
|
||||
'named' => array()
|
||||
);
|
||||
$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->cacheAction = array(
|
||||
'cache_parsing/33' => 21600
|
||||
'some_other_action' => 21600
|
||||
);
|
||||
$this->Controller->here = '/cacheTest/cache_parsing';
|
||||
$this->Controller->action = 'cache_parsing';
|
||||
|
@ -351,6 +380,41 @@ 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}'));
|
||||
|
||||
$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
|
||||
*
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -162,7 +162,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
|
|||
$result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1), array(
|
||||
'update' => '#content'
|
||||
));
|
||||
$expected = '$.ajax({success:function (data, textStatus) {$("#content").html(data);}, url:"\/posts\/view\/1"});';
|
||||
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#content").html(data);}, url:"\/posts\/view\/1"});';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Jquery->request('/people/edit/1', array(
|
||||
|
@ -184,7 +184,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
|
|||
'method' => 'post',
|
||||
'wrapCallbacks' => false
|
||||
));
|
||||
$expected = '$.ajax({success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Jquery->request('/people/edit/1', array(
|
||||
|
@ -195,7 +195,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
|
|||
'data' => '$("#someId").serialize()',
|
||||
'wrapCallbacks' => false
|
||||
));
|
||||
$expected = '$.ajax({data:$("#someId").serialize(), success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||
$expected = '$.ajax({data:$("#someId").serialize(), dataType:"html", success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Jquery->request('/people/edit/1', array(
|
||||
|
|
|
@ -247,6 +247,17 @@ class PrototypeEngineHelperTestCase extends CakeTestCase {
|
|||
));
|
||||
$expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {asynchronous:false, method:"post", onComplete:function (transport) {doComplete();}, onCreate:function (transport) {doBefore();}, onFailure:function (response, jsonHeader) {handleError();}, onSuccess:function (response, jsonHeader) {doSuccess();}});';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Proto->get('#submit');
|
||||
$result = $this->Proto->request('/users/login', array(
|
||||
'before' => 'login.create(event)',
|
||||
'complete' => 'login.complete(event)',
|
||||
'update' => 'auth',
|
||||
'data' => $this->Proto->serializeForm(array('isForm' => false, 'inline' => true)),
|
||||
'dataExpression' => true
|
||||
));
|
||||
$this->assertTrue(strpos($result, '$($("submit").form).serialize()') > 0);
|
||||
$this->assertFalse(strpos($result, 'parameters:function () {$($("submit").form).serialize()}') > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
249
cake/tests/lib/cake_test_suite_dispatcher.php
Normal file
249
cake/tests/lib/cake_test_suite_dispatcher.php
Normal file
|
@ -0,0 +1,249 @@
|
|||
<?php
|
||||
/**
|
||||
* CakeTestSuiteDispatcher controls dispatching TestSuite web based requests.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* 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.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';
|
||||
|
||||
/**
|
||||
* 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',
|
||||
'show_passes' => false
|
||||
);
|
||||
|
||||
/**
|
||||
* The classname for the TestManager being used
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $_managerClass = 'TestManager';
|
||||
|
||||
/**
|
||||
* The Instance of the Manager being used.
|
||||
*
|
||||
* @var TestManager subclass
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function dispatch() {
|
||||
$this->_checkSimpleTest();
|
||||
$this->_parseParams();
|
||||
|
||||
if ($this->params['group']) {
|
||||
$this->_runGroupTest();
|
||||
} elseif ($this->params['case']) {
|
||||
$this->_runTestCase();
|
||||
} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
|
||||
$this->_testCaseList();
|
||||
} else {
|
||||
$this->_groupTestList();
|
||||
}
|
||||
|
||||
$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')) {
|
||||
$basePath = $this->_baseDir;
|
||||
include CAKE_TESTS_LIB . 'templates' . DS . 'simpletest.php';
|
||||
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')) {
|
||||
$basePath = $this->_baseDir;
|
||||
include CAKE_TESTS_LIB . 'templates' . DS . 'xdebug.php';
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a page containing the a list of test cases that could be run.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _testCaseList() {
|
||||
$Reporter =& $this->getReporter();
|
||||
$Reporter->paintDocumentStart();
|
||||
$Reporter->paintTestMenu();
|
||||
$Reporter->testCaseList();
|
||||
$Reporter->paintDocumentEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a page containing a list of group tests that could be run.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _groupTestList() {
|
||||
$Reporter =& $this->getReporter();
|
||||
$Reporter->paintDocumentStart();
|
||||
$Reporter->paintTestMenu();
|
||||
$Reporter->groupTestList();
|
||||
$Reporter->paintDocumentEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Manager to use for the request.
|
||||
*
|
||||
* @return string The manager class name
|
||||
* @static
|
||||
*/
|
||||
function &getManager() {
|
||||
if (empty($this->Manager)) {
|
||||
$this->Manager = new $this->_managerClass();
|
||||
}
|
||||
return $this->Manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reporter based on the request parameters
|
||||
*
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function &getReporter() {
|
||||
static $Reporter = NULL;
|
||||
if (!$Reporter) {
|
||||
$type = strtolower($this->params['output']);
|
||||
$coreClass = 'Cake' . ucwords($this->params['output']) . 'Reporter';
|
||||
$coreFile = CAKE_TESTS_LIB . 'reporter' . DS . 'cake_' . $type . '_reporter.php';
|
||||
|
||||
$appClass = $this->params['output'] . 'Reporter';
|
||||
$appFile = APPLIBS . 'test_suite' . DS . 'reporter' . DS . $type . '_reporter.php';
|
||||
if (include_once $coreFile) {
|
||||
$Reporter =& new $coreClass(null, $this->params);
|
||||
} elseif (include_once $appFile) {
|
||||
$Reporter =& new $appClass(null, $this->params);
|
||||
}
|
||||
}
|
||||
return $Reporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
$this->params['baseUrl'] = $this->_baseUrl;
|
||||
$this->params['baseDir'] = $this->_baseDir;
|
||||
$this->getManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the group test case.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _runGroupTest() {
|
||||
$Reporter =& CakeTestSuiteDispatcher::getReporter();
|
||||
if ('all' == $this->params['group']) {
|
||||
$this->Manager->runAllTests($Reporter);
|
||||
} else {
|
||||
if ($this->params['codeCoverage']) {
|
||||
CodeCoverageManager::init($this->params['group'], $Reporter);
|
||||
}
|
||||
$this->Manager->runGroupTest(ucfirst($this->params['group']), $Reporter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a test case file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _runTestCase() {
|
||||
$Reporter =& CakeTestSuiteDispatcher::getReporter();
|
||||
if ($this->params['codeCoverage']) {
|
||||
CodeCoverageManager::init($this->params['case'], $Reporter);
|
||||
}
|
||||
$this->Manager->runTestCase($this->params['case'], $Reporter);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
class CakeTextReporter extends TextReporter {
|
||||
|
||||
var $_timeStart = 0;
|
||||
var $_timeEnd = 0;
|
||||
var $_timeDuration = 0;
|
||||
|
||||
/**
|
||||
* Signals / Paints the beginning of a TestSuite executing.
|
||||
* Starts the timer for the TestSuite execution time.
|
||||
*
|
||||
* @param
|
||||
* @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.
|
||||
*
|
||||
* @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 end of the test with a summary of
|
||||
* the passes and failures.
|
||||
*
|
||||
* @param string $test_name Name class of test.
|
||||
* @access public
|
||||
*/
|
||||
function paintFooter($test_name) {
|
||||
parent::paintFooter($test_name);
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* 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.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'));
|
||||
define('STDERR', fopen('php://stderr', 'w'));
|
||||
register_shutdown_function(create_function('', 'fclose(STDOUT); fclose(STDERR); return true;'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.tests.libs
|
||||
*/
|
||||
class CLIReporter extends TextReporter {
|
||||
var $faildetail_separator = ST_FAILDETAIL_SEPARATOR;
|
||||
|
||||
function CLIReporter($faildetail_separator = NULL) {
|
||||
$this->SimpleReporter();
|
||||
if (! is_null($faildetail_separator)) {
|
||||
$this->setFailDetailSeparator($faildetail_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint fail faildetail to STDERR.
|
||||
*/
|
||||
function paintFail($message) {
|
||||
parent::paintFail($message);
|
||||
fwrite(STDERR, 'FAIL' . $this->faildetail_separator . $this->_paintTestFailDetail($message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint exception faildetail to STDERR.
|
||||
*/
|
||||
function paintException($message) {
|
||||
parent::paintException($message);
|
||||
fwrite(STDERR, 'EXCEPTION' . $this->faildetail_separator . $this->_paintTestFailDetail($message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint a footer with test case name, timestamp, counts of fails and exceptions.
|
||||
*/
|
||||
function paintFooter($test_name) {
|
||||
$buffer = $this->getTestCaseProgress() . '/' . $this->getTestCaseCount() . ' test cases complete: ';
|
||||
|
||||
if (0 < ($this->getFailCount() + $this->getExceptionCount())) {
|
||||
$buffer .= $this->getPassCount() . " passes";
|
||||
if (0 < $this->getFailCount()) {
|
||||
$buffer .= ", " . $this->getFailCount() . " fails";
|
||||
}
|
||||
if (0 < $this->getExceptionCount()) {
|
||||
$buffer .= ", " . $this->getExceptionCount() . " exceptions";
|
||||
}
|
||||
$buffer .= ".\n";
|
||||
fwrite(STDOUT, $buffer);
|
||||
} else {
|
||||
fwrite(STDOUT, $buffer . $this->getPassCount() . " passes.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -87,67 +87,97 @@ 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;
|
||||
$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'])) {
|
||||
$manager->appTest = true;
|
||||
}
|
||||
|
||||
if (isset($_GET['group'])) {
|
||||
$manager->groupTest = true;
|
||||
}
|
||||
|
||||
if (isset($_GET['plugin'])) {
|
||||
$manager->pluginTest = Inflector::underscore($_GET['plugin']);
|
||||
}
|
||||
$manager->setParams($reporter);
|
||||
$manager->testCaseFile = $testCaseFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start/resume Code coverage collection.
|
||||
*
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function start() {
|
||||
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()
|
||||
* 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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setParams(&$reporter) {
|
||||
if ($reporter->params['app']) {
|
||||
$this->appTest = true;
|
||||
}
|
||||
|
||||
if ($reporter->params['group']) {
|
||||
$this->groupTest = true;
|
||||
}
|
||||
|
||||
if ($reporter->params['plugin']) {
|
||||
$this->pluginTest = Inflector::underscore($reporter->params['plugin']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
CodeCoverageManager::stop();
|
||||
CodeCoverageManager::clear();
|
||||
|
||||
list($coverageData, $testObjectFile) = $manager->_getCoverageData();
|
||||
|
||||
if (empty($coverageData) && $output) {
|
||||
echo "The test object file is never loaded.\n";
|
||||
}
|
||||
|
||||
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();
|
||||
xdebug_stop_code_coverage();
|
||||
$coverageData = array();
|
||||
|
||||
foreach ($dump as $file => $data) {
|
||||
if ($file == $testObjectFile) {
|
||||
$coverageData = $data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($coverageData) && $output) {
|
||||
echo 'The test object file is never loaded.';
|
||||
}
|
||||
$execCodeLines = $manager->__getExecutableLines(file_get_contents($testObjectFile));
|
||||
$result = '';
|
||||
|
||||
|
@ -155,46 +185,22 @@ class CodeCoverageManager {
|
|||
case 'CakeHtmlReporter':
|
||||
$result = $manager->reportCaseHtmlDiff(@file($testObjectFile), $coverageData, $execCodeLines, $manager->numDiffContextLines);
|
||||
break;
|
||||
case 'CLIReporter':
|
||||
$result = $manager->reportCaseCli(@file($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->reportCaseCli(@file($testObjectFile), $coverageData, $execCodeLines, $manager->numDiffContextLines);
|
||||
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();
|
||||
xdebug_stop_code_coverage();
|
||||
$coverageData = array();
|
||||
foreach ($dump as $file => $data) {
|
||||
if (in_array($file, $testObjectFiles)) {
|
||||
$coverageData[$file] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
break;
|
||||
case 'CLIReporter':
|
||||
$result = $manager->reportGroupCli($testObjectFiles, $coverageData, $execCodeLines, $manager->numDiffContextLines);
|
||||
$result = $manager->reportGroupHtml($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;
|
||||
}
|
||||
}
|
||||
|
@ -205,39 +211,40 @@ class CodeCoverageManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Html reporting
|
||||
* Gets the coverage data for the test case or group test that is being run.
|
||||
*
|
||||
* @param string $testObjectFile
|
||||
* @param string $coverageData
|
||||
* @param string $execCodeLines
|
||||
* @param string $output
|
||||
* @return void
|
||||
*/
|
||||
function reportCaseHtml($testObjectFile, $coverageData, $execCodeLines) {
|
||||
$manager = CodeCoverageManager::getInstance();
|
||||
$lineCount = $coveredCount = 0;
|
||||
$report = '';
|
||||
function _getCoverageData() {
|
||||
$coverageData = array();
|
||||
$dump = xdebug_get_code_coverage();
|
||||
|
||||
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++;
|
||||
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 ;
|
||||
}
|
||||
} else {
|
||||
$class = 'ignored';
|
||||
}
|
||||
$report .= $manager->__paintCodeline($class, $num, $line);
|
||||
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 $manager->__paintHeader($lineCount, $coveredCount, $report);
|
||||
return array($coverageData, $testObjectFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,6 +255,7 @@ class CodeCoverageManager {
|
|||
* @param string $execCodeLines
|
||||
* @param string $output
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function reportCaseHtmlDiff($testObjectFile, $coverageData, $execCodeLines, $numContextLines) {
|
||||
$manager = CodeCoverageManager::getInstance();
|
||||
|
@ -366,6 +374,7 @@ class CodeCoverageManager {
|
|||
* @param string $execCodeLines
|
||||
* @param string $output
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function reportCaseCli($testObjectFile, $coverageData, $execCodeLines) {
|
||||
$manager = CodeCoverageManager::getInstance();
|
||||
|
@ -396,6 +405,7 @@ class CodeCoverageManager {
|
|||
* @param string $execCodeLines
|
||||
* @param string $output
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function reportGroupHtml($testObjectFiles, $coverageData, $execCodeLines, $numContextLines) {
|
||||
$manager = CodeCoverageManager::getInstance();
|
||||
|
@ -436,6 +446,7 @@ class CodeCoverageManager {
|
|||
* @param string $execCodeLines
|
||||
* @param string $output
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function reportGroupCli($testObjectFiles, $coverageData, $execCodeLines) {
|
||||
$manager = CodeCoverageManager::getInstance();
|
||||
|
@ -670,7 +681,6 @@ class CodeCoverageManager {
|
|||
$manager =& CodeCoverageManager::getInstance();
|
||||
$codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount);
|
||||
$class = 'bad';
|
||||
|
||||
if ($codeCoverage > 50) {
|
||||
$class = 'ok';
|
||||
}
|
||||
|
@ -691,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";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
226
cake/tests/lib/reporter/cake_base_reporter.php
Normal file
226
cake/tests/lib/reporter/cake_base_reporter.php
Normal file
|
@ -0,0 +1,226 @@
|
|||
<?php
|
||||
/**
|
||||
* CakeBaseReporter contains common functionality to all cake test suite reporters.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* 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.tests.libs.reporter
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* - 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.
|
||||
* @access public
|
||||
*/
|
||||
function CakeBaseReporter($charset = 'utf-8', $params = array()) {
|
||||
$this->SimpleReporter();
|
||||
if (!$charset) {
|
||||
$charset = 'utf-8';
|
||||
}
|
||||
$this->_characterSet = $charset;
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return float Time in microseconds
|
||||
* @access protected
|
||||
*/
|
||||
function _getTime() {
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
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() {
|
||||
$testList = TestManager::getTestCaseList();
|
||||
return $testList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
$testList = TestManager::getGroupTestList();
|
||||
return $testList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the start of the response from the test suite.
|
||||
* Used to paint things like head elements in an html page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function paintDocumentStart() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the end of the response from the test suite.
|
||||
* Used to paint things like </body> in an html page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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 '';
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
179
cake/tests/lib/reporter/cake_cli_reporter.php
Normal file
179
cake/tests/lib/reporter/cake_cli_reporter.php
Normal file
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
/**
|
||||
* Cake CLI test reporter.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* 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.2.0.4433
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
if (version_compare(PHP_VERSION, '4.4.4', '<=') ||
|
||||
PHP_SAPI == 'cgi') {
|
||||
define('STDOUT', fopen('php://stdout', 'w'));
|
||||
define('STDERR', fopen('php://stderr', 'w'));
|
||||
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.
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.libs.reporter
|
||||
*/
|
||||
class CakeCliReporter extends CakeBaseReporter {
|
||||
/**
|
||||
* separator string for fail, error, exception, and skip messages.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $separator = '->';
|
||||
|
||||
/**
|
||||
* array of 'request' parameters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $params = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $separator
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
function CakeCLIReporter($charset = 'utf-8', $params = array()) {
|
||||
$this->CakeBaseReporter($charset, $params);
|
||||
}
|
||||
|
||||
function setFailDetailSeparator($separator) {
|
||||
$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);
|
||||
$message .= $this->_getBreadcrumb();
|
||||
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);
|
||||
$message .= $this->_getBreadcrumb();
|
||||
fwrite(STDERR, 'ERROR' . $this->separator . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint exception faildetail to STDERR.
|
||||
*
|
||||
* @param string $message Message of the Error
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
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()
|
||||
);
|
||||
$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);
|
||||
$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");
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint a footer with test case name, timestamp, counts of fails and exceptions.
|
||||
*/
|
||||
function paintFooter($test_name) {
|
||||
$buffer = $this->getTestCaseProgress() . '/' . $this->getTestCaseCount() . ' test cases complete: ';
|
||||
|
||||
if (0 < ($this->getFailCount() + $this->getExceptionCount())) {
|
||||
$buffer .= $this->getPassCount() . " passes";
|
||||
if (0 < $this->getFailCount()) {
|
||||
$buffer .= ", " . $this->getFailCount() . " fails";
|
||||
}
|
||||
if (0 < $this->getExceptionCount()) {
|
||||
$buffer .= ", " . $this->getExceptionCount() . " exceptions";
|
||||
}
|
||||
$buffer .= ".\n";
|
||||
$buffer .= $this->_timeStats();
|
||||
fwrite(STDOUT, $buffer);
|
||||
} else {
|
||||
fwrite(STDOUT, $buffer . $this->getPassCount() . " passes.\n" . $this->_timeStats());
|
||||
}
|
||||
|
||||
if (
|
||||
isset($this->params['codeCoverage']) &&
|
||||
$this->params['codeCoverage'] &&
|
||||
class_exists('CodeCoverageManager')
|
||||
) {
|
||||
CodeCoverageManager::report();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Short description for file.
|
||||
* CakeHtmlReporter
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
|
@ -11,100 +11,133 @@
|
|||
* 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
|
||||
* @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
|
||||
*/
|
||||
include_once dirname(__FILE__) . DS . 'cake_base_reporter.php';
|
||||
|
||||
/**
|
||||
* CakeHtmlReporter Reports Results of TestSuites and Test Cases
|
||||
* in an HTML format / context.
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.tests.lib
|
||||
* @subpackage cake.tests.lib
|
||||
*/
|
||||
class CakeHtmlReporter extends SimpleReporter {
|
||||
var $_character_set;
|
||||
var $_show_passes = false;
|
||||
|
||||
var $_timeStart = 0;
|
||||
var $_timeEnd = 0;
|
||||
var $_timeDuration = 0;
|
||||
|
||||
/**
|
||||
* Does nothing yet. The first output will
|
||||
* be sent on the first test start. For use
|
||||
* by a web browser.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function CakeHtmlReporter($character_set = 'ISO-8859-1') {
|
||||
if (isset($_GET['show_passes']) && $_GET['show_passes']) {
|
||||
$this->_show_passes = true;
|
||||
}
|
||||
$this->SimpleReporter();
|
||||
$this->_character_set = $character_set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signals / Paints the beginning of a TestSuite executing.
|
||||
* Starts the timer for the TestSuite execution time.
|
||||
*
|
||||
* @param
|
||||
* @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.
|
||||
*
|
||||
* @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 CakeHtmlReporter extends CakeBaseReporter {
|
||||
|
||||
/**
|
||||
* Paints the top of the web page setting the
|
||||
* title to the name of the starting test.
|
||||
*
|
||||
* @param string $test_name Name class of test.
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function paintHeader($testName) {
|
||||
$this->sendNoCacheHeaders();
|
||||
$this->paintDocumentStart();
|
||||
$this->paintTestMenu();
|
||||
echo "<h2>$testName</h2>\n";
|
||||
echo "<ul class='tests'>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the document start content contained in header.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function paintDocumentStart() {
|
||||
ob_start();
|
||||
$baseDir = $this->params['baseDir'];
|
||||
include CAKE_TESTS_LIB . 'templates' . DS . 'header.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the menu on the left side of the test suite interface.
|
||||
* Contains all of the various plugin, core, and app buttons.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function paintTestMenu() {
|
||||
$groups = $this->baseUrl() . '?show=groups';
|
||||
$cases = $this->baseUrl() . '?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() {
|
||||
$testCases = parent::testCaseList();
|
||||
$app = $this->params['app'];
|
||||
$plugin = $this->params['plugin'];
|
||||
|
||||
$buffer = "<h3>Core Test Cases:</h3>\n<ul>";
|
||||
$urlExtra = null;
|
||||
if ($app) {
|
||||
$buffer = "<h3>App Test Cases:</h3>\n<ul>";
|
||||
$urlExtra = '&app=true';
|
||||
} elseif ($plugin) {
|
||||
$buffer = "<h3>" . Inflector::humanize($plugin) . " Test Cases:</h3>\n<ul>";
|
||||
$urlExtra = '&plugin=' . $plugin;
|
||||
}
|
||||
|
||||
if (1 > count($testCases)) {
|
||||
$buffer .= "<strong>EMPTY</strong>";
|
||||
}
|
||||
|
||||
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 .= "<li><a href='" . $this->baseUrl() . "?case=" . urlencode($testCase) . $urlExtra ."'>" . $title . "</a></li>\n";
|
||||
}
|
||||
$buffer .= "</ul>\n";
|
||||
echo $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves and paints the list of group tests in an HTML format.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function groupTestList() {
|
||||
$groupTests = parent::groupTestList();
|
||||
$app = $this->params['app'];
|
||||
$plugin = $this->params['plugin'];
|
||||
|
||||
$buffer = "<h3>Core Test Groups:</h3>\n<ul>";
|
||||
$urlExtra = null;
|
||||
if ($app) {
|
||||
$buffer = "<h3>App Test Groups:</h3>\n<ul>";
|
||||
$urlExtra = '&app=true';
|
||||
} else if ($plugin) {
|
||||
$buffer = "<h3>" . Inflector::humanize($plugin) . " Test Groups:</h3>\n<ul>";
|
||||
$urlExtra = '&plugin=' . $plugin;
|
||||
}
|
||||
|
||||
$buffer .= "<li><a href='" . $this->baseURL() . "?group=all$urlExtra'>All tests</a></li>\n";
|
||||
|
||||
foreach ($groupTests as $groupTest) {
|
||||
$buffer .= "<li><a href='" . $this->baseURL() . "?group={$groupTest}" . "{$urlExtra}'>" . $groupTest . "</a></li>\n";
|
||||
}
|
||||
$buffer .= "</ul>\n";
|
||||
echo $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the headers necessary to ensure the page is
|
||||
* 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()) {
|
||||
|
@ -121,6 +154,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) {
|
||||
|
@ -140,7 +174,74 @@ class CakeHtmlReporter extends SimpleReporter {
|
|||
if (function_exists('memory_get_peak_usage')) {
|
||||
echo '<p><strong>Peak memory use: (in bytes):</strong> ' . number_format(memory_get_peak_usage()) . '</p>';
|
||||
}
|
||||
echo $this->_paintLinks();
|
||||
echo '</div>';
|
||||
if (
|
||||
isset($this->params['codeCoverage']) &&
|
||||
$this->params['codeCoverage'] &&
|
||||
class_exists('CodeCoverageManager')
|
||||
) {
|
||||
CodeCoverageManager::report();
|
||||
}
|
||||
$this->paintDocumentEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 "<p><a href='" . $this->baseUrl() . $show . "'>Run more tests</a> | <a href='" . $this->baseUrl() . $query . "&show_passes=1'>Show Passes</a> | \n";
|
||||
echo " <a href='" . $this->baseUrl() . $query . "&code_coverage=true'>Analyze Code Coverage</a></p>\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 end of the document html.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function paintDocumentEnd() {
|
||||
$baseDir = $this->params['baseDir'];
|
||||
include CAKE_TESTS_LIB . 'templates' . DS . 'footer.php';
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,6 +251,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) {
|
||||
|
@ -157,7 +259,7 @@ class CakeHtmlReporter extends SimpleReporter {
|
|||
echo "<li class='fail'>\n";
|
||||
echo "<span>Failed</span>";
|
||||
echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
||||
$breadcrumb = Set::filter($this->getTestList());
|
||||
$breadcrumb = $this->getTestList();
|
||||
array_shift($breadcrumb);
|
||||
echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
||||
echo "</li>\n";
|
||||
|
@ -169,15 +271,16 @@ 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) {
|
||||
parent::paintPass($message);
|
||||
|
||||
if ($this->_show_passes) {
|
||||
if (isset($this->params['show_passes']) && $this->params['show_passes']) {
|
||||
echo "<li class='pass'>\n";
|
||||
echo "<span>Passed</span> ";
|
||||
$breadcrumb = Set::filter($this->getTestList());
|
||||
$breadcrumb = $this->getTestList();
|
||||
array_shift($breadcrumb);
|
||||
echo implode(" -> ", $breadcrumb);
|
||||
echo "<br />" . $this->_htmlEntities($message) . "\n";
|
||||
|
@ -189,6 +292,7 @@ class CakeHtmlReporter extends SimpleReporter {
|
|||
* Paints a PHP error.
|
||||
*
|
||||
* @param string $message Message is ignored.
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function paintError($message) {
|
||||
|
@ -196,7 +300,7 @@ class CakeHtmlReporter extends SimpleReporter {
|
|||
echo "<li class='error'>\n";
|
||||
echo "<span>Error</span>";
|
||||
echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
||||
$breadcrumb = Set::filter($this->getTestList());
|
||||
$breadcrumb = $this->getTestList();
|
||||
array_shift($breadcrumb);
|
||||
echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
||||
echo "</li>\n";
|
||||
|
@ -206,6 +310,7 @@ class CakeHtmlReporter extends SimpleReporter {
|
|||
* Paints a PHP exception.
|
||||
*
|
||||
* @param Exception $exception Exception to display.
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function paintException($exception) {
|
||||
|
@ -217,7 +322,7 @@ class CakeHtmlReporter extends SimpleReporter {
|
|||
'] in ['. $exception->getFile() .
|
||||
' line ' . $exception->getLine() . ']';
|
||||
echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
||||
$breadcrumb = Set::filter($this->getTestList());
|
||||
$breadcrumb = $this->getTestList();
|
||||
array_shift($breadcrumb);
|
||||
echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
||||
echo "</li>\n";
|
||||
|
@ -226,7 +331,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) {
|
||||
|
@ -241,6 +347,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) {
|
||||
|
@ -255,7 +362,7 @@ class CakeHtmlReporter extends SimpleReporter {
|
|||
* @access protected
|
||||
*/
|
||||
function _htmlEntities($message) {
|
||||
return htmlentities($message, ENT_COMPAT, $this->_character_set);
|
||||
return htmlentities($message, ENT_COMPAT, $this->_characterSet);
|
||||
}
|
||||
}
|
||||
?>
|
199
cake/tests/lib/reporter/cake_text_reporter.php
Normal file
199
cake/tests/lib/reporter/cake_text_reporter.php
Normal file
|
@ -0,0 +1,199 @@
|
|||
<?php
|
||||
/**
|
||||
* CakeTextReporter contains reporting features used for plain text based output
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* 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.tests.libs.reporter
|
||||
* @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';
|
||||
|
||||
/**
|
||||
* CakeTextReporter contains reporting features used for plain text based output
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.lib
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param string $test_name Name class of test.
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function 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";
|
||||
}
|
||||
if (
|
||||
isset($this->params['codeCoverage']) &&
|
||||
$this->params['codeCoverage'] &&
|
||||
class_exists('CodeCoverageManager')
|
||||
) {
|
||||
CodeCoverageManager::report();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the title only.
|
||||
*
|
||||
* @param string $test_name Name class of test.
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function paintHeader($test_name) {
|
||||
$this->paintDocumentStart();
|
||||
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.
|
||||
* @return void
|
||||
* @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.
|
||||
* @return void
|
||||
* @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.
|
||||
* @return void
|
||||
* @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.
|
||||
* @return void
|
||||
* @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.
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function paintFormattedMessage($message) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -22,8 +22,14 @@
|
|||
<div id="footer">
|
||||
<!--PLEASE USE ONE OF THE POWERED BY CAKEPHP LOGO-->
|
||||
<a href="http://www.cakephp.org/" target="_blank">
|
||||
<img src="<?php echo $baseUrl; ?>img/cake.power.gif" alt="CakePHP(tm) :: Rapid Development Framework" /></a></p>
|
||||
<img src="<?php echo $baseDir; ?>img/cake.power.gif" alt="CakePHP(tm) :: Rapid Development Framework" /></a></p>
|
||||
</div>
|
||||
<?php
|
||||
App::import('Core', 'View');
|
||||
$null = null;
|
||||
$View =& new View($null, false);
|
||||
echo $View->element('sql_dump');
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -21,7 +21,7 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv='content-Type' content='text/html; <?php echo $characterSet; ?>' />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>CakePHP Test Suite 1.3</title>
|
||||
<style type="text/css">
|
||||
h3 {font-size: 170%; padding-top: 1em}
|
||||
|
@ -114,7 +114,7 @@
|
|||
div.code-coverage-results span.result-ok { color: #fa0; }
|
||||
div.code-coverage-results span.result-good { color: #0a0; }
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $baseUrl; ?>css/cake.generic.css" />
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $baseDir; ?>css/cake.generic.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
|
@ -21,7 +21,7 @@
|
|||
<div class="test-menu">
|
||||
<ul>
|
||||
<li>
|
||||
<span style="font-size: 18px">App</span>
|
||||
<span style="font-size: 18px">App</span>
|
||||
<ul>
|
||||
<li><a href='<?php echo $groups;?>&app=true'>Test Groups</a></li>
|
||||
<li><a href='<?php echo $cases;?>&app=true'>Test Cases</a></li>
|
||||
|
@ -31,7 +31,7 @@
|
|||
if (!empty($plugins)):
|
||||
?>
|
||||
<li style="padding-top: 10px">
|
||||
<span style="font-size: 18px">Plugins</span>
|
||||
<span style="font-size: 18px">Plugins</span>
|
||||
<?php foreach($plugins as $plugin):
|
||||
$pluginPath = Inflector::underscore($plugin);
|
||||
?>
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Short description for file.
|
||||
* Missing SimpleTest error page.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
|
@ -18,6 +18,7 @@
|
|||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
?>
|
||||
<?php include dirname(__FILE__) . DS . 'header.php'; ?>
|
||||
<div id="content">
|
||||
<h2>SimpleTest is not installed</h2>
|
||||
<p>You must install SimpleTest to use the CakePHP(tm) Test Suite.</p>
|
||||
|
@ -27,4 +28,5 @@
|
|||
<li><?php echo APP_DIR . DS; ?>vendors</li>
|
||||
</ul>
|
||||
<p><a href="http://simpletest.org/en/download.html" target="_blank">Download SimpleTest</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php include dirname(__FILE__) . DS . 'footer.php'; ?>
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Short description for file.
|
||||
* Xdebug error page
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
|
@ -18,7 +18,10 @@
|
|||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
?>
|
||||
<div id="content">
|
||||
<h2>Xdebug is not installed</h2>
|
||||
<p>You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation.</p>
|
||||
<p><a href="http://www.xdebug.org/docs/install" target="_blank">Learn How To Install Xdebug</a></p>
|
||||
<?php include dirname(__FILE__) . DS . 'header.php'; ?>
|
||||
<div id="content">
|
||||
<h2>Xdebug is not installed</h2>
|
||||
<p>You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation.</p>
|
||||
<p><a href="http://www.xdebug.org/docs/install" target="_blank">Learn How To Install Xdebug</a></p>
|
||||
</div>
|
||||
<?php include dirname(__FILE__) . DS . 'footer.php'; ?>
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Short description for file.
|
||||
* TestManager for CakePHP Test suite.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
|
@ -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,18 +93,17 @@ 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) {
|
||||
$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');
|
||||
}
|
||||
|
@ -99,15 +122,14 @@ 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 Result of test case being run.
|
||||
* @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);
|
||||
|
@ -126,14 +148,13 @@ 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 Results of group test being run.
|
||||
* @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);
|
||||
|
@ -141,7 +162,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)) {
|
||||
|
@ -154,10 +175,11 @@ 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
|
||||
* @static
|
||||
*/
|
||||
function addTestCasesFromDirectory(&$groupTest, $directory = '.') {
|
||||
$manager =& new TestManager();
|
||||
|
@ -170,18 +192,19 @@ 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
|
||||
* @static
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
@ -190,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();
|
||||
|
@ -200,7 +224,8 @@ class TestManager {
|
|||
/**
|
||||
* Builds the list of test cases from a given directory
|
||||
*
|
||||
* @access public
|
||||
* @param string $directory Directory to get test case list from.
|
||||
* @access protected
|
||||
*/
|
||||
function &_getTestCaseList($directory = '.') {
|
||||
$fileList =& $this->_getTestFileList($directory);
|
||||
|
@ -214,7 +239,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'));
|
||||
|
@ -225,6 +251,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();
|
||||
|
@ -235,7 +262,8 @@ class TestManager {
|
|||
/**
|
||||
* Returns a list of group test files from a given directory
|
||||
*
|
||||
* @access public
|
||||
* @param string $directory The directory to get group test files from.
|
||||
* @access protected
|
||||
*/
|
||||
function &_getTestGroupFileList($directory = '.') {
|
||||
$return = $this->_getRecursiveFileList($directory, array(&$this, '_isTestGroupFile'));
|
||||
|
@ -245,7 +273,8 @@ class TestManager {
|
|||
/**
|
||||
* Returns a list of group test files from a given directory
|
||||
*
|
||||
* @access public
|
||||
* @param string $directory The directory to get group tests from.
|
||||
* @access protected
|
||||
*/
|
||||
function &_getTestGroupList($directory = '.') {
|
||||
$fileList =& $this->_getTestGroupFileList($directory);
|
||||
|
@ -261,7 +290,8 @@ class TestManager {
|
|||
/**
|
||||
* Returns a list of class names from a group test file
|
||||
*
|
||||
* @access public
|
||||
* @param string $groupTestFile The groupTest file to scan for TestSuite classnames.
|
||||
* @access protected
|
||||
*/
|
||||
function &_getGroupTestClassNames($groupTestFile) {
|
||||
$file = implode("\n", file($groupTestFile));
|
||||
|
@ -278,7 +308,9 @@ class TestManager {
|
|||
* Gets a recursive list of files from a given directory and matches then against
|
||||
* a given fileTestFunction, like isTestCaseFile()
|
||||
*
|
||||
* @access public
|
||||
* @param string $directory The directory to scan for files.
|
||||
* @param mixed $fileTestFunction
|
||||
* @access protected
|
||||
*/
|
||||
function &_getRecursiveFileList($directory = '.', $fileTestFunction) {
|
||||
$fileList = array();
|
||||
|
@ -303,8 +335,8 @@ class TestManager {
|
|||
* Tests if a file has the correct test case extension
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
* @access public
|
||||
* @return boolean Whether $file is a test case.
|
||||
* @access protected
|
||||
*/
|
||||
function _isTestCaseFile($file) {
|
||||
return $this->_hasExpectedExtension($file, $this->_testExtension);
|
||||
|
@ -314,8 +346,8 @@ class TestManager {
|
|||
* Tests if a file has the correct group test extension
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
* @access public
|
||||
* @return boolean Whether $file is a group
|
||||
* @access protected
|
||||
*/
|
||||
function _isTestGroupFile($file) {
|
||||
return $this->_hasExpectedExtension($file, $this->_groupExtension);
|
||||
|
@ -327,7 +359,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))));
|
||||
|
@ -336,9 +368,9 @@ class TestManager {
|
|||
/**
|
||||
* Returns the given path to the test files depending on a given type of tests (cases, group, ..)
|
||||
*
|
||||
* @param string $type
|
||||
* @return void
|
||||
* @access public
|
||||
* @param string $type either 'cases' or 'groups'
|
||||
* @return string The path tests are located on
|
||||
* @access protected
|
||||
*/
|
||||
function _getTestsPath($type = 'cases') {
|
||||
if (!empty($this->appTest)) {
|
||||
|
@ -365,453 +397,18 @@ 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') {
|
||||
$manager =& new TestManager();
|
||||
if ($type == 'test') {
|
||||
return $manager->_testExtension;
|
||||
if ($type == 'test' || $type == 'case') {
|
||||
return $this->_testExtension;
|
||||
}
|
||||
return $manager->_groupExtension;
|
||||
return $this->_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";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 void
|
||||
* @access public
|
||||
*/
|
||||
function getBaseURL() {
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of available group tests in a text-friendly format
|
||||
*
|
||||
* @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=txt{$urlExtra}"."\n";
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of available test cases in a text-friendly format
|
||||
*
|
||||
* @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=txt"."\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() {
|
||||
$urlExtra = '';
|
||||
$manager =& new HtmlTestManager();
|
||||
$groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups'));
|
||||
|
||||
$buffer = "<h3>Core Test Groups:</h3>\n<ul>";
|
||||
$urlExtra = null;
|
||||
if ($manager->appTest) {
|
||||
$buffer = "<h3>App Test Groups:</h3>\n<ul>";
|
||||
$urlExtra = '&app=true';
|
||||
} else if ($manager->pluginTest) {
|
||||
$buffer = "<h3>" . Inflector::humanize($manager->pluginTest) . " Test Groups:</h3>\n<ul>";
|
||||
$urlExtra = '&plugin=' . $manager->pluginTest;
|
||||
}
|
||||
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group=all$urlExtra'>All tests</a></li>\n";
|
||||
|
||||
foreach ($groupTests as $groupTest) {
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$groupTest}" . "{$urlExtra}'>" . $groupTest . "</a></li>\n";
|
||||
}
|
||||
$buffer .= "</ul>\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 = "<h3>Core Test Cases:</h3>\n<ul>";
|
||||
$urlExtra = null;
|
||||
if ($manager->appTest) {
|
||||
$buffer = "<h3>App Test Cases:</h3>\n<ul>";
|
||||
$urlExtra = '&app=true';
|
||||
} else if ($manager->pluginTest) {
|
||||
$buffer = "<h3>" . Inflector::humanize($manager->pluginTest) . " Test Cases:</h3>\n<ul>";
|
||||
$urlExtra = '&plugin=' . $manager->pluginTest;
|
||||
}
|
||||
|
||||
if (1 > count($testCases)) {
|
||||
$buffer .= "<strong>EMPTY</strong>";
|
||||
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 .= "<li><a href='" . $manager->getBaseURL() . "?case=" . urlencode($testCase) . $urlExtra ."'>" . $title . "</a></li>\n";
|
||||
}
|
||||
$buffer .= "</ul>\n";
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 "<p><a href='" . RUN_TEST_LINK . $show . "'>Run more tests</a> | <a href='" . RUN_TEST_LINK . $query . "&show_passes=1'>Show Passes</a> | \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 " <a href='" . RUN_TEST_LINK . $query . "'>Analyze Code Coverage</a></p>\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;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue