mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '1.3' of git@thechaw.com:cakephp into 1.3-jshelper
Conflicts: cake/libs/view/helpers/html.php
This commit is contained in:
commit
4b690237f0
72 changed files with 2226 additions and 565 deletions
|
@ -95,7 +95,7 @@ if (!class_exists('File')) {
|
|||
|
||||
header("Date: " . date("D, j M Y G:i:s ", $templateModified) . 'GMT');
|
||||
header("Content-Type: text/css");
|
||||
header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
|
||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + DAY) . " GMT");
|
||||
header("Cache-Control: max-age=86400, must-revalidate"); // HTTP/1.1
|
||||
header("Pragma: cache"); // HTTP/1.0
|
||||
print $output;
|
||||
|
|
|
@ -471,11 +471,11 @@ class Shell extends Object {
|
|||
if (App::import('vendor', 'simpletest' . DS . 'simpletest')) {
|
||||
return true;
|
||||
}
|
||||
$unitTest = $this->in('Cake test suite not installed. Do you want to bake unit test files anyway?', array('y','n'), 'y');
|
||||
$unitTest = $this->in('SimpleTest is not installed. Do you want to bake unit test files anyway?', array('y','n'), 'y');
|
||||
$result = low($unitTest) == 'y' || low($unitTest) == 'yes';
|
||||
|
||||
if ($result) {
|
||||
$this->out("\nYou can download the Cake test suite from http://cakeforge.org/projects/testsuite/", true);
|
||||
$this->out("\nYou can download SimpleTest from http://simpletest.org", true);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -668,6 +668,9 @@ class ExtractTask extends Shell{
|
|||
$files = glob("$path*.{php,ctp,thtml,inc,tpl}", GLOB_BRACE);
|
||||
$dirs = glob("$path*", GLOB_ONLYDIR);
|
||||
|
||||
$files = $files ? $files : array();
|
||||
$dirs = $dirs ? $dirs : array();
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
if (!preg_match("!(^|.+/)(CVS|.svn)$!", $dir)) {
|
||||
$files = array_merge($files, $this->__searchDirectory("$dir" . DS));
|
||||
|
|
|
@ -570,13 +570,13 @@ class ModelTask extends Shell {
|
|||
$belongsToCount = count($associations['belongsTo']);
|
||||
|
||||
for ($i = 0; $i < $belongsToCount; $i++) {
|
||||
$out .= "\t\t\t'{$associations['belongsTo'][$i]['alias']}' => ";
|
||||
$out .= "array('className' => '{$associations['belongsTo'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'foreignKey' => '{$associations['belongsTo'][$i]['foreignKey']}',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'conditions' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'fields' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'order' => ''\n";
|
||||
$out .= "\t\t\t)";
|
||||
$out .= "\t\t'{$associations['belongsTo'][$i]['alias']}' => array(\n";
|
||||
$out .= "\t\t\t'className' => '{$associations['belongsTo'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t'foreignKey' => '{$associations['belongsTo'][$i]['foreignKey']}',\n";
|
||||
$out .= "\t\t\t'conditions' => '',\n";
|
||||
$out .= "\t\t\t'fields' => '',\n";
|
||||
$out .= "\t\t\t'order' => ''\n";
|
||||
$out .= "\t\t)";
|
||||
if ($i + 1 < $belongsToCount) {
|
||||
$out .= ",";
|
||||
}
|
||||
|
@ -591,14 +591,14 @@ class ModelTask extends Shell {
|
|||
$hasOneCount = count($associations['hasOne']);
|
||||
|
||||
for ($i = 0; $i < $hasOneCount; $i++) {
|
||||
$out .= "\t\t\t'{$associations['hasOne'][$i]['alias']}' => ";
|
||||
$out .= "array('className' => '{$associations['hasOne'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'foreignKey' => '{$associations['hasOne'][$i]['foreignKey']}',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'dependent' => false,\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'conditions' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'fields' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'order' => ''\n";
|
||||
$out .= "\t\t\t)";
|
||||
$out .= "\t\t'{$associations['hasOne'][$i]['alias']}' => array(\n";
|
||||
$out .= "\t\t\t'className' => '{$associations['hasOne'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t'foreignKey' => '{$associations['hasOne'][$i]['foreignKey']}',\n";
|
||||
$out .= "\t\t\t'dependent' => false,\n";
|
||||
$out .= "\t\t\t'conditions' => '',\n";
|
||||
$out .= "\t\t\t'fields' => '',\n";
|
||||
$out .= "\t\t\t'order' => ''\n";
|
||||
$out .= "\t\t)";
|
||||
if ($i + 1 < $hasOneCount) {
|
||||
$out .= ",";
|
||||
}
|
||||
|
@ -613,19 +613,19 @@ class ModelTask extends Shell {
|
|||
$hasManyCount = count($associations['hasMany']);
|
||||
|
||||
for ($i = 0; $i < $hasManyCount; $i++) {
|
||||
$out .= "\t\t\t'{$associations['hasMany'][$i]['alias']}' => ";
|
||||
$out .= "array('className' => '{$associations['hasMany'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'foreignKey' => '{$associations['hasMany'][$i]['foreignKey']}',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'dependent' => false,\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'conditions' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'fields' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'order' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'limit' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'offset' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'exclusive' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'finderQuery' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'counterQuery' => ''\n";
|
||||
$out .= "\t\t\t)";
|
||||
$out .= "\t\t'{$associations['hasMany'][$i]['alias']}' => array(\n";
|
||||
$out .= "\t\t\t'className' => '{$associations['hasMany'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t'foreignKey' => '{$associations['hasMany'][$i]['foreignKey']}',\n";
|
||||
$out .= "\t\t\t'dependent' => false,\n";
|
||||
$out .= "\t\t\t'conditions' => '',\n";
|
||||
$out .= "\t\t\t'fields' => '',\n";
|
||||
$out .= "\t\t\t'order' => '',\n";
|
||||
$out .= "\t\t\t'limit' => '',\n";
|
||||
$out .= "\t\t\t'offset' => '',\n";
|
||||
$out .= "\t\t\t'exclusive' => '',\n";
|
||||
$out .= "\t\t\t'finderQuery' => '',\n";
|
||||
$out .= "\t\t\t'counterQuery' => ''\n";
|
||||
$out .= "\t\t)";
|
||||
if ($i + 1 < $hasManyCount) {
|
||||
$out .= ",";
|
||||
}
|
||||
|
@ -639,21 +639,21 @@ class ModelTask extends Shell {
|
|||
$hasAndBelongsToManyCount = count($associations['hasAndBelongsToMany']);
|
||||
|
||||
for ($i = 0; $i < $hasAndBelongsToManyCount; $i++) {
|
||||
$out .= "\t\t\t'{$associations['hasAndBelongsToMany'][$i]['alias']}' => ";
|
||||
$out .= "array('className' => '{$associations['hasAndBelongsToMany'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t\t\t\t'joinTable' => '{$associations['hasAndBelongsToMany'][$i]['joinTable']}',\n";
|
||||
$out .= "\t\t\t\t\t\t'foreignKey' => '{$associations['hasAndBelongsToMany'][$i]['foreignKey']}',\n";
|
||||
$out .= "\t\t\t\t\t\t'associationForeignKey' => '{$associations['hasAndBelongsToMany'][$i]['associationForeignKey']}',\n";
|
||||
$out .= "\t\t\t\t\t\t'unique' => true,\n";
|
||||
$out .= "\t\t\t\t\t\t'conditions' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t'fields' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t'order' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t'limit' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t'offset' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t'finderQuery' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t'deleteQuery' => '',\n";
|
||||
$out .= "\t\t\t\t\t\t'insertQuery' => ''\n";
|
||||
$out .= "\t\t\t)";
|
||||
$out .= "\t\t'{$associations['hasAndBelongsToMany'][$i]['alias']}' => array(\n";
|
||||
$out .= "\t\t\t'className' => '{$associations['hasAndBelongsToMany'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t'joinTable' => '{$associations['hasAndBelongsToMany'][$i]['joinTable']}',\n";
|
||||
$out .= "\t\t\t'foreignKey' => '{$associations['hasAndBelongsToMany'][$i]['foreignKey']}',\n";
|
||||
$out .= "\t\t\t'associationForeignKey' => '{$associations['hasAndBelongsToMany'][$i]['associationForeignKey']}',\n";
|
||||
$out .= "\t\t\t'unique' => true,\n";
|
||||
$out .= "\t\t\t'conditions' => '',\n";
|
||||
$out .= "\t\t\t'fields' => '',\n";
|
||||
$out .= "\t\t\t'order' => '',\n";
|
||||
$out .= "\t\t\t'limit' => '',\n";
|
||||
$out .= "\t\t\t'offset' => '',\n";
|
||||
$out .= "\t\t\t'finderQuery' => '',\n";
|
||||
$out .= "\t\t\t'deleteQuery' => '',\n";
|
||||
$out .= "\t\t\t'insertQuery' => ''\n";
|
||||
$out .= "\t\t)";
|
||||
if ($i + 1 < $hasAndBelongsToManyCount) {
|
||||
$out .= ",";
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ class ModelTask extends Shell {
|
|||
$out .= "\tfunction test{$className}Find() {\n";
|
||||
$out .= "\t\t\$this->{$className}->recursive = -1;\n";
|
||||
$out .= "\t\t\$results = \$this->{$className}->find('first');\n\t\t\$this->assertTrue(!empty(\$results));\n\n";
|
||||
$out .= "\t\t\$expected = array('$className' => array(\n$results\n\t\t\t));\n";
|
||||
$out .= "\t\t\$expected = array('$className' => array(\n$results\n\t\t));\n";
|
||||
$out .= "\t\t\$this->assertEqual(\$results, \$expected);\n";
|
||||
$out .= "\t}\n";
|
||||
$out .= "}\n";
|
||||
|
@ -862,7 +862,7 @@ class ModelTask extends Shell {
|
|||
$type = $value;
|
||||
$value = array('type'=> $type);
|
||||
}
|
||||
$col = "\t\t\t'{$field}' => array('type'=>'" . $value['type'] . "', ";
|
||||
$col = "\t\t'{$field}' => array('type'=>'" . $value['type'] . "', ";
|
||||
|
||||
switch ($value['type']) {
|
||||
case 'integer':
|
||||
|
@ -898,11 +898,11 @@ class ModelTask extends Shell {
|
|||
$insert .= "feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.'";
|
||||
break;
|
||||
}
|
||||
$records[] = "\t\t\t'$field' => $insert";
|
||||
$records[] = "\t\t'$field' => $insert";
|
||||
unset($value['type']);
|
||||
$col .= join(', ', $schema->__values($value));
|
||||
} else {
|
||||
$col = "\t\t\t'indexes' => array(";
|
||||
$col = "\t\t'indexes' => array(";
|
||||
$props = array();
|
||||
foreach ((array)$value as $key => $index) {
|
||||
$props[] = "'{$key}' => array(".join(', ', $schema->__values($index)).")";
|
||||
|
@ -914,11 +914,11 @@ class ModelTask extends Shell {
|
|||
}
|
||||
$out .= join(",\n", $cols);
|
||||
}
|
||||
$out .= "\n\t\t\t);\n";
|
||||
$out .= "\n\t);\n";
|
||||
}
|
||||
}
|
||||
$records = join(",\n", $records);
|
||||
$out .= "\tvar \$records = array(array(\n$records\n\t\t\t));\n";
|
||||
$out .= "\tvar \$records = array(array(\n$records\n\t));\n";
|
||||
$out .= "}\n";
|
||||
$path = TESTS . DS . 'fixtures' . DS;
|
||||
if (isset($this->plugin)) {
|
||||
|
@ -930,7 +930,7 @@ class ModelTask extends Shell {
|
|||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $model ." Fixture generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
|
||||
$this->out("\nBaking test fixture for $model...");
|
||||
if ($this->createFile($path . $filename, $content)) {
|
||||
return $records;
|
||||
return str_replace("\t\t", "\t\t\t", $records);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -87,19 +87,19 @@ class TestTask extends Shell {
|
|||
}
|
||||
|
||||
while ($class == null) {
|
||||
$cases = array();
|
||||
$this->hr();
|
||||
$this->out("Select a class:");
|
||||
$this->hr();
|
||||
|
||||
$this->hr();
|
||||
$this->out("Select a class:");
|
||||
$this->hr();
|
||||
$keys = array();
|
||||
foreach ($options as $key => $option) {
|
||||
$this->out(++$key . '. ' . $option);
|
||||
$keys[] = $key;
|
||||
}
|
||||
$keys[] = 'q';
|
||||
|
||||
$keys = array();
|
||||
foreach ($options as $key => $option) {
|
||||
$this->out(++$key . '. ' . $option);
|
||||
$keys[] = $key;
|
||||
}
|
||||
$keys[] = 'q';
|
||||
|
||||
$key = $this->in(__("Enter the class to test or (q)uit", true), $keys, 'q');
|
||||
$key = $this->in(__("Enter the class to test or (q)uit", true), $keys, 'q');
|
||||
|
||||
if ($key != 'q') {
|
||||
if (isset($options[--$key])) {
|
||||
|
@ -143,7 +143,7 @@ class TestTask extends Shell {
|
|||
}
|
||||
|
||||
if (strpos($this->path, $class) === false) {
|
||||
$this->path .= 'cases' . DS . Inflector::tableize($class) . DS;
|
||||
$this->filePath = $this->path . 'cases' . DS . Inflector::tableize($class) . DS;
|
||||
}
|
||||
|
||||
$class = Inflector::classify($class);
|
||||
|
@ -175,14 +175,14 @@ class TestTask extends Shell {
|
|||
|
||||
$this->out("Baking unit test for $name...");
|
||||
$this->out($out);
|
||||
$ok = $this->in(__('Is this correct?'), array('y', 'n'), 'y');
|
||||
$ok = $this->in(__('Is this correct?', true), array('y', 'n'), 'y');
|
||||
if ($ok == 'n') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$header = '$Id';
|
||||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $name ." Test cases generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
|
||||
return $this->createFile($this->path . Inflector::underscore($name) . '.test.php', $content);
|
||||
return $this->createFile($this->filePath . Inflector::underscore($name) . '.test.php', $content);
|
||||
}
|
||||
/**
|
||||
* Handles the extra stuff needed
|
||||
|
|
|
@ -87,7 +87,6 @@ class Dispatcher extends Object {
|
|||
if ($base !== false) {
|
||||
Configure::write('App.base', $base);
|
||||
}
|
||||
|
||||
if ($url !== null) {
|
||||
return $this->dispatch($url);
|
||||
}
|
||||
|
@ -105,45 +104,36 @@ class Dispatcher extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function dispatch($url = null, $additionalParams = array()) {
|
||||
$parse = true;
|
||||
|
||||
if (is_array($url)) {
|
||||
$url = $this->__extractParams($url, $additionalParams);
|
||||
$parse = false;
|
||||
}
|
||||
|
||||
if ($this->base === false) {
|
||||
$this->base = $this->baseUrl();
|
||||
}
|
||||
|
||||
if ($url !== null) {
|
||||
$_GET['url'] = $url;
|
||||
if (is_array($url)) {
|
||||
$url = $this->__extractParams($url, $additionalParams);
|
||||
} else {
|
||||
if ($url) {
|
||||
$_GET['url'] = $url;
|
||||
}
|
||||
$url = $this->getUrl();
|
||||
$this->params = array_merge($this->parseParams($url), $additionalParams);
|
||||
}
|
||||
|
||||
if ($parse) {
|
||||
$url = $this->getUrl();
|
||||
}
|
||||
$this->here = $this->base . '/' . $url;
|
||||
|
||||
if ($this->cached($url)) {
|
||||
$this->_stop();
|
||||
}
|
||||
|
||||
if ($parse) {
|
||||
$this->params = array_merge($this->parseParams($url), $additionalParams);
|
||||
}
|
||||
$controller =& $this->__getController();
|
||||
|
||||
if (!is_object($controller)) {
|
||||
Router::setRequestInfo(array($this->params, array('base' => $this->base, 'webroot' => $this->webroot)));
|
||||
return $this->cakeError('missingController', array(
|
||||
array(
|
||||
'className' => Inflector::camelize($this->params['controller']) . 'Controller',
|
||||
'webroot' => $this->webroot,
|
||||
'url' => $url,
|
||||
'base' => $this->base
|
||||
)
|
||||
));
|
||||
return $this->cakeError('missingController', array(array(
|
||||
'className' => Inflector::camelize($this->params['controller']) . 'Controller',
|
||||
'webroot' => $this->webroot,
|
||||
'url' => $url,
|
||||
'base' => $this->base
|
||||
)));
|
||||
}
|
||||
|
||||
$privateAction = (bool)(strpos($this->params['action'], '_', 0) === 0);
|
||||
|
@ -163,15 +153,13 @@ class Dispatcher extends Object {
|
|||
));
|
||||
|
||||
if ($privateAction) {
|
||||
return $this->cakeError('privateAction', array(
|
||||
array(
|
||||
'className' => Inflector::camelize($this->params['controller'] . "Controller"),
|
||||
'action' => $this->params['action'],
|
||||
'webroot' => $this->webroot,
|
||||
'url' => $url,
|
||||
'base' => $this->base
|
||||
)
|
||||
));
|
||||
return $this->cakeError('privateAction', array(array(
|
||||
'className' => Inflector::camelize($this->params['controller'] . "Controller"),
|
||||
'action' => $this->params['action'],
|
||||
'webroot' => $this->webroot,
|
||||
'url' => $url,
|
||||
'base' => $this->base
|
||||
)));
|
||||
}
|
||||
|
||||
$controller->base = $this->base;
|
||||
|
@ -187,15 +175,12 @@ class Dispatcher extends Object {
|
|||
} else {
|
||||
$controller->data = null;
|
||||
}
|
||||
|
||||
if (array_key_exists('return', $this->params) && $this->params['return'] == 1) {
|
||||
$controller->autoRender = false;
|
||||
}
|
||||
|
||||
if (!empty($this->params['bare'])) {
|
||||
$controller->autoLayout = false;
|
||||
}
|
||||
|
||||
if (array_key_exists('layout', $this->params)) {
|
||||
if (empty($this->params['layout'])) {
|
||||
$controller->autoLayout = false;
|
||||
|
@ -203,11 +188,9 @@ class Dispatcher extends Object {
|
|||
$controller->layout = $this->params['layout'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->params['viewPath'])) {
|
||||
$controller->viewPath = $this->params['viewPath'];
|
||||
}
|
||||
|
||||
return $this->_invoke($controller, $this->params);
|
||||
}
|
||||
/**
|
||||
|
@ -233,14 +216,13 @@ class Dispatcher extends Object {
|
|||
App::import('Core', 'Scaffold');
|
||||
return new Scaffold($controller, $params);
|
||||
}
|
||||
return $this->cakeError('missingAction', array(
|
||||
array(
|
||||
'className' => Inflector::camelize($params['controller']."Controller"),
|
||||
'action' => $params['action'],
|
||||
'webroot' => $this->webroot,
|
||||
'url' => $this->here,
|
||||
'base' => $this->base)));
|
||||
|
||||
return $this->cakeError('missingAction', array(array(
|
||||
'className' => Inflector::camelize($params['controller']."Controller"),
|
||||
'action' => $params['action'],
|
||||
'webroot' => $this->webroot,
|
||||
'url' => $this->here,
|
||||
'base' => $this->base
|
||||
)));
|
||||
}
|
||||
$output = $controller->dispatchMethod($params['action'], $params['pass']);
|
||||
|
||||
|
@ -262,16 +244,13 @@ class Dispatcher extends Object {
|
|||
*
|
||||
* @param array $url
|
||||
* @param array $additionalParams
|
||||
* @return null
|
||||
* @return string $url
|
||||
* @access private
|
||||
* @todo commented Router::url(). this improved performance,
|
||||
* will work on this more later.
|
||||
*/
|
||||
function __extractParams($url, $additionalParams = array()) {
|
||||
$defaults = array('pass' => array(), 'named' => array(), 'form' => array());
|
||||
$this->params = array_merge($defaults, $url, $additionalParams);
|
||||
//$url = Router::url($url);
|
||||
//return $url;
|
||||
return Router::url($url);
|
||||
}
|
||||
/**
|
||||
* Returns array of GET and POST parameters. GET parameters are taken from given URL.
|
||||
|
@ -300,19 +279,18 @@ class Dispatcher extends Object {
|
|||
unset($params['form']['_method']);
|
||||
}
|
||||
}
|
||||
extract(Router::getNamedExpressions());
|
||||
$namedExpressions = Router::getNamedExpressions();
|
||||
extract($namedExpressions);
|
||||
include CONFIGS . 'routes.php';
|
||||
$params = array_merge(Router::parse($fromUrl), $params);
|
||||
|
||||
if (empty($params['action'])) {
|
||||
if (strlen($params['action']) === 0) {
|
||||
$params['action'] = 'index';
|
||||
}
|
||||
|
||||
if (isset($params['form']['data'])) {
|
||||
$params['data'] = Router::stripEscape($params['form']['data']);
|
||||
unset($params['form']['data']);
|
||||
}
|
||||
|
||||
if (isset($_GET)) {
|
||||
if (ini_get('magic_quotes_gpc') === '1') {
|
||||
$url = stripslashes_deep($_GET);
|
||||
|
@ -325,13 +303,11 @@ class Dispatcher extends Object {
|
|||
$params['url'] = $url;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($_FILES as $name => $data) {
|
||||
if ($name != 'data') {
|
||||
$params['form'][$name] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_FILES['data'])) {
|
||||
foreach ($_FILES['data'] as $key => $data) {
|
||||
foreach ($data as $model => $fields) {
|
||||
|
@ -363,12 +339,10 @@ class Dispatcher extends Object {
|
|||
if (!$base) {
|
||||
$base = $this->base;
|
||||
}
|
||||
|
||||
if ($base !== false) {
|
||||
$this->webroot = $base . '/';
|
||||
return $this->base = $base;
|
||||
}
|
||||
|
||||
if (!$baseUrl) {
|
||||
$base = dirname(env('PHP_SELF'));
|
||||
|
||||
|
@ -418,10 +392,12 @@ class Dispatcher extends Object {
|
|||
function _restructureParams($params, $reverse = false) {
|
||||
if ($reverse === true) {
|
||||
extract(Router::getArgs($params['action']));
|
||||
$params = array_merge($params, array('controller'=> $params['plugin'],
|
||||
'action'=> $params['controller'],
|
||||
'pass' => array_merge($pass, $params['pass']),
|
||||
'named' => array_merge($named, $params['named'])));
|
||||
$params = array_merge($params, array(
|
||||
'controller'=> $params['plugin'],
|
||||
'action'=> $params['controller'],
|
||||
'pass' => array_merge($pass, $params['pass']),
|
||||
'named' => array_merge($named, $params['named'])
|
||||
));
|
||||
$this->plugin = $params['plugin'];
|
||||
} else {
|
||||
$params['plugin'] = $params['controller'];
|
||||
|
@ -444,24 +420,29 @@ class Dispatcher extends Object {
|
|||
*/
|
||||
function &__getController($params = null) {
|
||||
if (!is_array($params)) {
|
||||
$params = $this->params;
|
||||
$original = $params = $this->params;
|
||||
}
|
||||
$controller = false;
|
||||
|
||||
if (!$ctrlClass = $this->__loadController($params)) {
|
||||
$ctrlClass = $this->__loadController($params);
|
||||
if (!$ctrlClass) {
|
||||
if (!isset($params['plugin'])) {
|
||||
$params = $this->_restructureParams($params);
|
||||
} else {
|
||||
if (empty($original['pass']) && $original['action'] == 'index') {
|
||||
$params['action'] = null;
|
||||
}
|
||||
$params = $this->_restructureParams($params, true);
|
||||
}
|
||||
|
||||
if (!$ctrlClass = $this->__loadController($params)) {
|
||||
$ctrlClass = $this->__loadController($params);
|
||||
if (!$ctrlClass) {
|
||||
$this->params = $original;
|
||||
return $controller;
|
||||
}
|
||||
} else {
|
||||
$params = $this->params;
|
||||
}
|
||||
$name = $ctrlClass;
|
||||
$ctrlClass = $ctrlClass . 'Controller';
|
||||
|
||||
if (class_exists($ctrlClass)) {
|
||||
if (strtolower(get_parent_class($ctrlClass)) === strtolower($name . 'AppController') && empty($params['plugin'])) {
|
||||
$params = $this->_restructureParams($params);
|
||||
|
@ -481,7 +462,6 @@ class Dispatcher extends Object {
|
|||
*/
|
||||
function __loadController($params) {
|
||||
$pluginName = $pluginPath = $controller = null;
|
||||
|
||||
if (!empty($params['plugin'])) {
|
||||
$this->plugin = $params['plugin'];
|
||||
$pluginName = Inflector::camelize($params['plugin']);
|
||||
|
@ -489,11 +469,10 @@ class Dispatcher extends Object {
|
|||
$this->params['controller'] = $this->plugin;
|
||||
$controller = $pluginName;
|
||||
}
|
||||
|
||||
if (!empty($params['controller'])) {
|
||||
$this->params['controller'] = $params['controller'];
|
||||
$controller = Inflector::camelize($params['controller']);
|
||||
}
|
||||
|
||||
if ($pluginPath . $controller) {
|
||||
if (App::import('Controller', $pluginPath . $controller)) {
|
||||
return $controller;
|
||||
|
@ -522,11 +501,9 @@ class Dispatcher extends Object {
|
|||
if ($base) {
|
||||
$uri = preg_replace('/^(?:\/)?(?:' . preg_quote($base, '/') . ')?(?:url=)?/', '', $uri);
|
||||
}
|
||||
|
||||
if (PHP_SAPI == 'isapi') {
|
||||
$uri = preg_replace('/^(?:\/)?(?:\/)?(?:\?)?(?:url=)?/', '', $uri);
|
||||
}
|
||||
|
||||
if (!empty($uri)) {
|
||||
if (key($_GET) && strpos(key($_GET), '?') !== false) {
|
||||
unset($_GET[key($_GET)]);
|
||||
|
@ -540,11 +517,9 @@ class Dispatcher extends Object {
|
|||
} elseif (empty($uri) && is_string(env('QUERY_STRING'))) {
|
||||
$uri = env('QUERY_STRING');
|
||||
}
|
||||
|
||||
if (strpos($uri, 'index.php') !== false) {
|
||||
list(, $uri) = explode('index.php', $uri, 2);
|
||||
}
|
||||
|
||||
if (empty($uri) || $uri == '/' || $uri == '//') {
|
||||
return '';
|
||||
}
|
||||
|
@ -563,7 +538,6 @@ class Dispatcher extends Object {
|
|||
if ($uri == null) {
|
||||
$uri = $this->uri();
|
||||
}
|
||||
|
||||
if ($base == null) {
|
||||
$base = $this->base;
|
||||
}
|
||||
|
@ -596,7 +570,6 @@ class Dispatcher extends Object {
|
|||
} else {
|
||||
$url = $_GET['url'];
|
||||
}
|
||||
|
||||
if ($url{0} == '/') {
|
||||
$url = substr($url, 1);
|
||||
}
|
||||
|
|
|
@ -142,10 +142,6 @@ class Cache extends Object {
|
|||
* @static
|
||||
*/
|
||||
function engine($name = 'File', $settings = array()) {
|
||||
if (!$name || Configure::read('Cache.disable')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cacheClass = $name . 'Engine';
|
||||
$_this =& Cache::getInstance();
|
||||
if (!isset($_this->_Engine[$name])) {
|
||||
|
|
4
cake/libs/cache/memcache.php
vendored
4
cake/libs/cache/memcache.php
vendored
|
@ -100,8 +100,8 @@ class MemcacheEngine extends CacheEngine {
|
|||
*/
|
||||
function write($key, &$value, $duration) {
|
||||
$expires = time() + $duration;
|
||||
$this->__Memcache->set($key.'_expires', $expires, $this->settings['compress'], $duration);
|
||||
return $this->__Memcache->set($key, $value, $this->settings['compress'], $duration);
|
||||
$this->__Memcache->set($key.'_expires', $expires, $this->settings['compress'], $expires);
|
||||
return $this->__Memcache->set($key, $value, $this->settings['compress'], $expires);
|
||||
}
|
||||
/**
|
||||
* Read a key from the cache
|
||||
|
|
5
cake/libs/cache/xcache.php
vendored
5
cake/libs/cache/xcache.php
vendored
|
@ -107,11 +107,12 @@ class XcacheEngine extends CacheEngine {
|
|||
*/
|
||||
function clear() {
|
||||
$this->__auth();
|
||||
for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
|
||||
$max = xcache_count(XC_TYPE_VAR);
|
||||
for ($i = 0; $i < $max; $i++) {
|
||||
xcache_clear_cache(XC_TYPE_VAR, $i);
|
||||
}
|
||||
$this->__auth(true);
|
||||
return xcache_count(XC_TYPE_VAR) == 0;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Populates and reverses $_SERVER authentication values
|
||||
|
|
|
@ -74,9 +74,6 @@ class Component extends Object {
|
|||
'base' => $controller->base
|
||||
);
|
||||
|
||||
if (!in_array('Session', $controller->components)) {
|
||||
array_unshift($controller->components, 'Session');
|
||||
}
|
||||
$this->_loadComponents($controller);
|
||||
}
|
||||
/**
|
||||
|
@ -179,40 +176,28 @@ class Component extends Object {
|
|||
* @access protected
|
||||
*/
|
||||
function _loadComponents(&$object, $parent = null) {
|
||||
$components = $object->components;
|
||||
$base = $this->__controllerVars['base'];
|
||||
$normal = Set::normalize($object->components);
|
||||
if ($parent == null) {
|
||||
$normal = Set::merge(array('Session' => null), $normal);
|
||||
}
|
||||
foreach ((array)$normal as $component => $config) {
|
||||
$plugin = null;
|
||||
|
||||
if (is_array($object->components)) {
|
||||
$normal = Set::normalize($object->components);
|
||||
foreach ($normal as $component => $config) {
|
||||
$plugin = null;
|
||||
if (isset($this->__controllerVars['plugin'])) {
|
||||
$plugin = $this->__controllerVars['plugin'] . '.';
|
||||
}
|
||||
|
||||
if (isset($this->__controllerVars['plugin'])) {
|
||||
$plugin = $this->__controllerVars['plugin'] . '.';
|
||||
}
|
||||
if (strpos($component, '.') !== false) {
|
||||
list($plugin, $component) = explode('.', $component);
|
||||
$plugin = $plugin . '.';
|
||||
}
|
||||
$componentCn = $component . 'Component';
|
||||
|
||||
if (strpos($component, '.') !== false) {
|
||||
list($plugin, $component) = explode('.', $component);
|
||||
$plugin = $plugin . '.';
|
||||
}
|
||||
$componentCn = $component . 'Component';
|
||||
|
||||
if (!class_exists($componentCn)) {
|
||||
if (is_null($plugin) || !App::import('Component', $plugin . $component)) {
|
||||
if (!App::import('Component', $component)) {
|
||||
$this->cakeError('missingComponentFile', array(array(
|
||||
'className' => $this->__controllerVars['name'],
|
||||
'component' => $component,
|
||||
'file' => Inflector::underscore($component) . '.php',
|
||||
'base' => $base,
|
||||
'code' => 500
|
||||
)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists($componentCn)) {
|
||||
$this->cakeError('missingComponentClass', array(array(
|
||||
if (!class_exists($componentCn)) {
|
||||
if (is_null($plugin) || !App::import('Component', $plugin . $component)) {
|
||||
if (!App::import('Component', $component)) {
|
||||
$this->cakeError('missingComponentFile', array(array(
|
||||
'className' => $this->__controllerVars['name'],
|
||||
'component' => $component,
|
||||
'file' => Inflector::underscore($component) . '.php',
|
||||
|
@ -223,34 +208,45 @@ class Component extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if ($parent === null) {
|
||||
$this->_primary[] = $component;
|
||||
if (!class_exists($componentCn)) {
|
||||
$this->cakeError('missingComponentClass', array(array(
|
||||
'className' => $this->__controllerVars['name'],
|
||||
'component' => $component,
|
||||
'file' => Inflector::underscore($component) . '.php',
|
||||
'base' => $base,
|
||||
'code' => 500
|
||||
)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->_loaded[$component])) {
|
||||
$object->{$component} =& $this->_loaded[$component];
|
||||
if ($parent === null) {
|
||||
$this->_primary[] = $component;
|
||||
}
|
||||
|
||||
if (!empty($config) && isset($this->__settings[$component])) {
|
||||
$this->__settings[$component] = array_merge($this->__settings[$component], $config);
|
||||
} elseif (!empty($config)) {
|
||||
$this->__settings[$component] = $config;
|
||||
}
|
||||
if (isset($this->_loaded[$component])) {
|
||||
$object->{$component} =& $this->_loaded[$component];
|
||||
|
||||
if (!empty($config) && isset($this->__settings[$component])) {
|
||||
$this->__settings[$component] = array_merge($this->__settings[$component], $config);
|
||||
} elseif (!empty($config)) {
|
||||
$this->__settings[$component] = $config;
|
||||
}
|
||||
} else {
|
||||
if ($componentCn === 'SessionComponent') {
|
||||
$object->{$component} =& new $componentCn($base);
|
||||
} else {
|
||||
if ($componentCn === 'SessionComponent') {
|
||||
$object->{$component} =& new $componentCn($base);
|
||||
} else {
|
||||
$object->{$component} =& new $componentCn();
|
||||
}
|
||||
$object->{$component}->enabled = true;
|
||||
$this->_loaded[$component] =& $object->{$component};
|
||||
if (!empty($config)) {
|
||||
$this->__settings[$component] = $config;
|
||||
}
|
||||
$object->{$component} =& new $componentCn();
|
||||
}
|
||||
$object->{$component}->enabled = true;
|
||||
$this->_loaded[$component] =& $object->{$component};
|
||||
if (!empty($config)) {
|
||||
$this->__settings[$component] = $config;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($object->{$component}->components) && is_array($object->{$component}->components) && (!isset($object->{$component}->{$parent}))) {
|
||||
$this->_loadComponents($object->{$component}, $component);
|
||||
}
|
||||
if (isset($object->{$component}->components) && is_array($object->{$component}->components) && (!isset($object->{$component}->{$parent}))) {
|
||||
$this->_loadComponents($object->{$component}, $component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -368,7 +368,7 @@ class RequestHandlerComponent extends Object {
|
|||
*
|
||||
* @param string $name The name of the Content-type, i.e. "html", "xml", "css"
|
||||
* @param mixed $type The Content-type or array of Content-types assigned to the name,
|
||||
* i.e. "text/html", or "application/xml"
|
||||
* i.e. "text/html", or "application/xml"
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
|
@ -427,11 +427,11 @@ class RequestHandlerComponent extends Object {
|
|||
* header.
|
||||
*
|
||||
* @param mixed $type Can be null (or no parameter), a string type name, or an
|
||||
* array of types
|
||||
* array of types
|
||||
* @return mixed If null or no parameter is passed, returns an array of content
|
||||
* types the client accepts. If a string is passed, returns true
|
||||
* if the client accepts it. If an array is passed, returns true
|
||||
* if the client accepts one or more elements in the array.
|
||||
* types the client accepts. If a string is passed, returns true
|
||||
* if the client accepts it. If an array is passed, returns true
|
||||
* if the client accepts one or more elements in the array.
|
||||
* @access public
|
||||
* @see RequestHandlerComponent::setContent()
|
||||
*/
|
||||
|
@ -504,9 +504,9 @@ class RequestHandlerComponent extends Object {
|
|||
* HTTP_ACCEPT.
|
||||
*
|
||||
* @param mixed $type An optional array of 'friendly' content-type names, i.e.
|
||||
* 'html', 'xml', 'js', etc.
|
||||
* 'html', 'xml', 'js', etc.
|
||||
* @return mixed If $type is null or not provided, the first content-type in the
|
||||
* list, based on preference, is returned.
|
||||
* list, based on preference, is returned.
|
||||
* @access public
|
||||
* @see RequestHandlerComponent::setContent()
|
||||
*/
|
||||
|
@ -607,13 +607,13 @@ class RequestHandlerComponent extends Object {
|
|||
* is not set.
|
||||
*
|
||||
* @param mixed $type Friendly type name, i.e. 'html' or 'xml', or a full content-type,
|
||||
* like 'application/x-shockwave'.
|
||||
* like 'application/x-shockwave'.
|
||||
* @param array $options If $type is a friendly type name that is associated with
|
||||
* more than one type of content, $index is used to select
|
||||
* which content-type to use.
|
||||
* more than one type of content, $index is used to select which content-type to use.
|
||||
*
|
||||
* @return boolean Returns false if the friendly type name given in $type does
|
||||
* not exist in the type map, or if the Content-type header has
|
||||
* already been set by this method.
|
||||
* not exist in the type map, or if the Content-type header has
|
||||
* already been set by this method.
|
||||
* @access public
|
||||
* @see RequestHandlerComponent::setContent()
|
||||
*/
|
||||
|
@ -672,7 +672,7 @@ class RequestHandlerComponent extends Object {
|
|||
* Returns the current response type (Content-type header), or null if none has been set
|
||||
*
|
||||
* @return mixed A string content type alias, or raw content type if no alias map exists,
|
||||
* otherwise null
|
||||
* otherwise null
|
||||
* @access public
|
||||
*/
|
||||
function responseType() {
|
||||
|
|
|
@ -363,7 +363,7 @@ class Controller extends Object {
|
|||
}
|
||||
|
||||
foreach ($merge as $var) {
|
||||
if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
|
||||
if (!empty($appVars[$var]) && is_array($this->{$var})) {
|
||||
if ($var === 'components') {
|
||||
$normal = Set::normalize($this->{$var});
|
||||
$app = Set::normalize($appVars[$var]);
|
||||
|
@ -375,7 +375,7 @@ class Controller extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if ($pluginController) {
|
||||
if ($pluginController && $pluginName != null) {
|
||||
$appVars = get_class_vars($pluginController);
|
||||
$uses = $appVars['uses'];
|
||||
$merge = array('components', 'helpers');
|
||||
|
@ -819,7 +819,7 @@ class Controller extends Object {
|
|||
* Does not work if the current debug level is higher than 0.
|
||||
*
|
||||
* @param string $message Message to display to the user
|
||||
* @param string $url Relative URL to redirect to after the time expires
|
||||
* @param mixed $url Relative string or array-based URL to redirect to after the time expires
|
||||
* @param integer $pause Time to show the message
|
||||
* @return void Renders flash layout
|
||||
* @access public
|
||||
|
@ -1013,7 +1013,8 @@ class Controller extends Object {
|
|||
$type = 'all';
|
||||
|
||||
if (isset($defaults[0])) {
|
||||
$type = array_shift($defaults);
|
||||
$type = $defaults[0];
|
||||
unset($defaults[0]);
|
||||
}
|
||||
$extra = array_diff_key($defaults, compact(
|
||||
'conditions', 'fields', 'order', 'limit', 'page', 'recursive'
|
||||
|
@ -1038,6 +1039,7 @@ class Controller extends Object {
|
|||
} elseif (intval($page) < 1) {
|
||||
$options['page'] = $page = 1;
|
||||
}
|
||||
$page = $options['page'] = (integer)$page;
|
||||
|
||||
if (method_exists($object, 'paginate')) {
|
||||
$results = $object->paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra);
|
||||
|
@ -1136,4 +1138,4 @@ class Controller extends Object {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -151,7 +151,7 @@ class ErrorHandler extends Object {
|
|||
$this->controller->set(array(
|
||||
'code' => '404',
|
||||
'name' => __('Not Found', true),
|
||||
'message' => $url,
|
||||
'message' => h($url),
|
||||
'base' => $this->controller->base
|
||||
));
|
||||
$this->_outputMessage('error404');
|
||||
|
|
|
@ -526,6 +526,10 @@ class Folder extends Object {
|
|||
if (is_dir($path) === true) {
|
||||
$normalFiles = glob($path . '*');
|
||||
$hiddenFiles = glob($path . '\.?*');
|
||||
|
||||
$normalFiles = $normalFiles ? $normalFiles : array();
|
||||
$hiddenFiles = $hiddenFiles ? $hiddenFiles : array();
|
||||
|
||||
$files = array_merge($normalFiles, $hiddenFiles);
|
||||
if (is_array($files)) {
|
||||
foreach ($files as $file) {
|
||||
|
|
|
@ -66,7 +66,7 @@ class HttpSocket extends CakeSocket {
|
|||
'fragment' => null
|
||||
),
|
||||
'auth' => array(
|
||||
'method' => 'basic',
|
||||
'method' => 'Basic',
|
||||
'user' => null,
|
||||
'pass' => null
|
||||
),
|
||||
|
@ -121,7 +121,7 @@ class HttpSocket extends CakeSocket {
|
|||
'port' => 80
|
||||
),
|
||||
'auth' => array(
|
||||
'method' => 'basic',
|
||||
'method' => 'Basic',
|
||||
'user' => null,
|
||||
'pass' => null
|
||||
),
|
||||
|
|
|
@ -213,31 +213,31 @@ class I18n extends Object {
|
|||
if (strpos($header, "plurals=3")) {
|
||||
if (strpos($header, "100!=11")) {
|
||||
if (strpos($header, "10<=4")) {
|
||||
return $n % 10 === 1 && $n % 100 !== 11 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
return $n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
} elseif (strpos($header, "100<10")) {
|
||||
return $n % 10 === 1 && $n % 100 !== 11 ? 0 : ($n % 10 >= 2 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
return $n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
}
|
||||
return $n % 10 == 1 && $n % 100 != 11 ? 0 : ($n != 0 ? 1 : 2);
|
||||
} elseif (strpos($header, "n==2")) {
|
||||
return $n === 1 ? 0 : ($n === 2 ? 1 : 2);
|
||||
return $n == 1 ? 0 : ($n == 2 ? 1 : 2);
|
||||
} elseif (strpos($header, "n==0")) {
|
||||
return $n === 1 ? 0 : ($n === 0 || ($n % 100 > 0 && $n % 100 < 20) ? 1 : 2);
|
||||
return $n == 1 ? 0 : ($n == 0 || ($n % 100 > 0 && $n % 100 < 20) ? 1 : 2);
|
||||
} elseif (strpos($header, "n>=2")) {
|
||||
return $n === 1 ? 0 : ($n >= 2 && $n <= 4 ? 1 : 2);
|
||||
return $n == 1 ? 0 : ($n >= 2 && $n <= 4 ? 1 : 2);
|
||||
} elseif (strpos($header, "10>=2")) {
|
||||
return $n === 1 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
return $n == 1 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
}
|
||||
return $n % 10 === 1 ? 0 : ($n % 10 === 2 ? 1 : 2);
|
||||
return $n % 10 == 1 ? 0 : ($n % 10 == 2 ? 1 : 2);
|
||||
} elseif (strpos($header, "plurals=4")) {
|
||||
if (strpos($header, "100==2")) {
|
||||
return $n % 100 === 1 ? 0 : ($n % 100 === 2 ? 1 : ($n % 100 === 3 || $n % 100 === 4 ? 2 : 3));
|
||||
return $n % 100 == 1 ? 0 : ($n % 100 == 2 ? 1 : ($n % 100 == 3 || $n % 100 == 4 ? 2 : 3));
|
||||
} elseif (strpos($header, "n>=3")) {
|
||||
return $n === 1 ? 0 : ($n === 2 ? 1 : ($n == 0 || ($n >= 3 && $n <= 10) ? 2 : 3));
|
||||
return $n == 1 ? 0 : ($n == 2 ? 1 : ($n == 0 || ($n >= 3 && $n <= 10) ? 2 : 3));
|
||||
} elseif (strpos($header, "100>=1")) {
|
||||
return $n === 1 ? 0 : ($n == 0 || ($n % 100 >= 1 && $n % 100 <= 10) ? 1 : ($n % 100 >= 11 && $n % 100 <= 20 ? 2 : 3));
|
||||
return $n == 1 ? 0 : ($n == 0 || ($n % 100 >= 1 && $n % 100 <= 10) ? 1 : ($n % 100 >= 11 && $n % 100 <= 20 ? 2 : 3));
|
||||
}
|
||||
} elseif (strpos($header, "plurals=5")) {
|
||||
return $n === 1 ? 0 : ($n === 2 ? 1 : ($n >= 3 && $n <= 6 ? 2 : ($n >= 7 && $n <= 10 ? 3 : 4)));
|
||||
return $n == 1 ? 0 : ($n == 2 ? 1 : ($n >= 3 && $n <= 6 ? 2 : ($n >= 7 && $n <= 10 ? 3 : 4)));
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -167,7 +167,7 @@ class Inflector extends Object {
|
|||
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i',
|
||||
'/us$/' => 'uses',
|
||||
'/(alias)$/i' => '\1es',
|
||||
'/(ax|cri|test)is$/i' => '\1es',
|
||||
'/(ax|cris|test)is$/i' => '\1es',
|
||||
'/s$/' => 's',
|
||||
'/^$/' => '',
|
||||
'/$/' => 's');
|
||||
|
@ -282,6 +282,7 @@ class Inflector extends Object {
|
|||
'/^(ox)en/i' => '\1',
|
||||
'/(alias)(es)*$/i' => '\1',
|
||||
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
|
||||
'/([ftw]ax)es/' => '\1',
|
||||
'/(cris|ax|test)es$/i' => '\1is',
|
||||
'/(shoe)s$/i' => '\1',
|
||||
'/(o)es$/i' => '\1',
|
||||
|
|
|
@ -381,7 +381,6 @@ class L10n extends Object {
|
|||
if (Configure::read('Config.language') === null) {
|
||||
Configure::write('Config.language', $this->lang);
|
||||
}
|
||||
Configure::write('charset', $this->charset);
|
||||
|
||||
if ($language) {
|
||||
return $language;
|
||||
|
|
|
@ -273,13 +273,22 @@ class BehaviorCollection extends Object {
|
|||
}
|
||||
|
||||
if (!isset($this->{$name})) {
|
||||
if (PHP5) {
|
||||
$this->{$name} = new $class;
|
||||
if (ClassRegistry::isKeySet($class)) {
|
||||
if (PHP5) {
|
||||
$this->{$name} = ClassRegistry::getObject($class);
|
||||
} else {
|
||||
$this->{$name} =& ClassRegistry::getObject($class);
|
||||
}
|
||||
} else {
|
||||
$this->{$name} =& new $class;
|
||||
if (PHP5) {
|
||||
$this->{$name} = new $class;
|
||||
} else {
|
||||
$this->{$name} =& new $class;
|
||||
}
|
||||
ClassRegistry::addObject($class, $this->{$name});
|
||||
}
|
||||
} elseif (isset($this->{$name}->settings) && isset($this->{$name}->settings[$this->modelName])) {
|
||||
if (!empty($config)) {
|
||||
if ($config !== null && $config !== false) {
|
||||
$config = array_merge($this->{$name}->settings[$this->modelName], $config);
|
||||
} else {
|
||||
$config = array();
|
||||
|
@ -295,11 +304,18 @@ class BehaviorCollection extends Object {
|
|||
}
|
||||
$methods = get_class_methods($this->{$name});
|
||||
$parentMethods = array_flip(get_class_methods('ModelBehavior'));
|
||||
$callbacks = array('setup' => true, 'cleanup' => true, 'beforeFind' => true, 'afterFind' => true, 'beforeSave' => true, 'afterSave' => true, 'beforeDelete' => true, 'afterDelete' => true, 'afterError' => true);
|
||||
$callbacks = array(
|
||||
'setup', 'cleanup', 'beforeFind', 'afterFind', 'beforeSave', 'afterSave',
|
||||
'beforeDelete', 'afterDelete', 'afterError'
|
||||
);
|
||||
|
||||
foreach ($methods as $m) {
|
||||
if (!isset($parentMethods[$m])) {
|
||||
if ($m[0] != '_' && !array_key_exists($m, $this->__methods) && !isset($callbacks[$m])) {
|
||||
$methodAllowed = (
|
||||
$m[0] != '_' && !array_key_exists($m, $this->__methods) &&
|
||||
!in_array($m, $callbacks)
|
||||
);
|
||||
if ($methodAllowed) {
|
||||
$this->__methods[$m] = array($m, $name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,6 +370,8 @@ class TranslateBehavior extends ModelBehavior {
|
|||
}
|
||||
if (!empty($model->translateTable) && $model->translateTable !== $this->runtime[$model->alias]['model']->useTable) {
|
||||
$this->runtime[$model->alias]['model']->setSource($model->translateTable);
|
||||
} elseif (empty($model->translateTable) && empty($model->translateModel)) {
|
||||
$this->runtime[$model->alias]['model']->setSource('i18n');
|
||||
}
|
||||
return $this->runtime[$model->alias]['model'];
|
||||
}
|
||||
|
|
|
@ -25,10 +25,11 @@
|
|||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
/**
|
||||
* Short description for file
|
||||
*
|
||||
* Long description for file
|
||||
* Tree Behavior.
|
||||
*
|
||||
* Enables a model object to act as a node-based tree. Using Modified Preorder Tree Traversal
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Tree_traversal
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.model.behaviors
|
||||
*/
|
||||
|
@ -52,8 +53,8 @@ class TreeBehavior extends ModelBehavior {
|
|||
/**
|
||||
* Initiate Tree behavior
|
||||
*
|
||||
* @param object $Model
|
||||
* @param array $config
|
||||
* @param object $Model instance of model
|
||||
* @param array $config array of configuration settings.
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
|
@ -77,7 +78,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* Overriden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
|
||||
* parameters to be saved.
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance.
|
||||
* @param boolean $created indicates whether the node just saved was created or updated
|
||||
* @return boolean true on success, false on failure
|
||||
* @access public
|
||||
|
@ -98,7 +99,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
*
|
||||
* Will delete the current node and all children using the deleteAll method and sync the table
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @return boolean true to continue, false to abort the delete
|
||||
* @access public
|
||||
*/
|
||||
|
@ -130,7 +131,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* this method bypassing the setParent logic.
|
||||
*
|
||||
* @since 1.2
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @return boolean true to continue, false to abort the save
|
||||
* @access public
|
||||
*/
|
||||
|
@ -201,7 +202,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* If the direct parameter is set to true, only the direct children are counted (based upon the parent_id field)
|
||||
* If false is passed for the id parameter, all top level nodes are counted, or all nodes are counted.
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @param mixed $id The ID of the record to read or false to read all top level nodes
|
||||
* @param boolean $direct whether to count direct, or all, children
|
||||
* @return integer number of child nodes
|
||||
|
@ -241,7 +242,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* If the direct parameter is set to true, only the direct children are returned (based upon the parent_id field)
|
||||
* If false is passed for the id parameter, top level, or all (depending on direct parameter appropriate) are counted.
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @param mixed $id The ID of the record to read
|
||||
* @param boolean $direct whether to return only the direct, or all, children
|
||||
* @param mixed $fields Either a single string of a field name, or an array of field names
|
||||
|
@ -299,7 +300,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
/**
|
||||
* A convenience method for returning a hierarchical array used for HTML select boxes
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @param mixed $conditions SQL conditions as a string or as an array('field' =>'value',...)
|
||||
* @param string $keyPath A string path to the key, i.e. "{n}.Post.id"
|
||||
* @param string $valuePath A string path to the value, i.e. "{n}.Post.title"
|
||||
|
@ -356,7 +357,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
*
|
||||
* reads the parent id and returns this node
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @param mixed $id The ID of the record to read
|
||||
* @param integer $recursive The number of levels deep to fetch associated records
|
||||
* @return array Array of data for the parent node
|
||||
|
@ -387,7 +388,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
/**
|
||||
* Get the path to the given node
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @param mixed $id The ID of the record to read
|
||||
* @param mixed $fields Either a single string of a field name, or an array of field names
|
||||
* @param integer $recursive The number of levels deep to fetch associated records
|
||||
|
@ -424,7 +425,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
*
|
||||
* If the node is the last child, or is a top level node with no subsequent node this method will return false
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @param mixed $id The ID of the record to move
|
||||
* @param mixed $number how many places to move the node or true to move to last position
|
||||
* @return boolean true on success, false on failure
|
||||
|
@ -481,7 +482,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
*
|
||||
* If the node is the first child, or is a top level node with no previous node this method will return false
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @param mixed $id The ID of the record to move
|
||||
* @param mixed $number how many places to move the node, or true to move to first position
|
||||
* @return boolean true on success, false on failure
|
||||
|
@ -543,7 +544,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* parameter only applies to "parent" mode and determines what to do if the parent field contains an id that is not present.
|
||||
*
|
||||
* @todo Could be written to be faster, *maybe*. Ideally using a subquery and putting all the logic burden on the DB.
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @param string $mode parent or tree
|
||||
* @param mixed $missingParentAction 'return' to do nothing and return, 'delete' to
|
||||
* delete, or the id of the parent to set as the parent_id
|
||||
|
@ -615,9 +616,16 @@ class TreeBehavior extends ModelBehavior {
|
|||
* This method does not change the parent of any node.
|
||||
*
|
||||
* Requires a valid tree, by default it verifies the tree before beginning.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - 'id' id of record to use as top node for reordering
|
||||
* - 'field' Which field to use in reordeing defaults to displayField
|
||||
* - 'order' Direction to order either DESC or ASC (defaults to ASC)
|
||||
* - 'verify' Whether or not to verify the tree before reorder. defaults to true.
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param array $options
|
||||
* @param AppModel $Model Model instance
|
||||
* @param array $options array of options to use in reordering.
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
function reorder(&$Model, $options = array()) {
|
||||
|
@ -649,7 +657,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* If the parameter delete is false, the node will become a new top level node. Otherwise the node will be deleted
|
||||
* after the children are reparented.
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @param mixed $id The ID of the record to remove
|
||||
* @param boolean $delete whether to delete the node after reparenting children (if any)
|
||||
* @return boolean true on success, false on failure
|
||||
|
@ -717,7 +725,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
*
|
||||
* Returns true if the tree is valid otherwise an array of (type, incorrect left/right index, message)
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @return mixed true if the tree is valid or empty, otherwise an array of (error type [index, node],
|
||||
* [incorrect left/right index,node id], message)
|
||||
* @access public
|
||||
|
@ -788,7 +796,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* of recovering a corrupted table, or creating new nodes. Otherwise it should always be false. In reality this
|
||||
* method could be private, since calling save with parent_id set also calls setParent
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param AppModel $Model Model instance
|
||||
* @param mixed $parentId
|
||||
* @return boolean true on success, false on failure
|
||||
* @access protected
|
||||
|
|
|
@ -225,10 +225,10 @@ class DboSource extends DataSource {
|
|||
|
||||
if (strpos(strtolower($args[0]), 'findby') === 0) {
|
||||
$all = false;
|
||||
$field = Inflector::underscore(preg_replace('/findBy/i', '', $args[0]));
|
||||
$field = Inflector::underscore(preg_replace('/^findBy/i', '', $args[0]));
|
||||
} else {
|
||||
$all = true;
|
||||
$field = Inflector::underscore(preg_replace('/findAllBy/i', '', $args[0]));
|
||||
$field = Inflector::underscore(preg_replace('/^findAllBy/i', '', $args[0]));
|
||||
}
|
||||
|
||||
$or = (strpos($field, '_or_') !== false);
|
||||
|
@ -411,12 +411,23 @@ class DboSource extends DataSource {
|
|||
$data[$i] = str_replace($this->startQuote . '(', '(', $data[$i]);
|
||||
$data[$i] = str_replace(')' . $this->startQuote, ')', $data[$i]);
|
||||
|
||||
if (strpos($data[$i], ' AS ')) {
|
||||
$data[$i] = str_replace(' AS ', $this->endQuote . ' AS ' . $this->startQuote, $data[$i]);
|
||||
if (preg_match('/\s+AS\s+/', $data[$i])) {
|
||||
if (preg_match('/\w+\s+AS\s+/', $data[$i])) {
|
||||
$quoted = $this->endQuote . ' AS ' . $this->startQuote;
|
||||
$data[$i] = str_replace(' AS ', $quoted, $data[$i]);
|
||||
} else {
|
||||
$quoted = ' AS ' . $this->startQuote;
|
||||
$data[$i] = str_replace(' AS ', $quoted, $data[$i]) . $this->endQuote;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->endQuote) && $this->endQuote == $this->startQuote) {
|
||||
if (substr_count($data[$i], $this->endQuote) % 2 == 1) {
|
||||
$data[$i] = trim($data[$i], $this->endQuote);
|
||||
if (substr($data[$i], -2) == $this->endQuote . $this->endQuote) {
|
||||
$data[$i] = substr($data[$i], 0, -1);
|
||||
} else {
|
||||
$data[$i] = trim($data[$i], $this->endQuote);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strpos($data[$i], '*')) {
|
||||
|
@ -1680,7 +1691,7 @@ class DboSource extends DataSource {
|
|||
strpos($fields[$i], ' ') !== false ||
|
||||
strpos($fields[$i], '(') !== false
|
||||
);
|
||||
$fields[$i] = $this->name(($prefix ? '' : '') . $alias . '.' . $fields[$i]);
|
||||
$fields[$i] = $this->name(($prefix ? $alias . '.' : '') . $fields[$i]);
|
||||
} else {
|
||||
$value = array();
|
||||
$comma = strpos($fields[$i], ',');
|
||||
|
@ -1893,6 +1904,7 @@ class DboSource extends DataSource {
|
|||
$key = substr($key, 0, $split);
|
||||
}
|
||||
}
|
||||
|
||||
$type = (is_object($model) ? $model->getColumnType($key) : null);
|
||||
$null = ($value === null || (is_array($value) && empty($value)));
|
||||
|
||||
|
@ -1904,9 +1916,10 @@ class DboSource extends DataSource {
|
|||
}
|
||||
$value = $this->value($value, $type);
|
||||
|
||||
$key = (strpos($key, '(') !== false || strpos($key, ')') !== false) ?
|
||||
$this->__quoteFields($key) :
|
||||
$key = $this->name($key);
|
||||
if ($key !== '?') {
|
||||
$isKey = (strpos($key, '(') !== false || strpos($key, ')') !== false);
|
||||
$key = $isKey ? $this->__quoteFields($key) : $this->name($key);
|
||||
}
|
||||
|
||||
if ($bound) {
|
||||
return String::insert($key . ' ' . trim($operator), $value);
|
||||
|
@ -2102,10 +2115,11 @@ class DboSource extends DataSource {
|
|||
function hasAny(&$Model, $sql) {
|
||||
$sql = $this->conditions($sql);
|
||||
$table = $this->fullTableName($Model);
|
||||
$where = $sql ? "WHERE {$sql}" : 'WHERE 1 = 1';
|
||||
$id = $Model->primaryKey;
|
||||
$alias = $this->alias . $this->name($Model->alias);
|
||||
$where = $sql ? "{$sql}" : ' WHERE 1 = 1';
|
||||
$id = $Model->escapeField();
|
||||
|
||||
$out = $this->fetchRow("SELECT COUNT({$id}) {$this->alias}count FROM {$table} {$where}");
|
||||
$out = $this->fetchRow("SELECT COUNT({$id}) {$this->alias}count FROM {$table} {$alias}{$where}");
|
||||
|
||||
if (is_array($out)) {
|
||||
return $out[0]['count'];
|
||||
|
|
|
@ -280,10 +280,11 @@ class Model extends Overloadable {
|
|||
* @access private
|
||||
*/
|
||||
var $__associationKeys = array(
|
||||
'belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'),
|
||||
'hasOne' => array('className', 'foreignKey','conditions', 'fields','order', 'dependent'),
|
||||
'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
|
||||
'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery'));
|
||||
'belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'),
|
||||
'hasOne' => array('className', 'foreignKey','conditions', 'fields','order', 'dependent'),
|
||||
'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
|
||||
'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery')
|
||||
);
|
||||
/**
|
||||
* Holds provided/generated association key names and other data for all associations.
|
||||
*
|
||||
|
@ -1209,9 +1210,8 @@ class Model extends Overloadable {
|
|||
foreach ($this->_schema as $field => $properties) {
|
||||
if ($this->primaryKey === $field) {
|
||||
$fInfo = $this->_schema[$field];
|
||||
$isUUID = (
|
||||
($fInfo['type'] === 'string' && $fInfo['length'] === 36) ||
|
||||
($fInfo['type'] === 'binary' && $fInfo['length'] === 16)
|
||||
$isUUID = ($fInfo['length'] === 36 &&
|
||||
($fInfo['type'] === 'string' || $fInfo['type'] === 'binary')
|
||||
);
|
||||
if (empty($this->data[$this->alias][$this->primaryKey]) && $isUUID) {
|
||||
list($fields[], $values[]) = array($this->primaryKey, String::uuid());
|
||||
|
@ -1278,8 +1278,12 @@ class Model extends Overloadable {
|
|||
'fields' => $this->hasAndBelongsToMany[$assoc]['associationForeignKey']
|
||||
));
|
||||
|
||||
$isUUID = !empty($this->{$join}->primaryKey) && (($this->{$join}->_schema[$this->{$join}->primaryKey]['type'] === 'string' && $this->{$join}->_schema[$this->{$join}->primaryKey]['length'] === 36)
|
||||
|| ($this->{$join}->_schema[$this->{$join}->primaryKey]['type'] === 'binary' && $this->{$join}->_schema[$this->{$join}->primaryKey]['length'] === 16));
|
||||
$isUUID = !empty($this->{$join}->primaryKey) && (
|
||||
$this->{$join}->_schema[$this->{$join}->primaryKey]['length'] === 36 && (
|
||||
$this->{$join}->_schema[$this->{$join}->primaryKey]['type'] === 'string' ||
|
||||
$this->{$join}->_schema[$this->{$join}->primaryKey]['type'] === 'binary'
|
||||
)
|
||||
);
|
||||
|
||||
$newData = $newValues = array();
|
||||
$primaryAdded = false;
|
||||
|
@ -1309,6 +1313,8 @@ class Model extends Overloadable {
|
|||
unset($values);
|
||||
} elseif (isset($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
|
||||
$newData[] = $row;
|
||||
} elseif (isset($row[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
|
||||
$newData[] = $row[$join];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1677,7 +1683,7 @@ class Model extends Overloadable {
|
|||
$this->id = $id;
|
||||
|
||||
if (!empty($this->belongsTo)) {
|
||||
$keys = $this->find('first', array('fields', $this->__collectForeignKeys()));
|
||||
$keys = $this->find('first', array('fields' => $this->__collectForeignKeys()));
|
||||
}
|
||||
|
||||
if ($db->delete($this)) {
|
||||
|
|
|
@ -331,11 +331,11 @@ class CakeSchema extends Object {
|
|||
$type = $value;
|
||||
$value = array('type'=> $type);
|
||||
}
|
||||
$col = "\t\t\t'{$field}' => array('type' => '" . $value['type'] . "', ";
|
||||
$col = "\t\t'{$field}' => array('type' => '" . $value['type'] . "', ";
|
||||
unset($value['type']);
|
||||
$col .= join(', ', $this->__values($value));
|
||||
} else {
|
||||
$col = "\t\t\t'indexes' => array(";
|
||||
$col = "\t\t'indexes' => array(";
|
||||
$props = array();
|
||||
foreach ((array)$value as $key => $index) {
|
||||
$props[] = "'{$key}' => array(".join(', ', $this->__values($index)).")";
|
||||
|
@ -347,7 +347,7 @@ class CakeSchema extends Object {
|
|||
}
|
||||
$out .= join(",\n", $cols);
|
||||
}
|
||||
$out .= "\n\t\t);\n";
|
||||
$out .= "\n\t);\n";
|
||||
}
|
||||
}
|
||||
$out .="}\n";
|
||||
|
@ -355,7 +355,7 @@ class CakeSchema extends Object {
|
|||
|
||||
$File =& new File($path . DS . $file, true);
|
||||
$header = '$Id';
|
||||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $name ." schema generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
|
||||
$content = "<?php \n/* SVN FILE: {$header}$ */\n/* {$name} schema generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
|
||||
$content = $File->prepare($content);
|
||||
if ($File->write($content)) {
|
||||
return $content;
|
||||
|
|
|
@ -215,7 +215,7 @@ class Router extends Object {
|
|||
return $_this->routes;
|
||||
}
|
||||
/**
|
||||
*Specifies what named parameters CakePHP should be parsing. The most common setups are:
|
||||
* Specifies what named parameters CakePHP should be parsing. The most common setups are:
|
||||
*
|
||||
* Do not parse any named parameters:
|
||||
* {{{ Router::connectNamed(false); }}}
|
||||
|
@ -275,13 +275,13 @@ class Router extends Object {
|
|||
}
|
||||
/**
|
||||
* Creates REST resource routes for the given controller(s)
|
||||
*
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
*
|
||||
* - 'id' - The regular expression fragment to use when matching IDs. By default, matches
|
||||
* integer values and UUIDs.
|
||||
* - 'prefix' - URL prefix to use for the generated routes. Defaults to '/'.
|
||||
*
|
||||
*
|
||||
* @param mixed $controller A controller name or array of controller names (i.e. "Posts" or "ListItems")
|
||||
* @param array $options Options to use when generating REST routes
|
||||
* @return void
|
||||
|
@ -735,7 +735,7 @@ class Router extends Object {
|
|||
*
|
||||
* Returns an URL pointing to a combination of controller and action. Param
|
||||
* $url can be:
|
||||
*
|
||||
*
|
||||
* - Empty - the method will find adress to actuall controller/action.
|
||||
* - '/' - the method will find base URL of application.
|
||||
* - A combination of controller/action - the method will find url for it.
|
||||
|
@ -755,13 +755,13 @@ class Router extends Object {
|
|||
function url($url = null, $full = false) {
|
||||
$_this =& Router::getInstance();
|
||||
$defaults = $params = array('plugin' => null, 'controller' => null, 'action' => 'index');
|
||||
|
||||
|
||||
if (is_bool($full)) {
|
||||
$escape = false;
|
||||
} else {
|
||||
extract(array_merge(array('escape' => false, 'full' => false), $full));
|
||||
}
|
||||
|
||||
|
||||
if (!empty($_this->__params)) {
|
||||
if (isset($this) && !isset($this->params['requested'])) {
|
||||
$params = $_this->__params[0];
|
||||
|
@ -846,6 +846,7 @@ class Router extends Object {
|
|||
}
|
||||
$url = $originalUrl;
|
||||
}
|
||||
|
||||
$named = $args = array();
|
||||
$skip = array(
|
||||
'bare', 'action', 'controller', 'plugin', 'ext', '?', '#', 'prefix', $_this->__admin
|
||||
|
@ -900,7 +901,6 @@ class Router extends Object {
|
|||
$output .= '/' . $name . $_this->named['separator'] . $value;
|
||||
}
|
||||
}
|
||||
|
||||
$output = str_replace('//', '/', $base . '/' . $output);
|
||||
} else {
|
||||
if (((strpos($url, '://')) || (strpos($url, 'javascript:') === 0) || (strpos($url, 'mailto:') === 0)) || (!strncmp($url, '#', 1))) {
|
||||
|
@ -1082,6 +1082,8 @@ class Router extends Object {
|
|||
if (isset($params[$key])) {
|
||||
$string = $params[$key];
|
||||
unset($params[$key]);
|
||||
} else {
|
||||
$key = $key . '/';
|
||||
}
|
||||
$out = str_replace(':' . $key, $string, $out);
|
||||
}
|
||||
|
@ -1089,6 +1091,7 @@ class Router extends Object {
|
|||
if (strpos($route[0], '*')) {
|
||||
$out = str_replace('*', $params['pass'], $out);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -369,16 +369,16 @@ class Set extends Object {
|
|||
* @static
|
||||
*/
|
||||
function extract($path, $data = null, $options = array()) {
|
||||
if (empty($data) && is_string($path) && $path{0} === '/') {
|
||||
if (is_string($data)) {
|
||||
$tmp = $data;
|
||||
$data = $path;
|
||||
$path = $tmp;
|
||||
}
|
||||
if (empty($data)) {
|
||||
return array();
|
||||
}
|
||||
if (is_string($data) && $data{0} === '/') {
|
||||
$tmp = $path;
|
||||
$path = $data;
|
||||
$data = $tmp;
|
||||
}
|
||||
if (is_array($path) || empty($data) || is_object($path) || empty($path)) {
|
||||
return Set::classicExtract($path, $data);
|
||||
if (strpos($path, '/') === false) {
|
||||
return Set::classicExtract($data, $path);
|
||||
}
|
||||
if ($path === '/') {
|
||||
return $data;
|
||||
|
@ -388,12 +388,12 @@ class Set extends Object {
|
|||
if (!isset($contexts[0])) {
|
||||
$contexts = array($data);
|
||||
}
|
||||
$tokens = array_slice(preg_split('/(?<!=)\/(?![a-z]*\])/', $path), 1);
|
||||
$tokens = array_slice(preg_split('/(?<!=)\/(?![a-z-]*\])/', $path), 1);
|
||||
|
||||
do {
|
||||
$token = array_shift($tokens);
|
||||
$conditions = false;
|
||||
if (preg_match_all('/\[([^\]]+)\]/', $token, $m)) {
|
||||
if (preg_match_all('/\[([^=]+=\/[^\/]+\/|[^\]]+)\]/', $token, $m)) {
|
||||
$conditions = $m[1];
|
||||
$token = substr($token, 0, strpos($token, '['));
|
||||
}
|
||||
|
@ -411,8 +411,10 @@ class Set extends Object {
|
|||
$context['key'] = array_pop($context['trace']);
|
||||
if (isset($context['trace'][1]) && $context['trace'][1] > 0) {
|
||||
$context['item'] = $context['item'][0];
|
||||
} else {
|
||||
} else if(!empty($context['item'][$key])){
|
||||
$context['item'] = $context['item'][$key];
|
||||
} else {
|
||||
$context['item'] = array_shift($context['item']);
|
||||
}
|
||||
$matches[] = $context;
|
||||
continue;
|
||||
|
@ -449,6 +451,8 @@ class Set extends Object {
|
|||
'item' => $item,
|
||||
);
|
||||
break;
|
||||
} else {
|
||||
array_unshift($tokens, $token);
|
||||
}
|
||||
} else {
|
||||
$key = $token;
|
||||
|
@ -1086,7 +1090,7 @@ class Set extends Object {
|
|||
function sort($data, $path, $dir) {
|
||||
$result = Set::__flatten(Set::extract($data, $path));
|
||||
list($keys, $values) = array(Set::extract($result, '{n}.id'), Set::extract($result, '{n}.value'));
|
||||
|
||||
|
||||
$dir = strtolower($dir);
|
||||
if ($dir === 'asc') {
|
||||
$dir = SORT_ASC;
|
||||
|
|
|
@ -211,10 +211,10 @@ class String extends Object {
|
|||
* @static
|
||||
*/
|
||||
function insert($str, $data, $options = array()) {
|
||||
$options = array_merge(
|
||||
array('before' => ':', 'after' => null, 'escape' => '\\', 'format' => null, 'clean' => false),
|
||||
$options
|
||||
$defaults = array(
|
||||
'before' => ':', 'after' => null, 'escape' => '\\', 'format' => null, 'clean' => false
|
||||
);
|
||||
$options += $defaults;
|
||||
$format = $options['format'];
|
||||
|
||||
if (!isset($format)) {
|
||||
|
@ -231,7 +231,7 @@ class String extends Object {
|
|||
|
||||
if (array_keys($data) === array_keys(array_values($data))) {
|
||||
$offset = 0;
|
||||
while ($pos = strpos($str, '?', $offset)) {
|
||||
while (($pos = strpos($str, '?', $offset)) !== false) {
|
||||
$val = array_shift($data);
|
||||
$offset = $pos + strlen($val);
|
||||
$str = substr_replace($str, $val, $pos, 1);
|
||||
|
|
|
@ -175,7 +175,7 @@ class Helper extends Overloadable {
|
|||
* @return string Full translated URL with base path.
|
||||
*/
|
||||
function url($url = null, $full = false) {
|
||||
return Router::url($url, array('full' => $full, 'escape' => true));
|
||||
return h(Router::url($url, $full));
|
||||
}
|
||||
/**
|
||||
* Checks if a file exists when theme is used, if no file is found default location is returned
|
||||
|
|
|
@ -72,18 +72,18 @@ class FormHelper extends AppHelper {
|
|||
var $requestType = null;
|
||||
/**
|
||||
* Returns an HTML FORM element.
|
||||
*
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
*
|
||||
* - 'type' Form method defaults to POST
|
||||
* - 'action' The Action the form submits to. Can be a string or array,
|
||||
* - 'url' The url the form submits to. Can be a string or a url array,
|
||||
* - 'default' Allows for the creation of Ajax forms.
|
||||
* - 'onsubmit' Used in conjunction with 'default' to create ajax forms.
|
||||
*
|
||||
* - 'onsubmit' Used in conjunction with 'default' to create ajax forms.
|
||||
*
|
||||
* @access public
|
||||
* @param string $model The model object which the form is being defined for
|
||||
* @param array $options
|
||||
* @param array $options An array of html attributes and options.
|
||||
* @return string An formatted opening FORM tag.
|
||||
*/
|
||||
function create($model = null, $options = array()) {
|
||||
|
@ -378,11 +378,12 @@ class FormHelper extends AppHelper {
|
|||
* Returns a formatted error message for given FORM field, NULL if no errors.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
*
|
||||
* - 'escape' bool Whether or not to html escape the contents of the error.
|
||||
* - 'wrap' mixed Whether or not the error message should be wrapped in a div. If a
|
||||
* string, will be used as the HTML tag to use.
|
||||
* - 'class' string The classname for the error message
|
||||
*
|
||||
* @param string $field A field name, like "Modelname.fieldname"
|
||||
* @param mixed $text Error message or array of $options
|
||||
* @param array $options Rendering options for <div /> wrapper tag
|
||||
|
@ -561,18 +562,18 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
/**
|
||||
* Generates a form input element complete with label and wrapper div
|
||||
*
|
||||
*
|
||||
* Options - See each field type method for more information.
|
||||
*
|
||||
*
|
||||
* - 'type' - Force the type of widget you want. e.g. ```type => 'select'```
|
||||
* - 'label' - control the label
|
||||
* - 'div' - control the wrapping div element
|
||||
* - 'options' - for widgets that take options e.g. radio, select
|
||||
* - 'error' - control the error message that is produced
|
||||
*
|
||||
*
|
||||
* @param string $fieldName This should be "Modelname.fieldname"
|
||||
* @param array $options - Each type of input takes different options.
|
||||
* @return string Completed form widget
|
||||
* @param array $options Each type of input takes different options.
|
||||
* @return string Completed form widget
|
||||
*/
|
||||
function input($fieldName, $options = array()) {
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
|
@ -831,10 +832,13 @@ class FormHelper extends AppHelper {
|
|||
/**
|
||||
* Creates a checkbox input widget.
|
||||
*
|
||||
* @param string $fieldName Name of a field, like this "Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* Options:
|
||||
*
|
||||
* - 'value' - the value of the checkbox
|
||||
* - checked' - boolean indicate that this checkbox is checked.
|
||||
*
|
||||
* @param string $fieldName Name of a field, like this "Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @todo Right now, automatically setting the 'checked' value is dependent on whether or not the
|
||||
* checkbox is bound to a model. This should probably be re-evaluated in future versions.
|
||||
* @return string An HTML text input element
|
||||
|
@ -864,15 +868,15 @@ class FormHelper extends AppHelper {
|
|||
* Creates a set of radio widgets.
|
||||
*
|
||||
* Attributes:
|
||||
*
|
||||
*
|
||||
* - 'separator' - define the string in between the radio buttons
|
||||
* - 'legend' - control whether or not the widget set has a fieldset & legend
|
||||
* - 'value' - indicate a value that is should be checked
|
||||
* - 'label' - boolean to indicate whether or not labels for widgets show be displayed
|
||||
*
|
||||
* @param string $fieldName Name of a field, like this "Modelname.fieldname"
|
||||
* @param array $options Radio button options array.
|
||||
* @param array $attributes Array of HTML attributes.
|
||||
*
|
||||
* @param string $fieldName Name of a field, like this "Modelname.fieldname"
|
||||
* @param array $options Radio button options array.
|
||||
* @param array $attributes Array of HTML attributes.
|
||||
* @return string
|
||||
*/
|
||||
function radio($fieldName, $options = array(), $attributes = array()) {
|
||||
|
@ -947,7 +951,7 @@ class FormHelper extends AppHelper {
|
|||
/**
|
||||
* Creates a text input widget.
|
||||
*
|
||||
* @param string $fieldNamem Name of a field, in the form "Modelname.fieldname"
|
||||
* @param string $fieldName Name of a field, in the form "Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string An HTML text input element
|
||||
*/
|
||||
|
@ -979,7 +983,7 @@ class FormHelper extends AppHelper {
|
|||
/**
|
||||
* Creates a textarea widget.
|
||||
*
|
||||
* @param string $fieldNamem Name of a field, in the form "Modelname.fieldname"
|
||||
* @param string $fieldName Name of a field, in the form "Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string An HTML text input element
|
||||
*/
|
||||
|
@ -1004,8 +1008,8 @@ class FormHelper extends AppHelper {
|
|||
/**
|
||||
* Creates a hidden input field.
|
||||
*
|
||||
* @param string $fieldName Name of a field, in the form"Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @param string $fieldName Name of a field, in the form"Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
|
@ -1055,8 +1059,8 @@ class FormHelper extends AppHelper {
|
|||
/**
|
||||
* Creates a button tag.
|
||||
*
|
||||
* @param string $title The button's caption
|
||||
* @param array $options Array of options.
|
||||
* @param string $title The button's caption
|
||||
* @param array $options Array of options.
|
||||
* @return string A HTML button tag.
|
||||
* @access public
|
||||
*/
|
||||
|
@ -1147,12 +1151,12 @@ class FormHelper extends AppHelper {
|
|||
* Returns a formatted SELECT element.
|
||||
*
|
||||
* Attributes:
|
||||
*
|
||||
*
|
||||
* - 'showParents' - If included in the array and set to true, an additional option element
|
||||
* will be added for the parent of each option group.
|
||||
* - 'multiple' - show a multiple select box. If set to 'checkbox' multiple checkboxes will be
|
||||
* created instead.
|
||||
*
|
||||
*
|
||||
* @param string $fieldName Name attribute of the SELECT
|
||||
* @param array $options Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the
|
||||
* SELECT element
|
||||
|
@ -1315,7 +1319,7 @@ class FormHelper extends AppHelper {
|
|||
* Returns a SELECT element for months.
|
||||
*
|
||||
* Attributes:
|
||||
*
|
||||
*
|
||||
* - 'monthNames' is set and false 2 digit numbers will be used instead of text.
|
||||
*
|
||||
* @param string $fieldName Prefix name for the SELECT element
|
||||
|
@ -1477,12 +1481,13 @@ class FormHelper extends AppHelper {
|
|||
* Returns a set of SELECT elements for a full datetime setup: day, month and year, and then time.
|
||||
*
|
||||
* Attributes:
|
||||
*
|
||||
*
|
||||
* - 'monthNames' If set and false numbers will be used for month select instead of text.
|
||||
* - 'minYear' The lowest year to use in the year select
|
||||
* - 'maxYear' The maximum year to use in the year select
|
||||
* - 'interval' The interval for the minutes select. Defaults to 1
|
||||
* - 'separator' The contents of the string between select elements. Defaults to '-'
|
||||
*
|
||||
* @param string $fieldName Prefix name for the SELECT element
|
||||
* @param string $dateFormat DMY, MDY, YMD or NONE.
|
||||
* @param string $timeFormat 12, 24, NONE
|
||||
|
@ -1847,7 +1852,10 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
/**
|
||||
* Sets field defaults and adds field to form security input hash
|
||||
*
|
||||
*
|
||||
* Options
|
||||
* - secure - boolean whether or not the the field should be added to the security fields.
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $options
|
||||
* @return array
|
||||
|
|
|
@ -195,7 +195,7 @@ class HtmlHelper extends AppHelper {
|
|||
/**
|
||||
* Creates a link to an external resource and handles basic meta tags
|
||||
*
|
||||
* @param string $title The title of the external resource
|
||||
* @param string $type The title of the external resource
|
||||
* @param mixed $url The address of the external resource or string for content attribute
|
||||
* @param array $attributes Other attributes for the generated tag. If the type attribute is html, rss, atom, or icon, the mime-type is returned.
|
||||
* @param boolean $inline If set to false, the generated tag appears in the head tag of the layout.
|
||||
|
@ -294,9 +294,8 @@ class HtmlHelper extends AppHelper {
|
|||
$escapeTitle = false;
|
||||
}
|
||||
|
||||
if (isset($htmlAttributes['escape'])) {
|
||||
if (isset($htmlAttributes['escape']) && $escapeTitle == true) {
|
||||
$escapeTitle = $htmlAttributes['escape'];
|
||||
unset($htmlAttributes['escape']);
|
||||
}
|
||||
|
||||
if ($escapeTitle === true) {
|
||||
|
@ -477,7 +476,8 @@ class HtmlHelper extends AppHelper {
|
|||
/**
|
||||
* Builds CSS style data from an array of CSS properties
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data Style data array
|
||||
* @param boolean $inline Whether or not the style block should be displayed inline
|
||||
* @return string CSS styling data
|
||||
* @access public
|
||||
*/
|
||||
|
@ -525,7 +525,7 @@ class HtmlHelper extends AppHelper {
|
|||
* Creates a formatted IMG element.
|
||||
*
|
||||
* @param string $path Path to the image file, relative to the app/webroot/img/ directory.
|
||||
* @param array $htmlAttributes Array of HTML attributes.
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string completed img tag
|
||||
* @access public
|
||||
*/
|
||||
|
@ -535,7 +535,7 @@ class HtmlHelper extends AppHelper {
|
|||
} elseif ($path[0] === '/') {
|
||||
$path = $this->webroot($path);
|
||||
} elseif (strpos($path, '://') === false) {
|
||||
if (Configure::read('Asset.timestamp') == true && Configure::read() > 0) {
|
||||
if ((Configure::read('Asset.timestamp') == true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') {
|
||||
$path .= '?' . @filemtime(str_replace('/', DS, WWW_ROOT . IMAGES_URL . $path));
|
||||
}
|
||||
$path = $this->webroot(IMAGES_URL . $path);
|
||||
|
|
|
@ -152,15 +152,17 @@ class JavascriptHelper extends AppHelper {
|
|||
/**
|
||||
* Returns a JavaScript script tag.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - allowCache: boolean, designates whether this block is cacheable using the
|
||||
* current cache settings.
|
||||
* - safe: boolean, whether this block should be wrapped in CDATA tags. Defaults
|
||||
* to helper's object configuration.
|
||||
* - inline: whether the block should be printed inline, or written
|
||||
* to cached for later output (i.e. $scripts_for_layout).
|
||||
*
|
||||
* @param string $script The JavaScript to be wrapped in SCRIPT tags.
|
||||
* @param array $options Set of options:
|
||||
* - allowCache: boolean, designates whether this block is cacheable using the
|
||||
* current cache settings.
|
||||
* - safe: boolean, whether this block should be wrapped in CDATA tags. Defaults
|
||||
* to helper's object configuration.
|
||||
* - inline: whether the block should be printed inline, or written
|
||||
* to cached for later output (i.e. $scripts_for_layout).
|
||||
*
|
||||
* @return string The full SCRIPT element, with the JavaScript inside it, or null,
|
||||
* if 'inline' is set to false.
|
||||
*/
|
||||
|
@ -241,9 +243,9 @@ class JavascriptHelper extends AppHelper {
|
|||
* the path will be relative to the base path of your application. Otherwise, the path will
|
||||
* be relative to your JavaScript path, usually webroot/js.
|
||||
*
|
||||
* @param mixed $url String URL to JavaScript file, or an array of URLs.
|
||||
* @param boolean $inline If true, the <script /> tag will be printed inline,
|
||||
* otherwise it will be printed in the <head />, using $scripts_for_layout
|
||||
* @param mixed $url String URL to JavaScript file, or an array of URLs.
|
||||
* @param boolean $inline If true, the <script /> tag will be printed inline,
|
||||
* otherwise it will be printed in the <head />, using $scripts_for_layout
|
||||
* @see JS_URL
|
||||
* @return string
|
||||
*/
|
||||
|
@ -523,6 +525,13 @@ class JavascriptHelper extends AppHelper {
|
|||
if ($this->useNative) {
|
||||
$rt = json_encode($data);
|
||||
} else {
|
||||
if (is_null($data)) {
|
||||
return 'null';
|
||||
}
|
||||
if (is_bool($data)) {
|
||||
return $data ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if (is_array($data)) {
|
||||
$keys = array_keys($data);
|
||||
}
|
||||
|
|
|
@ -52,21 +52,17 @@ class NumberHelper extends AppHelper {
|
|||
* @static
|
||||
*/
|
||||
function toReadableSize($size) {
|
||||
switch ($size) {
|
||||
case 0:
|
||||
return '0 Bytes';
|
||||
case 1:
|
||||
return '1 Byte';
|
||||
switch (true) {
|
||||
case $size < 1024:
|
||||
return $size . ' Bytes';
|
||||
return sprintf(__n('%d Byte', '%d Bytes', $size, true), $size);
|
||||
case round($size / 1024) < 1024:
|
||||
return $this->precision($size / 1024, 0) . ' KB';
|
||||
return sprintf(__('%d KB', true), $this->precision($size / 1024, 0));
|
||||
case round($size / 1024 / 1024, 2) < 1024:
|
||||
return $this->precision($size / 1024 / 1024, 2) . ' MB';
|
||||
return sprintf(__('%.2f MB', true), $this->precision($size / 1024 / 1024, 2));
|
||||
case round($size / 1024 / 1024 / 1024, 2) < 1024:
|
||||
return $this->precision($size / 1024 / 1024 / 1024, 2) . ' GB';
|
||||
return sprintf(__('%.2f GB', true), $this->precision($size / 1024 / 1024 / 1024, 2));
|
||||
default:
|
||||
return $this->precision($size / 1024 / 1024 / 1024 / 1024, 2) . ' TB';
|
||||
return sprintf(__('%.2f TB', true), $this->precision($size / 1024 / 1024 / 1024 / 1024, 2));
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -172,6 +168,8 @@ class NumberHelper extends AppHelper {
|
|||
$number = $number * $multiply;
|
||||
$options['before'] = null;
|
||||
$options['places'] = null;
|
||||
} elseif (empty($options['before'])) {
|
||||
$options['before'] = null;
|
||||
} else {
|
||||
$options['after'] = null;
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ class PaginatorHelper extends AppHelper {
|
|||
* Holds the default options for pagination links
|
||||
*
|
||||
* The values that may be specified are:
|
||||
*
|
||||
*
|
||||
* - <i>$options['format']</i> Format of the counter. Supported formats are 'range' and 'pages'
|
||||
* and custom (default). In the default mode the supplied string is parsed and constants are replaced
|
||||
* and custom (default). In the default mode the supplied string is parsed and constants are replaced
|
||||
* by their actual values.
|
||||
* Constants: %page%, %pages%, %current%, %count%, %start%, %end% .
|
||||
* - <i>$options['separator']</i> The separator of the actual page and number of pages (default: ' of ').
|
||||
|
@ -84,7 +84,7 @@ class PaginatorHelper extends AppHelper {
|
|||
/**
|
||||
* Sets default options for all pagination links
|
||||
*
|
||||
* @param mixed $options Default options for pagination links. If a string is supplied - it
|
||||
* @param mixed $options Default options for pagination links. If a string is supplied - it
|
||||
* is used as the DOM id element to update. See #options for list of keys.
|
||||
*/
|
||||
function options($options = array()) {
|
||||
|
@ -144,7 +144,7 @@ class PaginatorHelper extends AppHelper {
|
|||
}
|
||||
return $options['sort'];
|
||||
} elseif (isset($options['order']) && is_array($options['order'])) {
|
||||
return preg_replace('/.*\./', '', key($options['order']));
|
||||
return key($options['order']);
|
||||
} elseif (isset($options['order']) && is_string($options['order'])) {
|
||||
if (preg_match('/(?:\w+\.)?(\w+)/', $options['order'], $result) && isset($result[1])) {
|
||||
return $result[1];
|
||||
|
@ -209,7 +209,7 @@ class PaginatorHelper extends AppHelper {
|
|||
* @param string $title Title for the link.
|
||||
* @param string $key The name of the key that the recordset should be sorted.
|
||||
* @param array $options Options for sorting link. See #options for list of keys.
|
||||
* @return string A link sorting default by 'asc'. If the resultset is sorted 'asc' by the specified
|
||||
* @return string A link sorting default by 'asc'. If the resultset is sorted 'asc' by the specified
|
||||
* key the returned link will sort by 'desc'.
|
||||
*/
|
||||
function sort($title, $key = null, $options = array()) {
|
||||
|
@ -222,19 +222,15 @@ class PaginatorHelper extends AppHelper {
|
|||
$title = __(Inflector::humanize(preg_replace('/_id$/', '', $title)), true);
|
||||
}
|
||||
$dir = 'asc';
|
||||
$model = null;
|
||||
|
||||
if (strpos($key, '.') !== false) {
|
||||
list($model, $key) = explode('.', $key);
|
||||
$model = $model . '.';
|
||||
}
|
||||
if ($this->sortKey($options['model']) == $key && $this->sortDir($options['model']) == 'asc') {
|
||||
$dir = 'desc';
|
||||
}
|
||||
if (is_array($title) && array_key_exists($dir, $title)) {
|
||||
$title = $title[$dir];
|
||||
}
|
||||
$url = array_merge(array('sort' => $model . $key, 'direction' => $dir), $url, array('order' => null));
|
||||
|
||||
$url = array_merge(array('sort' => $key, 'direction' => $dir), $url, array('order' => null));
|
||||
return $this->link($title, $url, $options);
|
||||
}
|
||||
/**
|
||||
|
@ -261,7 +257,8 @@ class PaginatorHelper extends AppHelper {
|
|||
|
||||
$obj = isset($options['update']) ? 'Ajax' : 'Html';
|
||||
$url = array_merge(array('page' => $this->current($model)), $url);
|
||||
return $this->{$obj}->link($title, Set::filter($url, true), $options);
|
||||
$url = array_merge(Set::filter($url, true), array_intersect_key($url, array('plugin'=>true)));
|
||||
return $this->{$obj}->link($title, $url, $options);
|
||||
}
|
||||
/**
|
||||
* Merges passed URL options with current pagination state to generate a pagination URL.
|
||||
|
@ -279,12 +276,6 @@ class PaginatorHelper extends AppHelper {
|
|||
$sort = $direction = null;
|
||||
if (is_array($url['order'])) {
|
||||
list($sort, $direction) = array($this->sortKey($model, $url), current($url['order']));
|
||||
$key = array_keys($url['order']);
|
||||
|
||||
if (strpos($key[0], '.') !== false) {
|
||||
list($model) = explode('.', $key[0]);
|
||||
$sort = $model . '.' . $sort;
|
||||
}
|
||||
}
|
||||
unset($url['order']);
|
||||
$url = array_merge($url, compact('sort', 'direction'));
|
||||
|
@ -643,4 +634,4 @@ class PaginatorHelper extends AppHelper {
|
|||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -287,7 +287,7 @@ class TimeHelper extends AppHelper {
|
|||
* $datetime should be in a <i>strtotime</i> - parsable format, like MySQL's datetime datatype.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
*
|
||||
* - 'format' => a fall back format if the relative time is longer than the duration specified by end
|
||||
* - 'end' => The end of relative time telling
|
||||
* - 'userOffset' => Users offset from GMT (in hours)
|
||||
|
|
|
@ -148,12 +148,16 @@ class XmlHelper extends AppHelper {
|
|||
* Serializes a model resultset into XML
|
||||
*
|
||||
* @param mixed $data The content to be converted to XML
|
||||
* @param array $options The data formatting options
|
||||
* @param array $options The data formatting options. For a list of valid options, see
|
||||
* XmlNode::__construct().
|
||||
* @return string A copy of $data in XML format
|
||||
* @see XmlNode
|
||||
*/
|
||||
function serialize($data, $options = array()) {
|
||||
$data =& new Xml($data, array_merge(array('attributes' => false, 'format' => 'attributes'), $options));
|
||||
return $data->toString(array_merge(array('header' => false), $options));
|
||||
$options += array('attributes' => false, 'format' => 'attributes');
|
||||
$data =& new Xml($data, $options);
|
||||
return $data->toString($options + array('header' => false));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -105,6 +105,11 @@ class MediaView extends View {
|
|||
} else {
|
||||
$path = APP . $path . $id;
|
||||
}
|
||||
|
||||
if (!file_exists($path)) {
|
||||
header('Content-Type: text/html');
|
||||
$this->cakeError('error404');
|
||||
}
|
||||
|
||||
if (is_null($name)) {
|
||||
$name = $id;
|
||||
|
@ -113,8 +118,8 @@ class MediaView extends View {
|
|||
if (is_array($mimeType)) {
|
||||
$this->mimeType = array_merge($this->mimeType, $mimeType);
|
||||
}
|
||||
|
||||
if (file_exists($path) && isset($extension) && isset($this->mimeType[$extension]) && connection_status() == 0) {
|
||||
|
||||
if (isset($extension) && isset($this->mimeType[$extension]) && connection_status() == 0) {
|
||||
$chunkSize = 8192;
|
||||
$buffer = '';
|
||||
$fileSize = @filesize($path);
|
||||
|
@ -130,13 +135,21 @@ class MediaView extends View {
|
|||
}
|
||||
|
||||
if ($download) {
|
||||
$contentType = 'application/octet-stream';
|
||||
$contentTypes = array('application/octet-stream');
|
||||
$agent = env('HTTP_USER_AGENT');
|
||||
|
||||
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent) || preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
|
||||
$contentType = 'application/octetstream';
|
||||
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent)) {
|
||||
$contentTypes[0] = 'application/octetstream';
|
||||
} else if (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
|
||||
$contentTypes[0] = 'application/force-download';
|
||||
array_push($contentTypes, array(
|
||||
'application/octet-stream',
|
||||
'application/download'
|
||||
));
|
||||
}
|
||||
foreach($contentTypes as $contentType) {
|
||||
header('Content-Type: ' . $contentType);
|
||||
}
|
||||
header('Content-Type: ' . $contentType);
|
||||
header('Content-Disposition: attachment; filename="' . $name . '.' . $extension . '";');
|
||||
header('Expires: 0');
|
||||
header('Accept-Ranges: bytes');
|
||||
|
@ -189,4 +202,4 @@ class MediaView extends View {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
if (Configure::read() == 0):
|
||||
$this->cakeError('error404');
|
||||
endif;
|
||||
?>
|
||||
<h2><?php echo sprintf(__('Release Notes for CakePHP %s.', true), Configure::version()); ?></h2>
|
||||
<a href="https://trac.cakephp.org/wiki/changelog/1.2.x.x"><?php __('Read the changelog'); ?> </a>
|
||||
|
|
|
@ -188,7 +188,7 @@ class XmlNode extends Object {
|
|||
return $object;
|
||||
}
|
||||
$name = null;
|
||||
$options = array_merge(array('format' => 'attributes'), $options);
|
||||
$options += array('format' => 'attributes');
|
||||
|
||||
if ($keyName !== null && !is_numeric($keyName)) {
|
||||
$name = $keyName;
|
||||
|
@ -769,8 +769,8 @@ class Xml extends XmlNode {
|
|||
var $__header = null;
|
||||
|
||||
/**
|
||||
* Default array keys/object properties to use as tag names when converting objects or array structures to XML.
|
||||
* Set by passing $options['tags'] to this object's constructor.
|
||||
* Default array keys/object properties to use as tag names when converting objects or array
|
||||
* structures to XML. Set by passing $options['tags'] to this object's constructor.
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
|
@ -797,8 +797,20 @@ class Xml extends XmlNode {
|
|||
* Constructor. Sets up the XML parser with options, gives it this object as
|
||||
* its XML object, and sets some variables.
|
||||
*
|
||||
* @param string $input What should be used to set up
|
||||
* @param array $options Options to set up with
|
||||
* @param mixed $input The content with which this XML document should be initialized. Can be a
|
||||
* string, array or object. If a string is specified, it may be a literal XML
|
||||
* document, or a URL or file path to read from.
|
||||
* @param array $options Options to set up with, valid options are as follows:
|
||||
* - 'root': The name of the root element, defaults to '#document'
|
||||
* - 'version': The XML version, defaults to '1.0'
|
||||
* - 'encoding': Document encoding, defaults to 'UTF-8'
|
||||
* - 'namespaces': An array of namespaces (as strings) used in this document
|
||||
* - 'format': Specifies the format this document converts to when parsed or
|
||||
* rendered out as text, either 'attributes' or 'tags',
|
||||
* defaults to 'attributes'
|
||||
* - 'tags': An array specifying any tag-specific formatting options, indexed
|
||||
* by tag name. See XmlNode::normalize().
|
||||
* @see XmlNode::normalize()
|
||||
*/
|
||||
function __construct($input = null, $options = array()) {
|
||||
$defaults = array(
|
||||
|
@ -820,7 +832,6 @@ class Xml extends XmlNode {
|
|||
$this->append($input, $options);
|
||||
}
|
||||
}
|
||||
|
||||
// if (Configure::read('App.encoding') !== null) {
|
||||
// $this->encoding = Configure::read('App.encoding');
|
||||
// }
|
||||
|
@ -863,7 +874,11 @@ class Xml extends XmlNode {
|
|||
*/
|
||||
function parse() {
|
||||
$this->__initParser();
|
||||
$this->__header = trim(str_replace(a('<' . '?', '?' . '>'), a('', ''), substr(trim($this->__rawData), 0, strpos($this->__rawData, "\n"))));
|
||||
$this->__header = trim(str_replace(
|
||||
a('<' . '?', '?' . '>'),
|
||||
a('', ''),
|
||||
substr(trim($this->__rawData), 0, strpos($this->__rawData, "\n"))
|
||||
));
|
||||
|
||||
xml_parse_into_struct($this->__parser, $this->__rawData, $vals);
|
||||
$xml =& $this;
|
||||
|
@ -871,7 +886,8 @@ class Xml extends XmlNode {
|
|||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$data = $vals[$i];
|
||||
$data = array_merge(array('tag' => null, 'value' => null, 'attributes' => array()), $data);
|
||||
$data += array('tag' => null, 'value' => null, 'attributes' => array());
|
||||
|
||||
switch ($data['type']) {
|
||||
case "open" :
|
||||
$xml =& $xml->createElement($data['tag'], $data['value'], $data['attributes']);
|
||||
|
@ -906,8 +922,8 @@ class Xml extends XmlNode {
|
|||
/**
|
||||
* Returns a string representation of the XML object
|
||||
*
|
||||
* @param mixed $options If boolean: whether to include the XML header with the document (defaults to true); if array:
|
||||
* overrides the default XML generation options
|
||||
* @param mixed $options If boolean: whether to include the XML header with the document
|
||||
* (defaults to true); if an array, overrides the default XML generation options
|
||||
* @return string XML data
|
||||
* @access public
|
||||
* @deprecated
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
require_once CAKE.'basics.php';
|
||||
require_once CAKE . 'basics.php';
|
||||
App::import('Core', 'Folder');
|
||||
/**
|
||||
* BasicsTest class
|
||||
*
|
||||
|
@ -47,8 +48,11 @@ class BasicsTest extends CakeTestCase {
|
|||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testHttpBase() {
|
||||
function testEnv() {
|
||||
$this->skipIf(!function_exists('ini_get') || ini_get('safe_mode') === '1', '%s safe mode is on');
|
||||
|
||||
$__SERVER = $_SERVER;
|
||||
$__ENV = $_ENV;
|
||||
|
||||
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||
$this->assertEqual(env('HTTP_BASE'), '');
|
||||
|
@ -65,7 +69,48 @@ class BasicsTest extends CakeTestCase {
|
|||
$_SERVER['HTTP_HOST'] = 'double.subdomain.example.com';
|
||||
$this->assertEqual(env('HTTP_BASE'), '.subdomain.example.com');
|
||||
|
||||
$_SERVER = $_ENV = array();
|
||||
|
||||
$_SERVER['SCRIPT_NAME'] = '/a/test/test.php';
|
||||
$this->assertEqual(env('SCRIPT_NAME'), '/a/test/test.php');
|
||||
|
||||
$_SERVER = $_ENV = array();
|
||||
|
||||
$_ENV['CGI_MODE'] = 'BINARY';
|
||||
$_ENV['SCRIPT_URL'] = '/a/test/test.php';
|
||||
$this->assertEqual(env('SCRIPT_NAME'), '/a/test/test.php');
|
||||
|
||||
$_SERVER = $_ENV = array();
|
||||
|
||||
$_SERVER['HTTPS'] = 'on';
|
||||
$this->assertTrue(env('HTTPS'));
|
||||
|
||||
$_SERVER['HTTPS'] = 'off';
|
||||
$this->assertFalse(env('HTTPS'));
|
||||
|
||||
$_SERVER = array();
|
||||
|
||||
$_ENV['SCRIPT_URI'] = 'https://domain.test/a/test.php';
|
||||
$this->assertTrue(env('HTTPS'));
|
||||
|
||||
$_ENV['SCRIPT_URI'] = 'http://domain.test/a/test.php';
|
||||
$this->assertFalse(env('HTTPS'));
|
||||
|
||||
$_SERVER = $_ENV = array();
|
||||
|
||||
$this->assertFalse(env('TEST_ME'));
|
||||
|
||||
$_ENV['TEST_ME'] = 'a';
|
||||
$this->assertEqual(env('TEST_ME'), 'a');
|
||||
|
||||
$_SERVER['TEST_ME'] = 'b';
|
||||
$this->assertEqual(env('TEST_ME'), 'b');
|
||||
|
||||
unset($_ENV['TEST_ME']);
|
||||
$this->assertEqual(env('TEST_ME'), 'b');
|
||||
|
||||
$_SERVER = $__SERVER;
|
||||
$_ENV = $__ENV;
|
||||
}
|
||||
/**
|
||||
* test uses()
|
||||
|
@ -145,6 +190,8 @@ class BasicsTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testCache() {
|
||||
$_cacheDisable = Configure::read('Cache.disable');
|
||||
|
||||
Configure::write('Cache.disable', true);
|
||||
$result = cache('basics_test', 'simple cache write');
|
||||
$this->assertNull($result);
|
||||
|
@ -165,6 +212,8 @@ class BasicsTest extends CakeTestCase {
|
|||
sleep(2);
|
||||
$result = cache('basics_test', null, '+1 second');
|
||||
$this->assertNull($result);
|
||||
|
||||
Configure::write('Cache.disable', $_cacheDisable);
|
||||
}
|
||||
/**
|
||||
* test clearCache()
|
||||
|
@ -414,6 +463,50 @@ class BasicsTest extends CakeTestCase {
|
|||
$this->assertNoPattern("/Error: Testing with\nmulti-line\nstring/", $result);
|
||||
$this->assertPattern('/Error: Testing with multi-line string/', $result);
|
||||
}
|
||||
/**
|
||||
* test fileExistsInPath()
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testFileExistsInPath() {
|
||||
$this->skipUnless(function_exists('ini_set'), '%s ini_set function not available');
|
||||
|
||||
$_includePath = ini_get('include_path');
|
||||
|
||||
$path = TMP . 'basics_test';
|
||||
$folder1 = $path . DS . 'folder1';
|
||||
$folder2 = $path . DS . 'folder2';
|
||||
$file1 = $path . DS . 'file1.php';
|
||||
$file2 = $folder1 . DS . 'file2.php';
|
||||
$file3 = $folder1 . DS . 'file3.php';
|
||||
$file4 = $folder2 . DS . 'file4.php';
|
||||
|
||||
new Folder($path, true);
|
||||
new Folder($folder1, true);
|
||||
new Folder($folder2, true);
|
||||
touch($file1);
|
||||
touch($file2);
|
||||
touch($file3);
|
||||
touch($file4);
|
||||
|
||||
ini_set('include_path', $path . PATH_SEPARATOR . $folder1);
|
||||
|
||||
$this->assertEqual(fileExistsInPath('file1.php'), $file1);
|
||||
$this->assertEqual(fileExistsInPath('file2.php'), $file2);
|
||||
$this->assertEqual(fileExistsInPath('folder1' . DS . 'file2.php'), $file2);
|
||||
$this->assertEqual(fileExistsInPath($file2), $file2);
|
||||
$this->assertEqual(fileExistsInPath('file3.php'), $file3);
|
||||
$this->assertEqual(fileExistsInPath($file4), $file4);
|
||||
|
||||
$this->assertFalse(fileExistsInPath('file1'));
|
||||
$this->assertFalse(fileExistsInPath('file4.php'));
|
||||
|
||||
$Folder = new Folder($path);
|
||||
$Folder->delete();
|
||||
|
||||
ini_set('include_path', $_includePath);
|
||||
}
|
||||
/**
|
||||
* test convertSlash()
|
||||
*
|
||||
|
@ -429,5 +522,151 @@ class BasicsTest extends CakeTestCase {
|
|||
$expected = 'path_to_location';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* test debug()
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testDebug() {
|
||||
ob_start();
|
||||
debug('this-is-a-test');
|
||||
$result = ob_get_clean();
|
||||
$pattern = '/.*' . preg_quote(substr(__FILE__, 1), '/')
|
||||
. '.*line.*' . (__LINE__ - 3) . '.*this-is-a-test.*/s';
|
||||
$this->assertPattern($pattern, $result);
|
||||
|
||||
ob_start();
|
||||
debug('<div>this-is-a-test</div>', true);
|
||||
$result = ob_get_clean();
|
||||
$pattern = '/.*' . preg_quote(substr(__FILE__, 1), '/')
|
||||
. '.*line.*' . (__LINE__ - 3) . '.*<div>this-is-a-test<\/div>.*/s';
|
||||
$this->assertPattern($pattern, $result);
|
||||
}
|
||||
/**
|
||||
* test pr()
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testPr() {
|
||||
ob_start();
|
||||
pr('this is a test');
|
||||
$result = ob_get_clean();
|
||||
$expected = "<pre>this is a test</pre>";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
ob_start();
|
||||
pr(array('this' => 'is', 'a' => 'test'));
|
||||
$result = ob_get_clean();
|
||||
$expected = "<pre>Array\n(\n [this] => is\n [a] => test\n)\n</pre>";
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* test params()
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testParams() {
|
||||
$this->assertNull(params('weekend'));
|
||||
$this->assertNull(params(array()));
|
||||
$this->assertEqual(params(array('weekend')), array('weekend'));
|
||||
|
||||
$nested = array(array('weekend'));
|
||||
$this->assertEqual(params($nested), array('weekend'));
|
||||
|
||||
$multiple = array(array('weekend'), 'jean-luc', 'godard');
|
||||
$this->assertEqual(params($multiple), $multiple);
|
||||
}
|
||||
/**
|
||||
* test stripslashes_deep()
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testStripslashesDeep() {
|
||||
$this->skipIf(ini_get('magic_quotes_sybase') === '1', '%s magic_quotes_sybase is on');
|
||||
|
||||
$this->assertEqual(stripslashes_deep("tes\'t"), "tes't");
|
||||
$this->assertEqual(stripslashes_deep('tes\\' . chr(0) .'t'), 'tes' . chr(0) .'t');
|
||||
$this->assertEqual(stripslashes_deep('tes\"t'), 'tes"t');
|
||||
$this->assertEqual(stripslashes_deep("tes\'t"), "tes't");
|
||||
$this->assertEqual(stripslashes_deep('te\\st'), 'test');
|
||||
|
||||
$nested = array(
|
||||
'a' => "tes\'t",
|
||||
'b' => 'tes\\' . chr(0) .'t',
|
||||
'c' => array(
|
||||
'd' => 'tes\"t',
|
||||
'e' => "te\'s\'t",
|
||||
array('f' => "tes\'t")
|
||||
),
|
||||
'g' => 'te\\st'
|
||||
);
|
||||
$expected = array(
|
||||
'a' => "tes't",
|
||||
'b' => 'tes' . chr(0) .'t',
|
||||
'c' => array(
|
||||
'd' => 'tes"t',
|
||||
'e' => "te's't",
|
||||
array('f' => "tes't")
|
||||
),
|
||||
'g' => 'test'
|
||||
);
|
||||
$this->assertEqual(stripslashes_deep($nested), $expected);
|
||||
}
|
||||
/**
|
||||
* test stripslashes_deep() with magic_quotes_sybase on
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testStripslashesDeepSybase() {
|
||||
$this->skipUnless(ini_get('magic_quotes_sybase') === '1', '%s magic_quotes_sybase is off');
|
||||
|
||||
$this->assertEqual(stripslashes_deep("tes\'t"), "tes\'t");
|
||||
|
||||
$nested = array(
|
||||
'a' => "tes't",
|
||||
'b' => "tes''t",
|
||||
'c' => array(
|
||||
'd' => "tes'''t",
|
||||
'e' => "tes''''t",
|
||||
array('f' => "tes''t")
|
||||
),
|
||||
'g' => "te'''''st"
|
||||
);
|
||||
$expected = array(
|
||||
'a' => "tes't",
|
||||
'b' => "tes't",
|
||||
'c' => array(
|
||||
'd' => "tes''t",
|
||||
'e' => "tes''t",
|
||||
array('f' => "tes't")
|
||||
),
|
||||
'g' => "te'''st"
|
||||
);
|
||||
$this->assertEqual(stripslashes_deep($nested), $expected);
|
||||
}
|
||||
/**
|
||||
* test ife()
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testIfe() {
|
||||
$this->assertEqual(ife(true, 'a', 'b'), 'a');
|
||||
$this->assertEqual(ife(' ', 'a', 'b'), 'a');
|
||||
$this->assertEqual(ife('test', 'a', 'b'), 'a');
|
||||
$this->assertEqual(ife(23, 'a', 'b'), 'a');
|
||||
$this->assertEqual(ife(array('t' => 'est'), 'a', 'b'), 'a');
|
||||
|
||||
$this->assertEqual(ife(false, 'a', 'b'), 'b');
|
||||
$this->assertEqual(ife(null, 'a', 'b'), 'b');
|
||||
$this->assertEqual(ife('', 'a', 'b'), 'b');
|
||||
$this->assertEqual(ife(0, 'a', 'b'), 'b');
|
||||
$this->assertEqual(ife(array(), 'a', 'b'), 'b');
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -445,6 +445,8 @@ class ShellDispatcherTest extends UnitTestCase {
|
|||
$expected .= "\n/";
|
||||
$this->assertPattern($expected, $Dispatcher->stdout);
|
||||
|
||||
// Shells need to be returned ordered
|
||||
// See Configure::__list/Folder::read
|
||||
$expected = "/ ROOT(\\\|\/)cake(\\\|\/)tests(\\\|\/)test_app(\\\|\/)plugins(\\\|\/)test_plugin_two(\\\|\/)vendors(\\\|\/)shells:";
|
||||
$expected .= "\n\t example";
|
||||
$expected .= "\n\t welcome";
|
||||
|
@ -461,6 +463,8 @@ class ShellDispatcherTest extends UnitTestCase {
|
|||
$expected .= "\n/";
|
||||
$this->assertPattern($expected, $Dispatcher->stdout);
|
||||
|
||||
// Shells need to be returned ordered
|
||||
// See Configure::__list/Folder::read
|
||||
$expected = "/ ROOT(\\\|\/)cake(\\\|\/)console(\\\|\/)libs:";
|
||||
$expected .= "\n\t acl";
|
||||
$expected .= "\n\t api";
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* Test Case for Shell
|
||||
*
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
|
@ -16,15 +16,15 @@
|
|||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.console.libs
|
||||
* @since CakePHP v 1.2.0.7726
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('Core', 'Shell');
|
||||
App::import('Core', array('Shell', 'Folder'));
|
||||
|
||||
if (!defined('DISABLE_AUTO_DISPATCH')) {
|
||||
define('DISABLE_AUTO_DISPATCH', true);
|
||||
|
@ -37,37 +37,80 @@ if (!class_exists('ShellDispatcher')) {
|
|||
ob_end_clean();
|
||||
}
|
||||
|
||||
Mock::generatePartial(
|
||||
'ShellDispatcher', 'TestShellMockShellDispatcher',
|
||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
||||
);
|
||||
/**
|
||||
* Test Shell class
|
||||
* TestShell class
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs
|
||||
* @subpackage cake.tests.cases.console.libs
|
||||
*/
|
||||
class TestShell extends Shell {
|
||||
|
||||
}
|
||||
|
||||
Mock::generate('ShellDispatcher');
|
||||
|
||||
/**
|
||||
* Test case class for shell
|
||||
* TestAppleTask class
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs
|
||||
* @subpackage cake.tests.cases.console.libs
|
||||
*/
|
||||
class TestAppleTask extends Shell {
|
||||
}
|
||||
/**
|
||||
* TestBananaTask class
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.console.libs
|
||||
*/
|
||||
class TestBananaTask extends Shell {
|
||||
}
|
||||
/**
|
||||
* ShellTest class
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.console.libs
|
||||
*/
|
||||
class ShellTest extends CakeTestCase {
|
||||
/**
|
||||
* Fixtures used in this test case
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
class CakeShellTestCase extends CakeTestCase {
|
||||
var $fixtures = array('core.post', 'core.comment');
|
||||
/**
|
||||
* setup
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
* @access public
|
||||
*/
|
||||
function setUp() {
|
||||
$this->Dispatcher =& new MockShellDispatcher();
|
||||
$this->Dispatcher =& new TestShellMockShellDispatcher();
|
||||
$this->Shell =& new TestShell($this->Dispatcher);
|
||||
}
|
||||
/**
|
||||
* undocumented function
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function tearDown() {
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
/**
|
||||
* testConstruct method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testConstruct() {
|
||||
$this->assertIsA($this->Shell->Dispatch, 'TestShellMockShellDispatcher');
|
||||
$this->assertEqual($this->Shell->name, 'TestShell');
|
||||
$this->assertEqual($this->Shell->alias, 'TestShell');
|
||||
}
|
||||
/**
|
||||
* testInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
|
@ -84,43 +127,255 @@ class CakeShellTestCase extends CakeTestCase {
|
|||
$this->Shell->initialize();
|
||||
|
||||
$this->assertTrue(isset($this->Shell->TestPluginPost));
|
||||
$this->assertTrue(is_a($this->Shell->TestPluginPost, 'TestPluginPost'));
|
||||
$this->assertIsA($this->Shell->TestPluginPost, 'TestPluginPost');
|
||||
$this->assertEqual($this->Shell->modelClass, 'TestPluginPost');
|
||||
|
||||
|
||||
$this->Shell->uses = array('Comment');
|
||||
$this->Shell->initialize();
|
||||
$this->assertTrue(isset($this->Shell->Comment));
|
||||
$this->assertTrue(is_a($this->Shell->Comment, 'Comment'));
|
||||
$this->assertIsA($this->Shell->Comment, 'Comment');
|
||||
$this->assertEqual($this->Shell->modelClass, 'Comment');
|
||||
|
||||
|
||||
$this->Shell->uses = true;
|
||||
$this->Shell->initialize();
|
||||
$this->assertTrue(isset($this->Shell->AppModel));
|
||||
$this->assertIsA($this->Shell->AppModel, 'AppModel');
|
||||
|
||||
Configure::write('pluginPaths', $_back['pluginPaths']);
|
||||
Configure::write('modelPaths', $_back['modelPaths']);
|
||||
}
|
||||
/**
|
||||
* testOut method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testOut() {
|
||||
$this->Shell->Dispatch->expectAt(0, 'stdout', array('Just a test', true));
|
||||
$this->Shell->out('Just a test');
|
||||
|
||||
$this->Shell->Dispatch->expectAt(1, 'stdout', array("Just\na\ntest\n", true));
|
||||
$this->Shell->out(array('Just', 'a', 'test'));
|
||||
}
|
||||
/**
|
||||
* Test Loading of Tasks
|
||||
* testIn method
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
* @access public
|
||||
*/
|
||||
function testIn() {
|
||||
$this->Shell->Dispatch->setReturnValueAt(0, 'getInput', 'n');
|
||||
$this->Shell->Dispatch->expectAt(0, 'getInput', array('Just a test?', array('y', 'n'), 'n'));
|
||||
$result = $this->Shell->in('Just a test?', array('y', 'n'), 'n');
|
||||
$this->assertEqual($result, 'n');
|
||||
|
||||
$this->Shell->Dispatch->setReturnValueAt(1, 'getInput', 'Y');
|
||||
$this->Shell->Dispatch->expectAt(1, 'getInput', array('Just a test?', array('y', 'n'), 'n'));
|
||||
$result = $this->Shell->in('Just a test?', array('y', 'n'), 'n');
|
||||
$this->assertEqual($result, 'Y');
|
||||
|
||||
$this->Shell->Dispatch->setReturnValueAt(2, 'getInput', 'y');
|
||||
$this->Shell->Dispatch->expectAt(2, 'getInput', array('Just a test?', 'y,n', 'n'));
|
||||
$result = $this->Shell->in('Just a test?', 'y,n', 'n');
|
||||
$this->assertEqual($result, 'y');
|
||||
|
||||
$this->Shell->Dispatch->setReturnValueAt(3, 'getInput', 'y');
|
||||
$this->Shell->Dispatch->expectAt(3, 'getInput', array('Just a test?', 'y/n', 'n'));
|
||||
$result = $this->Shell->in('Just a test?', 'y/n', 'n');
|
||||
$this->assertEqual($result, 'y');
|
||||
|
||||
$this->Shell->Dispatch->setReturnValueAt(4, 'getInput', 'y');
|
||||
$this->Shell->Dispatch->expectAt(4, 'getInput', array('Just a test?', 'y', 'y'));
|
||||
$result = $this->Shell->in('Just a test?', 'y', 'y');
|
||||
$this->assertEqual($result, 'y');
|
||||
|
||||
$this->Shell->interactive = false;
|
||||
|
||||
$result = $this->Shell->in('Just a test?', 'y/n', 'n');
|
||||
$this->assertEqual($result, 'n');
|
||||
}
|
||||
/**
|
||||
* testLoadTasks method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testLoadTasks() {
|
||||
|
||||
$this->assertTrue($this->Shell->loadTasks());
|
||||
|
||||
$this->Shell->tasks = null;
|
||||
$this->assertTrue($this->Shell->loadTasks());
|
||||
|
||||
$this->Shell->tasks = false;
|
||||
$this->assertTrue($this->Shell->loadTasks());
|
||||
|
||||
$this->Shell->tasks = true;
|
||||
$this->assertTrue($this->Shell->loadTasks());
|
||||
|
||||
$this->Shell->tasks = array();
|
||||
$this->assertTrue($this->Shell->loadTasks());
|
||||
|
||||
// Fatal Error
|
||||
// $this->Shell->tasks = 'TestIDontExist';
|
||||
// $this->assertFalse($this->Shell->loadTasks());
|
||||
// $this->assertFalse(isset($this->Shell->TestIDontExist));
|
||||
|
||||
$this->Shell->tasks = 'TestApple';
|
||||
$this->assertTrue($this->Shell->loadTasks());
|
||||
$this->assertIsA($this->Shell->TestApple, 'TestAppleTask');
|
||||
|
||||
$this->Shell->tasks = 'TestBanana';
|
||||
$this->assertTrue($this->Shell->loadTasks());
|
||||
$this->assertIsA($this->Shell->TestApple, 'TestAppleTask');
|
||||
$this->assertIsA($this->Shell->TestBanana, 'TestBananaTask');
|
||||
|
||||
unset($this->Shell->ShellTestApple, $this->Shell->TestBanana);
|
||||
|
||||
$this->Shell->tasks = array('TestApple', 'TestBanana');
|
||||
$this->assertTrue($this->Shell->loadTasks());
|
||||
$this->assertIsA($this->Shell->TestApple, 'TestAppleTask');
|
||||
$this->assertIsA($this->Shell->TestBanana, 'TestBananaTask');
|
||||
}
|
||||
/**
|
||||
* test ShortPath
|
||||
* testShortPath method
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
* @access public
|
||||
*/
|
||||
function testShortPath() {
|
||||
|
||||
$path = $expected = DS . 'tmp' . DS . 'ab' . DS . 'cd';
|
||||
$this->assertEqual($this->Shell->shortPath($path), $expected);
|
||||
|
||||
$path = $expected = DS . 'tmp' . DS . 'ab' . DS . 'cd' . DS ;
|
||||
$this->assertEqual($this->Shell->shortPath($path), $expected);
|
||||
|
||||
$path = $expected = DS . 'tmp' . DS . 'ab' . DS . 'index.php';
|
||||
$this->assertEqual($this->Shell->shortPath($path), $expected);
|
||||
|
||||
// Shell::shortPath needs Folder::realpath
|
||||
// $path = DS . 'tmp' . DS . 'ab' . DS . '..' . DS . 'cd';
|
||||
// $expected = DS . 'tmp' . DS . 'cd';
|
||||
// $this->assertEqual($this->Shell->shortPath($path), $expected);
|
||||
|
||||
$path = DS . 'tmp' . DS . 'ab' . DS . DS . 'cd';
|
||||
$expected = DS . 'tmp' . DS . 'ab' . DS . 'cd';
|
||||
$this->assertEqual($this->Shell->shortPath($path), $expected);
|
||||
|
||||
$path = 'tmp' . DS . 'ab';
|
||||
$expected = 'tmp' . DS . 'ab';
|
||||
$this->assertEqual($this->Shell->shortPath($path), $expected);
|
||||
|
||||
$path = 'tmp' . DS . 'ab';
|
||||
$expected = 'tmp' . DS . 'ab';
|
||||
$this->assertEqual($this->Shell->shortPath($path), $expected);
|
||||
|
||||
$path = APP;
|
||||
$expected = DS . basename(APP) . DS;
|
||||
$this->assertEqual($this->Shell->shortPath($path), $expected);
|
||||
|
||||
$path = APP . 'index.php';
|
||||
$expected = DS . basename(APP) . DS . 'index.php';
|
||||
$this->assertEqual($this->Shell->shortPath($path), $expected);
|
||||
}
|
||||
/**
|
||||
* test File creation
|
||||
* testCreateFile method
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function createFile() {
|
||||
|
||||
* @access public
|
||||
*/
|
||||
function testCreateFile() {
|
||||
$this->skipIf(DIRECTORY_SEPARATOR === '\\', '%s Not supported on Windows');
|
||||
|
||||
$path = TMP . 'shell_test';
|
||||
$file = $path . DS . 'file1.php';
|
||||
|
||||
new Folder($path, true);
|
||||
|
||||
$this->Shell->interactive = false;
|
||||
|
||||
$contents = "<?php\necho 'test';\n\$te = 'st';\n?>";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
$this->assertEqual(file_get_contents($file), $contents);
|
||||
|
||||
$contents = "<?php\necho 'another test';\n\$te = 'st';\n?>";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
$this->assertEqual(file_get_contents($file), $contents);
|
||||
|
||||
$this->Shell->interactive = true;
|
||||
|
||||
$this->Shell->Dispatch->setReturnValueAt(0, 'getInput', 'n');
|
||||
$this->Shell->Dispatch->expectAt(1, 'stdout', array('File exists, overwrite?', '*'));
|
||||
|
||||
$contents = "<?php\necho 'yet another test';\n\$te = 'st';\n?>";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertFalse($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
$this->assertNotEqual(file_get_contents($file), $contents);
|
||||
|
||||
$this->Shell->Dispatch->setReturnValueAt(1, 'getInput', 'y');
|
||||
$this->Shell->Dispatch->expectAt(3, 'stdout', array('File exists, overwrite?', '*'));
|
||||
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
$this->assertEqual(file_get_contents($file), $contents);
|
||||
|
||||
$Folder = new Folder($path);
|
||||
$Folder->delete();
|
||||
}
|
||||
/**
|
||||
* testCreateFileWindows method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testCreateFileWindows() {
|
||||
$this->skipUnless(DIRECTORY_SEPARATOR === '\\', '%s Supported on Windows only');
|
||||
|
||||
$path = TMP . 'shell_test';
|
||||
$file = $path . DS . 'file1.php';
|
||||
|
||||
new Folder($path, true);
|
||||
|
||||
$this->Shell->interactive = false;
|
||||
|
||||
$contents = "<?php\necho 'test';\r\n\$te = 'st';\r\n?>";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
$this->assertEqual(file_get_contents($file), $contents);
|
||||
|
||||
$contents = "<?php\necho 'another test';\r\n\$te = 'st';\r\n?>";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
$this->assertEqual(file_get_contents($file), $contents);
|
||||
|
||||
$this->Shell->interactive = true;
|
||||
|
||||
$this->Shell->Dispatch->setReturnValueAt(0, 'getInput', 'n');
|
||||
$this->Shell->Dispatch->expectAt(1, 'stdout', array('File exists, overwrite?'));
|
||||
|
||||
$contents = "<?php\necho 'yet another test';\r\n\$te = 'st';\r\n?>";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertFalse($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
$this->assertNotEqual(file_get_contents($file), $contents);
|
||||
|
||||
$this->Shell->Dispatch->setReturnValueAt(1, 'getInput', 'y');
|
||||
$this->Shell->Dispatch->expectAt(3, 'stdout', array('File exists, overwrite?'));
|
||||
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
$this->assertEqual(file_get_contents($file), $contents);
|
||||
|
||||
$Folder = new Folder($path);
|
||||
$Folder->delete();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
136
cake/tests/cases/console/libs/tasks/extract.test.php
Normal file
136
cake/tests/cases/console/libs/tasks/extract.test.php
Normal file
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id: extract.test.php 7838 2008-11-07 10:41:52Z nate $ */
|
||||
/**
|
||||
* Test Case for i18n extraction shell task
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework (http://www.cakephp.org)
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.console.libs.tasks
|
||||
* @since CakePHP v 1.2.0.7726
|
||||
* @version $Revision: 7838 $
|
||||
* @modifiedby $LastChangedBy: DarkAngelBGE $
|
||||
* @lastmodified $Date: 2008-11-07 05:41:52 -0500 (Fri, 07 Nov 2008) $
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('Core', array('Shell', 'Folder'));
|
||||
|
||||
if (!defined('DISABLE_AUTO_DISPATCH')) {
|
||||
define('DISABLE_AUTO_DISPATCH', true);
|
||||
}
|
||||
|
||||
if (!class_exists('ShellDispatcher')) {
|
||||
ob_start();
|
||||
$argv = false;
|
||||
require CAKE . 'console' . DS . 'cake.php';
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
if (!class_exists('ExtractTask')) {
|
||||
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'extract.php';
|
||||
}
|
||||
|
||||
Mock::generatePartial(
|
||||
'ShellDispatcher', 'TestExtractTaskMockShellDispatcher',
|
||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
||||
);
|
||||
|
||||
/**
|
||||
* ExtractTaskTest class
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.console.libs.tasks
|
||||
*/
|
||||
class ExtractTaskTest extends CakeTestCase {
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function setUp() {
|
||||
$this->Dispatcher =& new TestExtractTaskMockShellDispatcher();
|
||||
$this->Task =& new ExtractTask($this->Dispatcher);
|
||||
}
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function tearDown() {
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
/**
|
||||
* testExecute method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testExecute() {
|
||||
$path = TMP . 'extract_task_test';
|
||||
$folder1 = $path . DS . 'locale';
|
||||
|
||||
new Folder($path, true);
|
||||
new Folder($folder1, true);
|
||||
|
||||
$this->Task->interactive = false;
|
||||
|
||||
$this->Task->params['path'] = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages';
|
||||
$this->Task->params['output'] = $path . DS;
|
||||
$this->Task->Dispatch->expectNever('stderr');
|
||||
$this->Task->Dispatch->expectNever('_stop');
|
||||
$this->Task->execute();
|
||||
$this->assertTrue(file_exists($path . DS . 'default.pot'));
|
||||
$result = file_get_contents($path . DS . 'default.pot');
|
||||
|
||||
$pattern = '/"Content-Type\: text\/plain; charset\=utf-8/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/"Content-Transfer-Encoding\: 8bit/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/"Plural-Forms\: nplurals\=INTEGER; plural\=EXPRESSION;/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
|
||||
$pattern = '/msgid "Your tmp directory is writable."\nmsgstr ""\n/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "Your tmp directory is NOT writable."\nmsgstr ""\n/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "The %s is being used for caching. To change the config edit ';
|
||||
$pattern .= 'APP\/config\/core.php "\nmsgstr ""\n/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "Your cache is NOT working. Please check ';
|
||||
$pattern .= 'the settings in APP\/config\/core.php"\nmsgstr ""\n/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "Your database configuration file is present."\nmsgstr ""\n/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "Your database configuration file is NOT present."\nmsgstr ""\n/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "Rename config\/database.php.default to ';
|
||||
$pattern .= 'config\/database.php"\nmsgstr ""\n/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "Cake is able to connect to the database."\nmsgstr ""\n/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "Cake is NOT able to connect to the database."\nmsgstr ""\n/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "Editing this Page"\nmsgstr ""\n/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "To change the content of this page, edit: %s.*To change its layout, ';
|
||||
$pattern .= 'edit: %s.*You can also add some CSS styles for your pages at: %s"\nmsgstr ""/s';
|
||||
$this->assertPattern($pattern, $result);
|
||||
|
||||
$Folder = new Folder($path);
|
||||
$Folder->delete();
|
||||
}
|
||||
}
|
||||
?>
|
100
cake/tests/cases/console/libs/tasks/test.test.php
Normal file
100
cake/tests/cases/console/libs/tasks/test.test.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Test Case for test generation shell task
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework (http://www.cakephp.org)
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.console.libs.tasks
|
||||
* @since CakePHP v 1.2.0.7726
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('Core', 'Shell');
|
||||
|
||||
if (!defined('DISABLE_AUTO_DISPATCH')) {
|
||||
define('DISABLE_AUTO_DISPATCH', true);
|
||||
}
|
||||
|
||||
if (!class_exists('ShellDispatcher')) {
|
||||
ob_start();
|
||||
$argv = false;
|
||||
require CAKE . 'console' . DS . 'cake.php';
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
if (!class_exists('TestTask')) {
|
||||
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'test.php';
|
||||
}
|
||||
|
||||
Mock::generatePartial(
|
||||
'ShellDispatcher', 'TestTestTaskMockShellDispatcher',
|
||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
||||
);
|
||||
Mock::generatePartial(
|
||||
'TestTask', 'MockTestTask',
|
||||
array('in', 'out', 'createFile')
|
||||
);
|
||||
/**
|
||||
* TestTaskTest class
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.console.libs.tasks
|
||||
*/
|
||||
class TestTaskTest extends CakeTestCase {
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function setUp() {
|
||||
$this->Dispatcher =& new TestTestTaskMockShellDispatcher();
|
||||
$this->Task =& new MockTestTask($this->Dispatcher);
|
||||
$this->Task->Dispatch = new $this->Dispatcher;
|
||||
}
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function tearDown() {
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
/**
|
||||
* Test that file path generation doesn't continuously append paths.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testFilePathGeneration () {
|
||||
$file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php';
|
||||
|
||||
$this->Task->Dispatch->expectNever('stderr');
|
||||
$this->Task->Dispatch->expectNever('_stop');
|
||||
|
||||
$this->Task->setReturnValueAt(0, 'in', 'y');
|
||||
$this->Task->expectAt(0, 'createFile', array($file, '*'));
|
||||
$this->Task->bake('Model', 'MyClass');
|
||||
|
||||
$this->Task->setReturnValueAt(1, 'in', 'y');
|
||||
$this->Task->expectAt(1, 'createFile', array($file, '*'));
|
||||
$this->Task->bake('Model', 'MyClass');
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -45,7 +45,7 @@ class TestDispatcher extends Dispatcher {
|
|||
function _invoke(&$controller, $params) {
|
||||
restore_error_handler();
|
||||
if ($result = parent::_invoke($controller, $params)) {
|
||||
if ($result === 'missingAction') {
|
||||
if ($result[0] === 'missingAction') {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ class TestDispatcher extends Dispatcher {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function cakeError($filename) {
|
||||
return $filename;
|
||||
function cakeError($filename, $params) {
|
||||
return array($filename, $params);
|
||||
}
|
||||
/**
|
||||
* _stop method
|
||||
|
@ -1111,8 +1111,12 @@ class DispatcherTest extends CakeTestCase {
|
|||
Configure::write('App.baseUrl','/index.php');
|
||||
$url = 'some_controller/home/param:value/param2:value2';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
|
||||
$expected = 'missingController';
|
||||
$expected = array('missingController', array(array(
|
||||
'className' => 'SomeControllerController',
|
||||
'webroot' => '/app/webroot/',
|
||||
'url' => 'some_controller/home/param:value/param2:value2',
|
||||
'base' => '/index.php'
|
||||
)));
|
||||
$this->assertEqual($expected, $controller);
|
||||
}
|
||||
/**
|
||||
|
@ -1125,9 +1129,16 @@ class DispatcherTest extends CakeTestCase {
|
|||
$Dispatcher =& new TestDispatcher();
|
||||
Configure::write('App.baseUrl','/index.php');
|
||||
$url = 'some_pages/_protected/param:value/param2:value2';
|
||||
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
|
||||
$expected = 'privateAction';
|
||||
$expected = array('privateAction', array(array(
|
||||
'className' => 'SomePagesController',
|
||||
'action' => '_protected',
|
||||
'webroot' => '/app/webroot/',
|
||||
'url' => 'some_pages/_protected/param:value/param2:value2',
|
||||
'base' => '/index.php'
|
||||
)));
|
||||
$this->assertEqual($controller, $expected);
|
||||
}
|
||||
/**
|
||||
|
@ -1142,7 +1153,14 @@ class DispatcherTest extends CakeTestCase {
|
|||
$url = 'some_pages/home/param:value/param2:value2';
|
||||
|
||||
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
|
||||
$expected = 'missingAction';
|
||||
|
||||
$expected = array('missingAction', array(array(
|
||||
'className' => 'SomePagesController',
|
||||
'action' => 'home',
|
||||
'webroot' => '/app/webroot/',
|
||||
'url' => '/index.php/some_pages/home/param:value/param2:value2',
|
||||
'base' => '/index.php'
|
||||
)));
|
||||
$this->assertEqual($expected, $controller);
|
||||
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
|
@ -1150,7 +1168,14 @@ class DispatcherTest extends CakeTestCase {
|
|||
$url = 'some_pages/redirect/param:value/param2:value2';
|
||||
|
||||
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
|
||||
$expected = 'missingAction';
|
||||
|
||||
$expected = array('missingAction', array(array(
|
||||
'className' => 'SomePagesController',
|
||||
'action' => 'redirect',
|
||||
'webroot' => '/app/webroot/',
|
||||
'url' => '/index.php/some_pages/redirect/param:value/param2:value2',
|
||||
'base' => '/index.php'
|
||||
)));
|
||||
$this->assertEqual($expected, $controller);
|
||||
}
|
||||
/**
|
||||
|
@ -1207,6 +1232,25 @@ class DispatcherTest extends CakeTestCase {
|
|||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertEqual('TestDispatchPages', $controller->name);
|
||||
}
|
||||
/**
|
||||
* testDispatchWithArray method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testDispatchWithArray() {
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
Configure::write('App.baseUrl','/index.php');
|
||||
$url = 'pages/home/param:value/param2:value2';
|
||||
|
||||
$url = array('controller' => 'pages', 'action' => 'display');
|
||||
$controller = $Dispatcher->dispatch($url, array('pass' => array('home'), 'named' => array('param' => 'value', 'param2' => 'value2'), 'return' => 1));
|
||||
$expected = 'Pages';
|
||||
$this->assertEqual($expected, $controller->name);
|
||||
|
||||
$expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2');
|
||||
$this->assertIdentical($expected, $controller->passedArgs);
|
||||
}
|
||||
/**
|
||||
* testAdminDispatch method
|
||||
*
|
||||
|
@ -1273,6 +1317,9 @@ class DispatcherTest extends CakeTestCase {
|
|||
$expected = 'SomePages';
|
||||
$this->assertIdentical($expected, $controller->name);
|
||||
|
||||
$expected = 'some_pages';
|
||||
$this->assertIdentical($expected, $controller->params['controller']);
|
||||
|
||||
$expected = array('0' => 'home', 'param'=>'value', 'param2'=>'value2');
|
||||
$this->assertIdentical($expected, $controller->passedArgs);
|
||||
|
||||
|
@ -1350,6 +1397,32 @@ class DispatcherTest extends CakeTestCase {
|
|||
$this->assertEqual($controller->params['named'], $expected);
|
||||
|
||||
|
||||
Router::reload();
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
$Dispatcher->base = false;
|
||||
|
||||
/* Simulates the Route for a real plugin, installed in APP/plugins */
|
||||
Router::connect('/my_plugin/:controller/:action/*', array('plugin' => 'my_plugin'));
|
||||
|
||||
$plugin = 'MyPlugin';
|
||||
$pluginUrl = Inflector::underscore($plugin);
|
||||
|
||||
$url = $pluginUrl;
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
|
||||
$expected = $pluginUrl;
|
||||
$this->assertIdentical($controller->plugin, $expected);
|
||||
|
||||
$expected = $plugin;
|
||||
$this->assertIdentical($controller->name, $expected);
|
||||
|
||||
$expected = 'index';
|
||||
$this->assertIdentical($controller->action, $expected);
|
||||
|
||||
$expected = $pluginUrl;
|
||||
$this->assertEqual($controller->params['controller'], $expected);
|
||||
|
||||
|
||||
Configure::write('Routing.admin', 'admin');
|
||||
|
||||
Router::reload();
|
||||
|
@ -1393,6 +1466,55 @@ class DispatcherTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertEqual($controller->params, $expected);
|
||||
}
|
||||
/**
|
||||
* test Plugin dispatching without controller name and using
|
||||
* plugin short form instead.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testAutomaticPluginDispatchWithShortAccess() {
|
||||
$_POST = array();
|
||||
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
|
||||
|
||||
Router::reload();
|
||||
Router::connect('/my_plugin/:controller/:action/*', array('plugin'=>'my_plugin'));
|
||||
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
$Dispatcher->base = false;
|
||||
|
||||
$url = 'my_plugin/my_plugin/add';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertFalse(isset($controller->params['pass'][0]));
|
||||
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
$Dispatcher->base = false;
|
||||
|
||||
$url = 'my_plugin/my_plugin/add/0';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertTrue(isset($controller->params['pass'][0]));
|
||||
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
$Dispatcher->base = false;
|
||||
|
||||
$url = 'my_plugin/add';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
|
||||
$this->assertFalse(isset($controller->params['pass'][0]));
|
||||
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
$Dispatcher->base = false;
|
||||
|
||||
$url = 'my_plugin/add/0';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertIdentical('0',$controller->params['pass'][0]);
|
||||
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
$Dispatcher->base = false;
|
||||
|
||||
$url = 'my_plugin/add/1';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertIdentical('1',$controller->params['pass'][0]);
|
||||
}
|
||||
/**
|
||||
* testAutomaticPluginControllerMissingActionDispatch method
|
||||
*
|
||||
|
@ -1407,10 +1529,32 @@ class DispatcherTest extends CakeTestCase {
|
|||
$Dispatcher =& new TestDispatcher();
|
||||
$Dispatcher->base = false;
|
||||
|
||||
$url = 'my_plugin/not_here/param:value/param2:value2';
|
||||
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
|
||||
|
||||
$expected = array('missingAction', array(array(
|
||||
'className' => 'MyPluginController',
|
||||
'action' => 'not_here',
|
||||
'webroot' => '/cake/repo/branches/1.2.x.x/',
|
||||
'url' => '/cake/repo/branches/1.2.x.x/my_plugin/not_here/param:value/param2:value2',
|
||||
'base' => '/cake/repo/branches/1.2.x.x'
|
||||
)));
|
||||
$this->assertIdentical($expected, $controller);
|
||||
|
||||
Router::reload();
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
$Dispatcher->base = false;
|
||||
|
||||
$url = 'my_plugin/param:value/param2:value2';
|
||||
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
|
||||
|
||||
$expected = 'missingAction';
|
||||
$expected = array('missingAction', array(array(
|
||||
'className' => 'MyPluginController',
|
||||
'action' => 'param:value',
|
||||
'webroot' => '/cake/repo/branches/1.2.x.x/',
|
||||
'url' => '/cake/repo/branches/1.2.x.x/my_plugin/param:value/param2:value2',
|
||||
'base' => '/cake/repo/branches/1.2.x.x'
|
||||
)));
|
||||
$this->assertIdentical($expected, $controller);
|
||||
}
|
||||
/**
|
||||
|
@ -1432,7 +1576,13 @@ class DispatcherTest extends CakeTestCase {
|
|||
$url = 'test_dispatch_pages/admin_index/param:value/param2:value2';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
|
||||
$expected = 'privateAction';
|
||||
$expected = array('privateAction', array(array(
|
||||
'className' => 'TestDispatchPagesController',
|
||||
'action' => 'admin_index',
|
||||
'webroot' => '/cake/repo/branches/1.2.x.x/',
|
||||
'url' => 'test_dispatch_pages/admin_index/param:value/param2:value2',
|
||||
'base' => '/cake/repo/branches/1.2.x.x'
|
||||
)));
|
||||
$this->assertIdentical($expected, $controller);
|
||||
}
|
||||
/**
|
||||
|
@ -1464,7 +1614,13 @@ class DispatcherTest extends CakeTestCase {
|
|||
$url = 'some_posts/index/param:value/param2:value2';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
|
||||
$expected = 'missingAction';
|
||||
$expected = array('missingAction', array(array(
|
||||
'className' => 'SomePostsController',
|
||||
'action' => 'view',
|
||||
'webroot' => '/cake/repo/branches/1.2.x.x/',
|
||||
'url' => '/cake/repo/branches/1.2.x.x/some_posts/index/param:value/param2:value2',
|
||||
'base' => '/cake/repo/branches/1.2.x.x'
|
||||
)));
|
||||
$this->assertEqual($expected, $controller);
|
||||
|
||||
$url = 'some_posts/something_else/param:value/param2:value2';
|
||||
|
|
13
cake/tests/cases/libs/cache/memcache.test.php
vendored
13
cake/tests/cases/libs/cache/memcache.test.php
vendored
|
@ -189,6 +189,19 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
$result = Cache::read('other_test');
|
||||
$this->assertFalse($result);
|
||||
|
||||
Cache::engine('Memcache', array('duration' => '+31 day'));
|
||||
$data = 'this is a test of the emergency broadcasting system';
|
||||
$result = Cache::write('long_expiry_test', $data);
|
||||
$this->assertTrue($result);
|
||||
|
||||
sleep(2);
|
||||
$result = Cache::read('long_expiry_test');
|
||||
$expecting = $data;
|
||||
$this->assertEqual($result, $expecting);
|
||||
|
||||
$result = Cache::read('long_expiry_test');
|
||||
$this->assertTrue($result);
|
||||
|
||||
Cache::engine('Memcache', array('duration' => 3600));
|
||||
}
|
||||
/**
|
||||
|
|
17
cake/tests/cases/libs/cache/xcache.test.php
vendored
17
cake/tests/cases/libs/cache/xcache.test.php
vendored
|
@ -139,6 +139,23 @@ class XcacheEngineTest extends UnitTestCase {
|
|||
$result = Cache::delete('delete_test');
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
/**
|
||||
* testClearCache method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testClearCache() {
|
||||
$data = 'this is a test of the emergency broadcasting system';
|
||||
$result = Cache::write('clear_test_1', $data);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$result = Cache::write('clear_test_2', $data);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$result = Cache::clear();
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
|
|
|
@ -265,6 +265,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
));
|
||||
$this->assertEqual($result['params']['pass'], array('gogo', 'val2'));
|
||||
|
||||
|
||||
$result = $this->Case->testAction('/tests_apps_posts/url_var', array(
|
||||
'return' => 'vars',
|
||||
'method' => 'get',
|
||||
|
@ -288,8 +289,40 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
));
|
||||
$this->assertEqual(array_keys($result['data']), array('name', 'pork'));
|
||||
|
||||
$db =& ConnectionManager::getDataSource('test_suite');
|
||||
|
||||
$db =& ConnectionManager::getDataSource('test_suite');
|
||||
$_backPrefix = $db->config['prefix'];
|
||||
$db->config['prefix'] = 'cake_testaction_test_suite_';
|
||||
|
||||
$config = $db->config;
|
||||
$config['prefix'] = 'cake_testcase_test_';
|
||||
|
||||
ConnectionManager::create('cake_test_case', $config);
|
||||
$db =& ConnectionManager::getDataSource('cake_test_case');
|
||||
|
||||
$fixture =& new PostFixture($db);
|
||||
$fixture->create($db);
|
||||
$fixture->insert($db);
|
||||
|
||||
$result = $this->Case->testAction('/tests_apps_posts/fixtured', array(
|
||||
'return' => 'vars',
|
||||
'fixturize' => true,
|
||||
'connection' => 'cake_test_case',
|
||||
));
|
||||
$this->assertTrue(isset($result['posts']));
|
||||
$this->assertEqual(count($result['posts']), 3);
|
||||
$tables = $db->listSources(true);
|
||||
$this->assertFalse(in_array('cake_testaction_test_suite_posts', $tables));
|
||||
|
||||
$fixture->drop($db);
|
||||
|
||||
$db =& ConnectionManager::getDataSource('test_suite');
|
||||
$db->config['prefix'] = $_backPrefix;
|
||||
$fixture->drop($db);
|
||||
|
||||
|
||||
//test that drop tables behaves as exepected with testAction
|
||||
$db =& ConnectionManager::getDataSource('test_suite');
|
||||
$_backPrefix = $db->config['prefix'];
|
||||
$db->config['prefix'] = 'cake_testaction_test_suite_';
|
||||
|
||||
|
@ -301,21 +334,23 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
$fixture =& new PostFixture($db);
|
||||
$fixture->create($db);
|
||||
$fixture->insert($db);
|
||||
|
||||
|
||||
$this->Case->dropTables = false;
|
||||
$result = $this->Case->testAction('/tests_apps_posts/fixtured', array(
|
||||
'return' => 'vars',
|
||||
'fixturize' => true,
|
||||
'connection' => 'cake_test_case',
|
||||
));
|
||||
$this->assertTrue(isset($result['posts']));
|
||||
$this->assertEqual(count($result['posts']), 3);
|
||||
|
||||
|
||||
$tables = $db->listSources();
|
||||
$this->assertTrue(in_array('cake_testaction_test_suite_posts', $tables));
|
||||
|
||||
$fixture->drop($db);
|
||||
|
||||
$db =& ConnectionManager::getDataSource('test_suite');
|
||||
$db->config['prefix'] = $_backPrefix;
|
||||
$fixture->drop($db);
|
||||
|
||||
|
||||
Configure::write('modelPaths', $_back['model']);
|
||||
Configure::write('controllerPaths', $_back['controller']);
|
||||
Configure::write('viewPaths', $_back['view']);
|
||||
|
|
|
@ -320,7 +320,8 @@ class ComponentTest extends CakeTestCase {
|
|||
$this->assertTrue(is_a($Controller->Apple->Orange, 'OrangeComponent'));
|
||||
$this->assertTrue(is_a($Controller->Apple->Orange->Banana, 'BananaComponent'));
|
||||
$this->assertTrue(is_a($Controller->Apple->Orange->Controller, 'ComponentTestController'));
|
||||
|
||||
$this->assertTrue(empty($Controller->Apple->Session));
|
||||
$this->assertTrue(empty($Controller->Apple->Orange->Session));
|
||||
}
|
||||
/**
|
||||
* Tests Component::startup() and only running callbacks for components directly attached to
|
||||
|
@ -443,6 +444,19 @@ class ComponentTest extends CakeTestCase {
|
|||
'ComponentTestController'
|
||||
));
|
||||
}
|
||||
/**
|
||||
* test that SessionComponent doesn't get added if its already in the components array.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testDoubleLoadingOfSessionComponent() {
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->uses = array();
|
||||
$Controller->components = array('Session');
|
||||
$Controller->constructClasses();
|
||||
|
||||
$this->assertEqual($Controller->components, array('Session' => '', 'Orange' => array('colour' => 'blood orange')));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -282,6 +282,15 @@ class AuthTestController extends Controller {
|
|||
function add() {
|
||||
echo "add";
|
||||
}
|
||||
/**
|
||||
* add method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function camelCase() {
|
||||
echo "camelCase";
|
||||
}
|
||||
/**
|
||||
* redirect method
|
||||
*
|
||||
|
@ -557,7 +566,13 @@ class AuthTest extends CakeTestCase {
|
|||
|
||||
$this->Controller->Session->del('Auth');
|
||||
$result = $this->Controller->Auth->startup($this->Controller);
|
||||
$this->assertFalse($result);
|
||||
$this->assertTrue($this->Controller->Session->check('Message.auth'));
|
||||
|
||||
|
||||
$this->Controller->params = Router::parse('auth_test/camelCase');
|
||||
$result = $this->Controller->Auth->startup($this->Controller);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
/**
|
||||
* testAuthorizeController method
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
*/
|
||||
App::import('Core', array('Controller'));
|
||||
App::import('Component', array('RequestHandler'));
|
||||
|
||||
Mock::generatePartial('RequestHandlerComponent', 'NoStopRequestHandler', array('_stop'));
|
||||
/**
|
||||
* RequestHandlerTestController class
|
||||
*
|
||||
|
@ -53,6 +55,15 @@ class RequestHandlerTestController extends Controller {
|
|||
}
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* test method for ajax redirection
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function destination() {
|
||||
$this->viewPath = 'posts';
|
||||
$this->render('index');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* RequestHandlerTestDisabledController class
|
||||
|
@ -444,6 +455,31 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$_SERVER['HTTP_CLIENTADDRESS'] = '10.0.1.2, 10.0.1.1';
|
||||
$this->assertEqual($this->RequestHandler->getClientIP(), '10.0.1.2');
|
||||
}
|
||||
/**
|
||||
* test that ajax requests involving redirects trigger requestAction instead.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testAjaxRedirectAsRequestAction() {
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
||||
$this->_init();
|
||||
$_paths = Configure::read('viewPaths');
|
||||
$testDir = array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS);
|
||||
Configure::write('viewPaths', array_merge($testDir, $_paths));
|
||||
|
||||
$this->Controller->RequestHandler = new NoStopRequestHandler($this);
|
||||
$this->Controller->RequestHandler->expectOnce('_stop');
|
||||
|
||||
ob_start();
|
||||
$this->Controller->RequestHandler->beforeRedirect(
|
||||
$this->Controller, array('controller' => 'request_handler_test', 'action' => 'destination')
|
||||
);
|
||||
$result = ob_get_clean();
|
||||
$this->assertPattern('/posts index/', $result, 'RequestAction redirect failed.');
|
||||
|
||||
Configure::write('viewPaths', $_paths);
|
||||
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||
}
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
|
|
|
@ -496,13 +496,19 @@ class ControllerTest extends CakeTestCase {
|
|||
|
||||
$Controller->passedArgs = array('sort' => 'NotExisting.field', 'direction' => 'desc');
|
||||
$results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id');
|
||||
$this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1);
|
||||
$this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1, 'Invalid field in query %s');
|
||||
$this->assertEqual($results, array(1, 2, 3));
|
||||
|
||||
$Controller->passedArgs = array('sort' => 'ControllerPost.author_id', 'direction' => 'allYourBase');
|
||||
$results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id');
|
||||
$this->assertEqual($Controller->ControllerPost->lastQuery['order'][0], array('ControllerPost.author_id' => 'asc'));
|
||||
$this->assertEqual($results, array(1, 3, 2));
|
||||
|
||||
$Controller->passedArgs = array('page' => '1 " onclick="alert(\'xss\');">');
|
||||
$Controller->paginate = array('limit' => 1);
|
||||
$Controller->paginate('ControllerPost');
|
||||
$this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1, 'XSS exploit opened %s');
|
||||
$this->assertIdentical($Controller->params['paging']['ControllerPost']['options']['page'], 1, 'XSS exploit opened %s');
|
||||
}
|
||||
/**
|
||||
* testPaginateExtraParams method
|
||||
|
@ -851,7 +857,20 @@ class ControllerTest extends CakeTestCase {
|
|||
|
||||
$this->assertTrue(isset($TestController->ControllerPost));
|
||||
$this->assertTrue(isset($TestController->ControllerComment));
|
||||
}
|
||||
/**
|
||||
* Ensure that __mergeVars is not being greedy and merging with
|
||||
* AppController when you make an instance of Controller
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testMergeVarsNotGreedy() {
|
||||
$Controller =& new Controller();
|
||||
$Controller->components = array();
|
||||
$Controller->uses = array();
|
||||
$Controller->constructClasses();
|
||||
|
||||
$this->assertTrue(isset($Controller->Session));
|
||||
}
|
||||
/**
|
||||
* testReferer method
|
||||
|
|
|
@ -258,7 +258,19 @@ class TestErrorHandlerTest extends CakeTestCase {
|
|||
$TestErrorHandler = new TestErrorHandler('error404', array('message' => 'Page not found', 'url' => '/test_error'));
|
||||
$result = ob_get_clean();
|
||||
$this->assertPattern('/<h2>Not Found<\/h2>/', $result);
|
||||
$this->assertPattern("/<strong>'\/test_error'<\/strong>/", $result);
|
||||
$this->assertPattern("/<strong>'\/test_error'<\/strong>/", $result);
|
||||
|
||||
ob_start();
|
||||
$TestErrorHandler =& new TestErrorHandler('error404', array('message' => 'Page not found'));
|
||||
ob_get_clean();
|
||||
ob_start();
|
||||
$TestErrorHandler->error404(array(
|
||||
'url' => 'pages/<span id=333>pink</span></id><script>document.body.style.background = t=document.getElementById(333).innerHTML;window.alert(t);</script>',
|
||||
'message' => 'Page not found'
|
||||
));
|
||||
$result = ob_get_clean();
|
||||
$this->assertNoPattern('#<script>#', $result);
|
||||
$this->assertNoPattern('#</script>#', $result);
|
||||
}
|
||||
/**
|
||||
* testMissingController method
|
||||
|
|
|
@ -113,7 +113,7 @@ class HttpSocketTest extends CakeTestCase {
|
|||
, 'port' => 23
|
||||
),
|
||||
'auth' => array(
|
||||
'method' => 'basic'
|
||||
'method' => 'Basic'
|
||||
, 'user' => 'bob'
|
||||
, 'pass' => 'secret'
|
||||
),
|
||||
|
@ -142,7 +142,7 @@ class HttpSocketTest extends CakeTestCase {
|
|||
, 'port' => 80
|
||||
),
|
||||
'auth' => array(
|
||||
'method' => 'basic'
|
||||
'method' => 'Basic'
|
||||
, 'user' => null
|
||||
, 'pass' => null
|
||||
),
|
||||
|
@ -187,7 +187,7 @@ class HttpSocketTest extends CakeTestCase {
|
|||
, 'port' => 80,
|
||||
)
|
||||
, 'auth' => array(
|
||||
'method' => 'basic'
|
||||
'method' => 'Basic'
|
||||
,'user' => null
|
||||
,'pass' => null
|
||||
),
|
||||
|
@ -207,7 +207,7 @@ class HttpSocketTest extends CakeTestCase {
|
|||
, 'fragment' => null
|
||||
)
|
||||
, 'auth' => array(
|
||||
'method' => 'basic'
|
||||
'method' => 'Basic'
|
||||
, 'user' => null
|
||||
, 'pass' => null
|
||||
)
|
||||
|
@ -401,8 +401,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
$this->Socket->reset();
|
||||
$serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>This is a cookie test!</h1>";
|
||||
unset($this->Socket->_mock->_actions->_at['read']);
|
||||
unset($this->Socket->_mock->_return_sequence['read']);
|
||||
$this->Socket->_mock->_call_counts['read'] = 0;
|
||||
$this->Socket->setReturnValueAt(0, 'read', $serverResponse);
|
||||
|
||||
$this->Socket->connected = true;
|
||||
$this->Socket->request($request);
|
||||
$result = $this->Socket->response['cookies'];
|
||||
|
|
|
@ -2469,6 +2469,21 @@ class I18nTest extends CakeTestCase {
|
|||
$expected = 'this is a "quoted string" (translated)';
|
||||
$this->assertEqual(__('this is a "quoted string"', true), $expected);
|
||||
}
|
||||
function testFloatValue() {
|
||||
Configure::write('Config.language', 'rule_9_po');
|
||||
|
||||
$result = __n('%d = 1', '%d = 0 or > 1', (float)1, true);
|
||||
$expected = '%d is 1 (translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = __n('%d = 1', '%d = 0 or > 1', (float)2, true);
|
||||
$expected = "%d ends in 2-4, not 12-14 (translated)";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = __n('%d = 1', '%d = 0 or > 1', (float)5, true);
|
||||
$expected = "%d everything else (translated)";
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* Singular method
|
||||
*
|
||||
|
@ -2488,7 +2503,7 @@ class I18nTest extends CakeTestCase {
|
|||
function __domainPlural($domain = 'test_plugin') {
|
||||
$plurals = array();
|
||||
for ($number = 0; $number <= 25; $number++) {
|
||||
$plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', $number, true), $number );
|
||||
$plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, true), (float)$number );
|
||||
}
|
||||
return $plurals;
|
||||
}
|
||||
|
@ -2511,7 +2526,7 @@ class I18nTest extends CakeTestCase {
|
|||
function __plural() {
|
||||
$plurals = array();
|
||||
for ($number = 0; $number <= 25; $number++) {
|
||||
$plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', $number, true), $number );
|
||||
$plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number, true), (float)$number );
|
||||
}
|
||||
return $plurals;
|
||||
}
|
||||
|
@ -2534,7 +2549,7 @@ class I18nTest extends CakeTestCase {
|
|||
function __pluralFromCore() {
|
||||
$plurals = array();
|
||||
for ($number = 0; $number <= 25; $number++) {
|
||||
$plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', $number, true), $number );
|
||||
$plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number, true), (float)$number );
|
||||
}
|
||||
return $plurals;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,10 @@ class InflectorTest extends CakeTestCase {
|
|||
$this->assertEqual(Inflector::singularize('knives'), 'knife');
|
||||
$this->assertEqual(Inflector::singularize('wolves'), 'wolf');
|
||||
$this->assertEqual(Inflector::singularize('shelves'), 'shelf');
|
||||
$this->assertEqual(Inflector::singularize('taxis'), 'taxi');
|
||||
$this->assertEqual(Inflector::singularize('taxes'), 'tax');
|
||||
$this->assertEqual(Inflector::singularize('faxes'), 'fax');
|
||||
$this->assertEqual(Inflector::singularize('waxes'), 'wax');
|
||||
$this->assertEqual(Inflector::singularize(''), '');
|
||||
}
|
||||
/**
|
||||
|
@ -143,6 +147,7 @@ class InflectorTest extends CakeTestCase {
|
|||
$this->assertEqual(Inflector::pluralize('person'), 'people');
|
||||
$this->assertEqual(Inflector::pluralize('people'), 'people');
|
||||
$this->assertEqual(Inflector::pluralize('glove'), 'gloves');
|
||||
$this->assertEqual(Inflector::pluralize('crisis'), 'crises');
|
||||
$this->assertEqual(Inflector::pluralize(''), '');
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -375,8 +375,11 @@ class BehaviorTest extends CakeTestCase {
|
|||
$this->assertIdentical($Apple->Sample->Behaviors->attached(), array('Test'));
|
||||
$this->assertEqual($Apple->Sample->Behaviors->Test->settings['Sample'], array('beforeFind' => 'on', 'afterFind' => 'off', 'key2' => 'value2'));
|
||||
|
||||
$this->assertEqual(array_keys($Apple->Behaviors->Test->settings), array('Apple'));
|
||||
$this->assertEqual(array_keys($Apple->Sample->Behaviors->Test->settings), array('Sample'));
|
||||
$this->assertEqual(array_keys($Apple->Behaviors->Test->settings), array('Apple', 'Sample'));
|
||||
$this->assertIdentical(
|
||||
$Apple->Sample->Behaviors->Test->settings,
|
||||
$Apple->Behaviors->Test->settings
|
||||
);
|
||||
$this->assertNotIdentical($Apple->Behaviors->Test->settings['Apple'], $Apple->Sample->Behaviors->Test->settings['Sample']);
|
||||
|
||||
$Apple->Behaviors->attach('Test', array('key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off'));
|
||||
|
@ -398,14 +401,20 @@ class BehaviorTest extends CakeTestCase {
|
|||
$this->assertFalse($Apple->Behaviors->attach('NoSuchBehavior'));
|
||||
|
||||
$Apple->Behaviors->attach('Plugin.Test', array('key' => 'new value'));
|
||||
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], array('beforeFind' => 'off', 'afterFind' => 'off', 'key' => 'new value', 'key2' => 'value2', 'key3' => 'value3'));
|
||||
$expected = array(
|
||||
'beforeFind' => 'off', 'afterFind' => 'off', 'key' => 'new value',
|
||||
'key2' => 'value2', 'key3' => 'value3'
|
||||
);
|
||||
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], $expected);
|
||||
|
||||
$current = $Apple->Behaviors->Test->settings['Apple'];
|
||||
$expected = array_merge($current, array('mangle' => 'trigger mangled'));
|
||||
$Apple->Behaviors->attach('Test', array('mangle' => 'trigger'));
|
||||
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], $expected);
|
||||
|
||||
$Apple->Behaviors->attach('Test');
|
||||
$expected = array_merge($current, array('mangle' => 'trigger mangled mangled'));
|
||||
|
||||
$this->assertEqual($Apple->Behaviors->Test->settings['Apple'], $expected);
|
||||
$Apple->Behaviors->attach('Test', array('mangle' => 'trigger'));
|
||||
$expected = array_merge($current, array('mangle' => 'trigger mangled'));
|
||||
|
|
|
@ -64,6 +64,32 @@ class TranslateTest extends CakeTestCase {
|
|||
function endTest() {
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
/**
|
||||
* testTranslateModel method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testTranslateModel() {
|
||||
$TestModel =& new Tag();
|
||||
$TestModel->translateTable = 'another_i18n';
|
||||
$TestModel->Behaviors->attach('Translate', array('title'));
|
||||
$this->assertEqual($TestModel->translateModel()->name, 'I18nModel');
|
||||
$this->assertEqual($TestModel->translateModel()->useTable, 'another_i18n');
|
||||
|
||||
$TestModel =& new User();
|
||||
$TestModel->Behaviors->attach('Translate', array('title'));
|
||||
$this->assertEqual($TestModel->translateModel()->name, 'I18nModel');
|
||||
$this->assertEqual($TestModel->translateModel()->useTable, 'i18n');
|
||||
|
||||
$TestModel =& new TranslatedArticle();
|
||||
$this->assertEqual($TestModel->translateModel()->name, 'TranslateArticleModel');
|
||||
$this->assertEqual($TestModel->translateModel()->useTable, 'article_i18n');
|
||||
|
||||
$TestModel =& new TranslatedItem();
|
||||
$this->assertEqual($TestModel->translateModel()->name, 'TranslateTestModel');
|
||||
$this->assertEqual($TestModel->translateModel()->useTable, 'i18n');
|
||||
}
|
||||
/**
|
||||
* testLocaleFalsePlain method
|
||||
*
|
||||
|
@ -651,7 +677,7 @@ class TranslateTest extends CakeTestCase {
|
|||
$this->loadFixtures('Translate', 'TranslatedItem');
|
||||
|
||||
$TestModel =& new TranslatedItem();
|
||||
$Behavior = $TestModel->Behaviors->Translate;
|
||||
$Behavior =& $this->Model->Behaviors->Translate;
|
||||
|
||||
$TestModel->unbindTranslation();
|
||||
$translations = array('title' => 'Title', 'content' => 'Content');
|
||||
|
|
|
@ -2404,12 +2404,10 @@ class DboSourceTest extends CakeTestCase {
|
|||
$expected = " WHERE `client_id` > 20";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->conditions(array(
|
||||
'OR' => array(
|
||||
array('User.user' => 'mariano'),
|
||||
array('User.user' => 'nate')
|
||||
)
|
||||
));
|
||||
$result = $this->testDb->conditions(array('OR' => array(
|
||||
array('User.user' => 'mariano'),
|
||||
array('User.user' => 'nate')
|
||||
)));
|
||||
|
||||
$expected = " WHERE ((`User`.`user` = 'mariano') OR (`User`.`user` = 'nate'))";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
@ -2545,6 +2543,12 @@ class DboSourceTest extends CakeTestCase {
|
|||
));
|
||||
$expected = ' WHERE ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN 65 AND 90';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->conditions(array('or' => array(
|
||||
'? BETWEEN Model.field1 AND Model.field2' => '2009-03-04'
|
||||
)));
|
||||
$expected = " WHERE '2009-03-04' BETWEEN Model.field1 AND Model.field2";
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testArrayConditionsParsingComplexKeys method
|
||||
|
@ -2717,8 +2721,13 @@ class DboSourceTest extends CakeTestCase {
|
|||
$expected = array('count(*)', '`TestModel`.`name`');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->fields($this->Model, null, 'field1, field2, field3, count(*), name');
|
||||
$expected = array('`TestModel`.`field1`', '`TestModel`.`field2`', '`TestModel`.`field3`', 'count(*)', '`TestModel`.`name`');
|
||||
$result = $this->testDb->fields(
|
||||
$this->Model, null, 'field1, field2, field3, count(*), name'
|
||||
);
|
||||
$expected = array(
|
||||
'`TestModel`.`field1`', '`TestModel`.`field2`',
|
||||
'`TestModel`.`field3`', 'count(*)', '`TestModel`.`name`'
|
||||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->fields($this->Model, null, array('dayofyear(now())'));
|
||||
|
@ -2734,8 +2743,24 @@ class DboSourceTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->fields($this->Model, null, array('field AS AnotherName'));
|
||||
$expected = array('`field` AS `AnotherName`');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->fields($this->Model, null, array(
|
||||
'TestModel.field AS AnotherName'
|
||||
));
|
||||
$expected = array('`TestModel`.`field` AS `AnotherName`');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->fields($this->Model, 'Foo', array(
|
||||
'id', 'title', '(user_count + discussion_count + post_count) AS score'
|
||||
));
|
||||
$expected = array(
|
||||
'`Foo`.`id`',
|
||||
'`Foo`.`title`',
|
||||
'(user_count + discussion_count + post_count) AS `score`'
|
||||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testMergeAssociations method
|
||||
|
@ -2744,40 +2769,44 @@ class DboSourceTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testMergeAssociations() {
|
||||
$data = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
'Topic' => array(
|
||||
array('id' => '1', 'topic' => 'Topic', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')
|
||||
)
|
||||
);
|
||||
$data = array('Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article',
|
||||
'body' => 'First Article Body', 'published' => 'Y',
|
||||
'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
));
|
||||
$merge = array('Topic' => array(array(
|
||||
'id' => '1', 'topic' => 'Topic', 'created' => '2007-03-17 01:16:23',
|
||||
'updated' => '2007-03-17 01:18:31'
|
||||
)));
|
||||
$expected = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article',
|
||||
'body' => 'First Article Body', 'published' => 'Y',
|
||||
'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Topic' => array(
|
||||
'id' => '1', 'topic' => 'Topic', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
'id' => '1', 'topic' => 'Topic', 'created' => '2007-03-17 01:16:23',
|
||||
'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Topic', 'hasOne');
|
||||
$this->assertEqual($data, $expected);
|
||||
|
||||
$data = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
'User2' => array(
|
||||
array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')
|
||||
)
|
||||
);
|
||||
$data = array('Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article',
|
||||
'body' => 'First Article Body', 'published' => 'Y',
|
||||
'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
));
|
||||
$merge = array('User2' => array(array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
|
||||
'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)));
|
||||
|
||||
$expected = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article',
|
||||
'body' => 'First Article Body', 'published' => 'Y',
|
||||
'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
|
@ -3106,6 +3135,13 @@ class DboSourceTest extends CakeTestCase {
|
|||
'fields' => null, 'order' => null, 'recursive' => null
|
||||
));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->query('findByFindBy', array('value'), $this->Model);
|
||||
$expected = array('first', array(
|
||||
'conditions' => array('TestModel.find_by' => 'value'),
|
||||
'fields' => null, 'order' => null, 'recursive' => null
|
||||
));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->query('findAllByFieldName', array('value'), $this->Model);
|
||||
$expected = array('all', array(
|
||||
|
@ -3394,6 +3430,20 @@ class DboSourceTest extends CakeTestCase {
|
|||
$expected = '`int_field` int(11) NOT NULL';
|
||||
$this->assertTrue($result, $expected);
|
||||
}
|
||||
/**
|
||||
* test hasAny()
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testHasAny() {
|
||||
$this->testDb->hasAny($this->Model, array());
|
||||
$expected = 'SELECT COUNT(`TestModel`.`id`) AS count FROM `test_models` AS `TestModel` WHERE 1 = 1';
|
||||
$this->assertEqual($this->testDb->simulated[0], $expected);
|
||||
|
||||
$this->testDb->hasAny($this->Model, array('TestModel.name' => 'harry'));
|
||||
$expected = "SELECT COUNT(`TestModel`.`id`) AS count FROM `test_models` AS `TestModel` WHERE `TestModel`.`name` = 'harry'";
|
||||
$this->assertEqual($this->testDb->simulated[1], $expected);
|
||||
}
|
||||
/**
|
||||
* testIntrospectType method
|
||||
*
|
||||
|
|
|
@ -576,6 +576,12 @@ class ModelTest extends CakeTestCase {
|
|||
'JoinThing' => array('doomed' => '1', 'something_id' => '1', 'something_else_id' => '2'))));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$expected = $TestModel->findById(1);
|
||||
$TestModel->set($expected);
|
||||
$TestModel->save();
|
||||
$result = $TestModel->findById(1);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$TestModel->hasAndBelongsToMany['SomethingElse']['unique'] = false;
|
||||
$TestModel->create(array(
|
||||
'Something' => array('id' => 1),
|
||||
|
@ -1565,8 +1571,6 @@ class ModelTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testUpdateWithCalculation() {
|
||||
Configure::write('foo', true);
|
||||
|
||||
$this->loadFixtures('DataTest');
|
||||
$model =& new DataTest();
|
||||
$result = $model->saveAll(array(
|
||||
|
@ -3275,6 +3279,44 @@ class ModelTest extends CakeTestCase {
|
|||
$this->assertEqual(count($result['Comment']), 1);
|
||||
$this->assertEqual(count($result['Comment'][0]['comment']['Article comment']), 1);
|
||||
}
|
||||
|
||||
function testSaveAllHabtmWithExtraJoinTableFields() {
|
||||
$this->loadFixtures('Something', 'SomethingElse', 'JoinThing');
|
||||
|
||||
$data = array(
|
||||
'Something' => array(
|
||||
'id' => 4,
|
||||
'title' => 'Extra Fields',
|
||||
'body' => 'Extra Fields Body',
|
||||
'published' => '1'
|
||||
),
|
||||
'SomethingElse' => array(
|
||||
array('something_else_id' => 1, 'doomed' => '1'),
|
||||
array('something_else_id' => 2, 'doomed' => '0'),
|
||||
array('something_else_id' => 3, 'doomed' => '1')
|
||||
)
|
||||
);
|
||||
|
||||
$Something =& new Something();
|
||||
$result = $Something->saveAll($data);
|
||||
$this->assertTrue($result);
|
||||
$result = $Something->read();
|
||||
|
||||
$this->assertEqual(count($result['SomethingElse']), 3);
|
||||
$this->assertTrue(Set::matches('/Something[id=4]', $result));
|
||||
|
||||
$this->assertTrue(Set::matches('/SomethingElse[id=1]', $result));
|
||||
$this->assertTrue(Set::matches('/SomethingElse[id=1]/JoinThing[something_else_id=1]', $result));
|
||||
$this->assertTrue(Set::matches('/SomethingElse[id=1]/JoinThing[doomed=1]', $result));
|
||||
|
||||
$this->assertTrue(Set::matches('/SomethingElse[id=2]', $result));
|
||||
$this->assertTrue(Set::matches('/SomethingElse[id=2]/JoinThing[something_else_id=2]', $result));
|
||||
$this->assertTrue(Set::matches('/SomethingElse[id=2]/JoinThing[doomed=0]', $result));
|
||||
|
||||
$this->assertTrue(Set::matches('/SomethingElse[id=3]', $result));
|
||||
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[something_else_id=3]', $result));
|
||||
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[doomed=1]', $result));
|
||||
}
|
||||
|
||||
/**
|
||||
* testSaveAllHasOne method
|
||||
|
|
|
@ -538,6 +538,9 @@ class ObjectTest extends CakeTestCase {
|
|||
$result = $this->object->requestAction(array('controller'=>'request_action', 'action'=>'paginate_request_action'));
|
||||
$this->assertTrue($result);
|
||||
|
||||
$result = $this->object->requestAction(array('controller'=>'request_action', 'action'=>'paginate_request_action'), array('pass' => array(5), 'named' => array('param' => 'value')));
|
||||
$this->assertTrue($result);
|
||||
|
||||
Configure::write('controllerPaths', $_back['controller']);
|
||||
Configure::write('viewPaths', $_back['view']);
|
||||
Configure::write('pluginPaths', $_back['plugin']);
|
||||
|
@ -556,11 +559,11 @@ class ObjectTest extends CakeTestCase {
|
|||
$this->assertEqual($result['action'], 'params_pass');
|
||||
$this->assertEqual($result['form'], array());
|
||||
$this->assertEqual($result['plugin'], null);
|
||||
|
||||
|
||||
$result = $this->object->requestAction('/request_action/params_pass/sort:desc/limit:5');
|
||||
$expected = array('sort' => 'desc', 'limit' => 5,);
|
||||
$this->assertEqual($result['named'], $expected);
|
||||
|
||||
|
||||
$result = $this->object->requestAction(array('controller' => 'request_action', 'action' => 'params_pass'), array('named' => array('sort' => 'desc', 'limit' => 5)));
|
||||
$this->assertEqual($result['named'], $expected);
|
||||
}
|
||||
|
@ -580,7 +583,7 @@ class ObjectTest extends CakeTestCase {
|
|||
$expected = array();
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->object->requestAction(array('controller' => 'request_action', 'action' => 'post_pass', 'data' => $_POST['data']));
|
||||
$result = $this->object->requestAction(array('controller' => 'request_action', 'action' => 'post_pass'), array('data' => $_POST['data']));
|
||||
$expected = $_POST['data'];
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
|
|
|
@ -659,14 +659,14 @@ class RouterTest extends CakeTestCase {
|
|||
|
||||
Router::reload();
|
||||
Router::setRequestInfo(array(
|
||||
array ('plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'admin_edit', 'pass' =>
|
||||
array (0 => '6'), 'prefix' => 'admin', 'admin' => true, 'form' => array (), 'url' =>
|
||||
array ('url' => 'admin/shows/show_tickets/edit/6')),
|
||||
array ('plugin' => NULL, 'controller' => NULL, 'action' => NULL, 'base' => '', 'here' => '/admin/shows/show_tickets/edit/6', 'webroot' => '/')));
|
||||
array('plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'admin_edit', 'pass' =>
|
||||
array(0 => '6'), 'prefix' => 'admin', 'admin' => true, 'form' => array(), 'url' =>
|
||||
array('url' => 'admin/shows/show_tickets/edit/6')),
|
||||
array('plugin' => NULL, 'controller' => NULL, 'action' => NULL, 'base' => '', 'here' => '/admin/shows/show_tickets/edit/6', 'webroot' => '/')));
|
||||
|
||||
Router::parse('/');
|
||||
|
||||
$result = Router::url(array ( 'plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'edit', 'id' => '6', 'admin' => true, 'prefix' => 'admin', ));
|
||||
$result = Router::url(array('plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'edit', 'id' => '6', 'admin' => true, 'prefix' => 'admin', ));
|
||||
$expected = '/admin/shows/show_tickets/edit/6';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
@ -740,7 +740,28 @@ class RouterTest extends CakeTestCase {
|
|||
));
|
||||
|
||||
$this->assertEqual(Router::url('read/1'), '/base/test/controller/read/1');
|
||||
|
||||
Router::reload();
|
||||
|
||||
Router::connect('/:lang/:plugin/:controller/*', array(), array('action' => 'index'));
|
||||
|
||||
Router::setRequestInfo(array(
|
||||
array(
|
||||
'lang' => 'en',
|
||||
'plugin' => 'shows', 'controller' => 'shows', 'action' => 'index', 'pass' =>
|
||||
array(), 'form' => array(), 'url' =>
|
||||
array('url' => 'en/shows/')),
|
||||
array('plugin' => NULL, 'controller' => NULL, 'action' => NULL, 'base' => '',
|
||||
'here' => '/en/shows/', 'webroot' => '/')));
|
||||
|
||||
Router::parse('/en/shows/');
|
||||
|
||||
$result = Router::url(array(
|
||||
'lang' => 'en',
|
||||
'controller' => 'shows', 'action' => 'index', 'page' => '1',
|
||||
));
|
||||
$expected = '/en/shows/page:1';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testUrlParsing method
|
||||
|
|
|
@ -435,10 +435,6 @@ class SetTest extends CakeTestCase {
|
|||
$result = Set::extract('/User/id', $nonZero);
|
||||
$this->assertEqual($result, $expected, 'Failed non zero array key extract');
|
||||
|
||||
// $expected = array(
|
||||
// array('id' => 1), array('id' => 2), array('id' => 3), array('id' => 4), array('id' => 5)
|
||||
// );
|
||||
|
||||
$expected = array(1, 2, 3, 4, 5);
|
||||
$this->assertEqual(Set::extract('/User/id', $a), $expected);
|
||||
$this->assertEqual(Set::extract('/User/id', $nonSequential), $expected);
|
||||
|
@ -793,6 +789,20 @@ class SetTest extends CakeTestCase {
|
|||
),
|
||||
);
|
||||
|
||||
$r = Set::extract('/Comment/User[name=/\w+/]/..', $habtm);
|
||||
$this->assertEqual($r[0]['Comment']['User']['name'], 'bob');
|
||||
$this->assertEqual($r[1]['Comment']['User']['name'], 'tod');
|
||||
$this->assertEqual($r[2]['Comment']['User']['name'], 'dan');
|
||||
$this->assertEqual($r[3]['Comment']['User']['name'], 'dan');
|
||||
$this->assertEqual(count($r), 4);
|
||||
|
||||
$r = Set::extract('/Comment/User[name=/[a-z]+/]/..', $habtm);
|
||||
$this->assertEqual($r[0]['Comment']['User']['name'], 'bob');
|
||||
$this->assertEqual($r[1]['Comment']['User']['name'], 'tod');
|
||||
$this->assertEqual($r[2]['Comment']['User']['name'], 'dan');
|
||||
$this->assertEqual($r[3]['Comment']['User']['name'], 'dan');
|
||||
$this->assertEqual(count($r), 4);
|
||||
|
||||
$r = Set::extract('/Comment/User[name=/bob|dan/]/..', $habtm);
|
||||
$this->assertEqual($r[0]['Comment']['User']['name'], 'bob');
|
||||
$this->assertEqual($r[1]['Comment']['User']['name'], 'dan');
|
||||
|
@ -859,6 +869,108 @@ class SetTest extends CakeTestCase {
|
|||
$expected = array(array('children' => $tree[1]['children'][0]), array('children' => $tree[1]['children'][1]));
|
||||
$r = Set::extract('/Category[name=Category 2]/../children', $tree);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
$mixedKeys = array(
|
||||
'User' => array(
|
||||
0 => array(
|
||||
'id' => 4,
|
||||
'name' => 'Neo'
|
||||
),
|
||||
1 => array(
|
||||
'id' => 5,
|
||||
'name' => 'Morpheus'
|
||||
),
|
||||
'stringKey' => array()
|
||||
)
|
||||
);
|
||||
|
||||
$expected = array('Neo', 'Morpheus');
|
||||
$r = Set::extract('/User/name', $mixedKeys);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
$single = array(
|
||||
array(
|
||||
'CallType' => array(
|
||||
'name' => 'Internal Voice'
|
||||
),
|
||||
'x' => array(
|
||||
'hour' => 7
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$expected = array(7);
|
||||
$r = Set::extract('/CallType[name=Internal Voice]/../x/hour', $single);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
$multiple = array(
|
||||
array(
|
||||
'CallType' => array(
|
||||
'name' => 'Internal Voice'
|
||||
),
|
||||
'x' => array(
|
||||
'hour' => 7
|
||||
)
|
||||
),
|
||||
array(
|
||||
'CallType' => array(
|
||||
'name' => 'Internal Voice'
|
||||
),
|
||||
'x' => array(
|
||||
'hour' => 2
|
||||
)
|
||||
),
|
||||
array(
|
||||
'CallType' => array(
|
||||
'name' => 'Internal Voice'
|
||||
),
|
||||
'x' => array(
|
||||
'hour' => 1
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$expected = array(7,2,1);
|
||||
$r = Set::extract('/CallType[name=Internal Voice]/../x/hour', $multiple);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
$f = array(
|
||||
array(
|
||||
'file' => array(
|
||||
'name' => 'zipfile.zip',
|
||||
'type' => 'application/zip',
|
||||
'tmp_name' => '/tmp/php178.tmp',
|
||||
'error' => 0,
|
||||
'size' => '564647'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'file' => array(
|
||||
'name' => 'zipfile2.zip',
|
||||
'type' => 'application/x-zip-compressed',
|
||||
'tmp_name' => '/tmp/php179.tmp',
|
||||
'error' => 0,
|
||||
'size' => '354784'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'file' => array(
|
||||
'name' => 'picture.jpg',
|
||||
'type' => 'image/jpeg',
|
||||
'tmp_name' => '/tmp/php180.tmp',
|
||||
'error' => 0,
|
||||
'size' => '21324'
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(array('name' => 'zipfile2.zip','type' => 'application/x-zip-compressed','tmp_name' => '/tmp/php179.tmp','error' => 0,'size' => '354784'));
|
||||
$r = Set::extract('/file/.[type=application/x-zip-compressed]', $f);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
$expected = array(array('name' => 'zipfile.zip','type' => 'application/zip','tmp_name' => '/tmp/php178.tmp','error' => 0,'size' => '564647'));
|
||||
$r = Set::extract('/file/.[type=application/zip]', $f);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
}
|
||||
/**
|
||||
* testMatches method
|
||||
|
@ -930,6 +1042,25 @@ class SetTest extends CakeTestCase {
|
|||
$this->assertEqual(Set::extract('/Article/keep/Comment/fields', $r), array('comment', 'published'));
|
||||
$this->assertEqual(Set::extract('/Article/keep/User/fields', $r), array('user'));
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* testSetExtractReturnsEmptyArray method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSetExtractReturnsEmptyArray() {
|
||||
|
||||
$this->assertEqual(Set::extract(array(), '/Post/id'), array());
|
||||
|
||||
$this->assertEqual(Set::extract('/Post/id', array()), array());
|
||||
|
||||
$this->assertEqual(Set::extract('/Post/id', array(
|
||||
array('Post' => array('name' => 'bob')),
|
||||
array('Post' => array('name' => 'jim'))
|
||||
)), array());
|
||||
|
||||
}
|
||||
/**
|
||||
* testClassicExtract method
|
||||
|
|
|
@ -40,7 +40,8 @@ class StringTest extends CakeTestCase {
|
|||
*/
|
||||
function testUuidGeneration() {
|
||||
$result = String::uuid();
|
||||
$match = preg_match("/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/", $result);
|
||||
$pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/";
|
||||
$match = preg_match($pattern, $result);
|
||||
$this->assertTrue($match);
|
||||
}
|
||||
/**
|
||||
|
@ -52,9 +53,11 @@ class StringTest extends CakeTestCase {
|
|||
function testMultipleUuidGeneration() {
|
||||
$check = array();
|
||||
$count = mt_rand(10, 1000);
|
||||
$pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/";
|
||||
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
$result = String::uuid();
|
||||
$match = preg_match("/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/", $result);
|
||||
$match = preg_match($pattern, $result);
|
||||
$this->assertTrue($match);
|
||||
$this->assertFalse(in_array($result, $check));
|
||||
$check[] = $result;
|
||||
|
@ -179,9 +182,17 @@ class StringTest extends CakeTestCase {
|
|||
$expected = "We are of course passing.";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = String::insert(':I.am: :not.yet: passing.', array('I.am' => 'We are'), array('before' => ':', 'after' => ':', 'clean' => true));
|
||||
$result = String::insert(
|
||||
':I.am: :not.yet: passing.',
|
||||
array('I.am' => 'We are'),
|
||||
array('before' => ':', 'after' => ':', 'clean' => true)
|
||||
);
|
||||
$expected = "We are passing.";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = String::insert('?-pended result', array('Pre'));
|
||||
$expected = "Pre-pended result";
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* test Clean Insert
|
||||
|
|
|
@ -77,7 +77,28 @@ class ValidationTestCase extends CakeTestCase {
|
|||
$this->assertTrue(Validation::notEmpty('abcdefg'));
|
||||
$this->assertTrue(Validation::notEmpty('fasdf '));
|
||||
$this->assertTrue(Validation::notEmpty('fooo'.chr(243).'blabla'));
|
||||
|
||||
$this->assertTrue(Validation::notEmpty('abçďĕʑʘπй'));
|
||||
$this->assertTrue(Validation::notEmpty('José'));
|
||||
$this->assertTrue(Validation::notEmpty('é'));
|
||||
$this->assertTrue(Validation::notEmpty('π'));
|
||||
$this->assertFalse(Validation::notEmpty("\t "));
|
||||
$this->assertFalse(Validation::notEmpty(""));
|
||||
|
||||
}
|
||||
/**
|
||||
* testNotEmptyISO88591Encoding method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testNotEmptyISO88591AppEncoding() {
|
||||
Configure::write('App.encoding', 'ISO-8859-1');
|
||||
$this->assertTrue(Validation::notEmpty('abcdefg'));
|
||||
$this->assertTrue(Validation::notEmpty('fasdf '));
|
||||
$this->assertTrue(Validation::notEmpty('fooo'.chr(243).'blabla'));
|
||||
$this->assertTrue(Validation::notEmpty('abçďĕʑʘπй'));
|
||||
$this->assertTrue(Validation::notEmpty('José'));
|
||||
$this->assertTrue(Validation::notEmpty(utf8_decode('José')));
|
||||
$this->assertFalse(Validation::notEmpty("\t "));
|
||||
$this->assertFalse(Validation::notEmpty(""));
|
||||
}
|
||||
|
|
|
@ -347,6 +347,35 @@ class HelperTest extends CakeTestCase {
|
|||
$result = $this->Helper->value('Post.2.created.year');
|
||||
$this->assertEqual($result, '2008');
|
||||
}
|
||||
/**
|
||||
* Ensure HTML escaping of url params. So link addresses are valid and not exploited
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testUrlConversion() {
|
||||
$result = $this->Helper->url('/controller/action/1');
|
||||
$this->assertEqual($result, '/controller/action/1');
|
||||
|
||||
$result = $this->Helper->url('/controller/action/1?one=1&two=2');
|
||||
$this->assertEqual($result, '/controller/action/1?one=1&two=2');
|
||||
|
||||
$result = $this->Helper->url(array('controller' => 'posts', 'action' => 'index', 'page' => '1" onclick="alert(\'XSS\');"'));
|
||||
$this->assertEqual($result, "/posts/index/page:1" onclick="alert('XSS');"");
|
||||
|
||||
$result = $this->Helper->url('/controller/action/1/param:this+one+more');
|
||||
$this->assertEqual($result, '/controller/action/1/param:this+one+more');
|
||||
|
||||
$result = $this->Helper->url('/controller/action/1/param:this%20one%20more');
|
||||
$this->assertEqual($result, '/controller/action/1/param:this%20one%20more');
|
||||
|
||||
$result = $this->Helper->url('/controller/action/1/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24');
|
||||
$this->assertEqual($result, '/controller/action/1/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24');
|
||||
|
||||
$result = $this->Helper->url(array(
|
||||
'controller' => 'posts', 'action' => 'index', 'param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24'
|
||||
));
|
||||
$this->assertEqual($result, "/posts/index/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24");
|
||||
}
|
||||
/**
|
||||
* testFieldsWithSameName method
|
||||
*
|
||||
|
|
|
@ -163,7 +163,29 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
'/a'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$result = $this->Html->link('Next >', '#', array(
|
||||
'title' => 'to escape … or not escape?',
|
||||
'escape' => false
|
||||
));
|
||||
$expected = array(
|
||||
'a' => array('href' => '#', 'title' => 'to escape … or not escape?'),
|
||||
'Next >',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->link('Next >', '#', array(
|
||||
'title' => 'to escape … or not escape?',
|
||||
'escape' => true
|
||||
), false, false);
|
||||
$expected = array(
|
||||
'a' => array('href' => '#', 'title' => 'to escape &#8230; or not escape?'),
|
||||
'Next >',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->link('Original size', array(
|
||||
'controller' => 'images', 'action' => 'view', 3, '?' => array('height' => 100, 'width' => 200)
|
||||
));
|
||||
|
@ -233,8 +255,17 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
|
||||
Configure::write('Asset.timestamp', true);
|
||||
|
||||
$result = $this->Html->image('logo.gif');
|
||||
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/logo\.gif\?\d*/', 'alt' => '')));
|
||||
$result = $this->Html->image('cake.icon.gif');
|
||||
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));
|
||||
|
||||
$back = Configure::read('debug');
|
||||
Configure::write('debug', 0);
|
||||
Configure::write('Asset.timestamp', 'force');
|
||||
|
||||
$result = $this->Html->image('cake.icon.gif');
|
||||
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));
|
||||
|
||||
Configure::write('debug', $back);
|
||||
}
|
||||
/**
|
||||
* testStyle method
|
||||
|
|
|
@ -366,13 +366,18 @@ class JavascriptTest extends CakeTestCase {
|
|||
$expected = '{"title":"New thing","indexes":[5,6,7,8],"object":{"inner":{"value":1}}}';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
foreach (array('true' => true, 'false' => false, 'null' => null) as $expected => $data) {
|
||||
$result = $this->Javascript->object($data);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
if ($this->Javascript->useNative) {
|
||||
$this->Javascript->useNative = false;
|
||||
$this->testObjectGeneration();
|
||||
$this->Javascript->useNative = true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* testObjectNonNative method
|
||||
*
|
||||
* @access public
|
||||
|
@ -648,6 +653,10 @@ class JavascriptTest extends CakeTestCase {
|
|||
$result = $this->Javascript->escapeString('CakePHP: \'Rapid Development Framework\'');
|
||||
$expected = 'CakePHP: \\\'Rapid Development Framework\\\'';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Javascript->escapeString('my \\"string\\"');
|
||||
$expected = 'my \\\"string\\\"';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testAfterRender method
|
||||
|
|
|
@ -97,6 +97,11 @@ class NumberTest extends CakeTestCase {
|
|||
$result = $this->Number->currency($value, 'GBP');
|
||||
$expected = '£100,100,100.00';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->Number->currency($value, '', array('thousands' =>' ', 'after' => '€', 'decimals' => ',', 'zero' => 'Gratuit'));
|
||||
$expected = '100 100 100,00€';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
}
|
||||
/**
|
||||
* testCurrencyPositive method
|
||||
|
|
|
@ -167,6 +167,25 @@ class PaginatorTest extends CakeTestCase {
|
|||
$result = $this->Paginator->sort('Title','Article.title');
|
||||
$this->assertPattern('/\/accounts\/index\/page:1\/sort:Article.title\/direction:desc">Title<\/a>$/', $result);
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$result = $this->Paginator->sort('title');
|
||||
$this->assertPattern('/\/accounts\/index\/page:1\/sort:title\/direction:asc">Title<\/a>$/', $result);
|
||||
|
||||
}
|
||||
/**
|
||||
* testSortKey method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSortKey() {
|
||||
|
||||
$result = $this->Paginator->sortKey(null, array(
|
||||
'order' => array('Article.title' => 'desc'
|
||||
)));
|
||||
$this->assertEqual('Article.title', $result);
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* testSortAdminLinks method
|
||||
|
@ -349,29 +368,29 @@ class PaginatorTest extends CakeTestCase {
|
|||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||
$this->assertPattern('/^<a[^<>]+><< Previous<\/a>$/', $result);
|
||||
$this->assertPattern('/href="\/index\/page:1"/', $result);
|
||||
|
||||
|
||||
$result = $this->Paginator->next('Next');
|
||||
$this->assertPattern('/^<a[^<>]+>Next<\/a>$/', $result);
|
||||
$this->assertPattern('/href="\/index\/page:3"/', $result);
|
||||
|
||||
|
||||
$result = $this->Paginator->prev('<< Previous', array('escape' => true));
|
||||
$this->assertPattern('/^<a[^<>]+><< Previous<\/a>$/', $result);
|
||||
|
||||
|
||||
$result = $this->Paginator->prev('<< Previous', array('escape' => false));
|
||||
$this->assertPattern('/^<a[^<>]+><< Previous<\/a>$/', $result);
|
||||
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 1, 'current' => 1, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
|
||||
'defaults' => array(),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
);
|
||||
|
||||
|
||||
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>');
|
||||
$this->assertPattern('/^<div><strong>Disabled<\/strong><\/div>$/', $result);
|
||||
|
||||
|
||||
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => true));
|
||||
$this->assertPattern('/^<div><strong>Disabled<\/strong><\/div>$/', $result);
|
||||
|
||||
|
||||
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => false));
|
||||
$this->assertPattern('/^<div><strong>Disabled<\/strong><\/div>$/', $result);
|
||||
|
||||
|
@ -404,7 +423,7 @@ class PaginatorTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testPagingLinksNotDefaultModel
|
||||
*
|
||||
*
|
||||
* Test the creation of paging links when the non default model is used.
|
||||
*
|
||||
* @access public
|
||||
|
@ -427,7 +446,7 @@ class PaginatorTest extends CakeTestCase {
|
|||
$result = $this->Paginator->next('Next', array('model' => 'Client'));
|
||||
$this->assertPattern('/^<a[^<>]+>Next<\/a>$/', $result);
|
||||
$this->assertPattern('/href="\/index\/page:2"/', $result); // These is passed.
|
||||
|
||||
|
||||
$result = $this->Paginator->next('Next', array('model' => 'Server'), 'No Next', array('model' => 'Server'));
|
||||
$this->assertPattern('/^<div>No Next<\/div>$/', $result);
|
||||
}
|
||||
|
@ -788,6 +807,41 @@ class PaginatorTest extends CakeTestCase {
|
|||
$result = $this->Paginator->hasPage(2);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
/**
|
||||
* testWithPlugin method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testWithPlugin() {
|
||||
Router::reload();
|
||||
Router::setRequestInfo(array(
|
||||
array(
|
||||
'pass' => array(), 'named' => array(), 'prefix' => null, 'form' => array(),
|
||||
'controller' => 'magazines', 'plugin' => 'my_plugin', 'action' => 'index',
|
||||
'url' => array('ext' => 'html', 'url' => 'my_plugin/magazines')),
|
||||
array('base' => '', 'here' => '/my_plugin/magazines', 'webroot' => '/')
|
||||
));
|
||||
|
||||
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
||||
$this->assertPattern('/["\']\/my_plugin\/magazines\/index\/page:3["\']/', $result);
|
||||
|
||||
$this->Paginator->options(array('url' => array('action' => 'another_index')));
|
||||
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
||||
$this->assertPattern('/["\']\/my_plugin\/magazines\/another_index\/page:3["\']/', $result);
|
||||
|
||||
$this->Paginator->options(array('url' => array('controller' => 'issues')));
|
||||
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
||||
$this->assertPattern('/["\']\/my_plugin\/issues\/index\/page:3["\']/', $result);
|
||||
|
||||
$this->Paginator->options(array('url' => array('plugin' => null)));
|
||||
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
||||
$this->assertPattern('/["\']\/magazines\/index\/page:3["\']/', $result);
|
||||
|
||||
$this->Paginator->options(array('url' => array('plugin' => null, 'controller' => 'issues')));
|
||||
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
||||
$this->assertPattern('/["\']\/issues\/index\/page:3["\']/', $result);
|
||||
}
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
|
|
58
cake/tests/groups/console.group.php
Normal file
58
cake/tests/groups/console.group.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.groups
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
/** AllConsoleGroupTest
|
||||
*
|
||||
* This test group will run all console tests
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.groups
|
||||
*/
|
||||
/**
|
||||
* AllConsoleGroupTest class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.groups
|
||||
*/
|
||||
class AllConsoleGroupTest extends GroupTest {
|
||||
/**
|
||||
* label property
|
||||
*
|
||||
* @var string 'All core cache engines'
|
||||
* @access public
|
||||
*/
|
||||
var $label = 'All console tests';
|
||||
/**
|
||||
* AllConsoleGroupTest method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function AllConsoleGroupTest() {
|
||||
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'console');
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -223,7 +223,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
* * @param array $params Additional parameters as sent by testAction().
|
||||
*/
|
||||
function endController(&$controller, $params = array()) {
|
||||
if (isset($this->db) && isset($this->_actionFixtures) && !empty($this->_actionFixtures)) {
|
||||
if (isset($this->db) && isset($this->_actionFixtures) && !empty($this->_actionFixtures) && $this->dropTables) {
|
||||
foreach ($this->_actionFixtures as $fixture) {
|
||||
$fixture->drop($this->db);
|
||||
}
|
||||
|
@ -232,13 +232,20 @@ class CakeTestCase extends UnitTestCase {
|
|||
/**
|
||||
* Executes a Cake URL, and can get (depending on the $params['return'] value):
|
||||
*
|
||||
* 1. 'result': Whatever the action returns (and also specifies $this->params['requested'] for controller)
|
||||
* 2. 'view': The rendered view, without the layout
|
||||
* 3. 'contents': The rendered view, within the layout.
|
||||
* 4. 'vars': the view vars
|
||||
*
|
||||
* @param string $url Cake URL to execute (e.g: /articles/view/455)
|
||||
* @param array $params Parameters, or simply a string of what to return
|
||||
* Params:
|
||||
* - 'return' has several possible values:
|
||||
* 1. 'result': Whatever the action returns (and also specifies $this->params['requested'] for controller)
|
||||
* 2. 'view': The rendered view, without the layout
|
||||
* 3. 'contents': The rendered view, within the layout.
|
||||
* 4. 'vars': the view vars
|
||||
*
|
||||
* - 'fixturize' - Set to true if you want to copy model data from 'connection' to the test_suite connection
|
||||
* - 'data' - The data you want to insert into $this->data in the controller.
|
||||
* - 'connection' - Which connection to use in conjunction with fixturize (defaults to 'default')
|
||||
* - 'method' - What type of HTTP method to simulate (defaults to post)
|
||||
*
|
||||
* @param string $url Cake URL to execute (e.g: /articles/view/455)
|
||||
* @param mixed $params Parameters (see above), or simply a string of what to return
|
||||
* @return mixed Whatever is returned depending of requested result
|
||||
* @access public
|
||||
*/
|
||||
|
@ -254,7 +261,6 @@ class CakeTestCase extends UnitTestCase {
|
|||
if (is_string($params)) {
|
||||
$params = array('return' => $params);
|
||||
}
|
||||
|
||||
$params = array_merge($default, $params);
|
||||
|
||||
$toSave = array(
|
||||
|
@ -408,7 +414,9 @@ class CakeTestCase extends UnitTestCase {
|
|||
* @access public
|
||||
*/
|
||||
function after($method) {
|
||||
if (isset($this->_fixtures) && isset($this->db) && !in_array(strtolower($method), array('start', 'end'))) {
|
||||
$isTestMethod = !in_array(strtolower($method), array('start', 'end'));
|
||||
|
||||
if (isset($this->_fixtures) && isset($this->db) && $isTestMethod) {
|
||||
foreach ($this->_fixtures as $fixture) {
|
||||
$fixture->truncate($this->db);
|
||||
}
|
||||
|
@ -433,14 +441,17 @@ class CakeTestCase extends UnitTestCase {
|
|||
* @access public
|
||||
*/
|
||||
function getTests() {
|
||||
$methods = array_diff(parent::getTests(), array('testAction', 'testaction'));
|
||||
$methods = array_merge(array_merge(array('start', 'startCase'), $methods), array('endCase', 'end'));
|
||||
return $methods;
|
||||
return array_merge(
|
||||
array('start', 'startCase'),
|
||||
array_diff(parent::getTests(), array('testAction', 'testaction')),
|
||||
array('endCase', 'end')
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Chooses which fixtures to load for a given test
|
||||
*
|
||||
* @param string $fixture Each parameter is a model name that corresponds to a fixture, i.e. 'Post', 'Author', etc.
|
||||
* @param string $fixture Each parameter is a model name that corresponds to a
|
||||
* fixture, i.e. 'Post', 'Author', etc.
|
||||
* @access public
|
||||
* @see CakeTestCase::$autoFixtures
|
||||
*/
|
||||
|
@ -453,14 +464,16 @@ class CakeTestCase extends UnitTestCase {
|
|||
$fixture->truncate($this->db);
|
||||
$fixture->insert($this->db);
|
||||
} else {
|
||||
trigger_error("Non-existent fixture class {$class} referenced in test", E_USER_WARNING);
|
||||
trigger_error("Referenced fixture class {$class} not found", E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Takes an array $expected and generates a regex from it to match the provided $string. Samples for $expected:
|
||||
* Takes an array $expected and generates a regex from it to match the provided $string.
|
||||
* Samples for $expected:
|
||||
*
|
||||
* Checks for an input tag with a name attribute (contains any non-empty value) and an id attribute that contains 'my-input':
|
||||
* Checks for an input tag with a name attribute (contains any non-empty value) and an id
|
||||
* attribute that contains 'my-input':
|
||||
* array('input' => array('name', 'id' => 'my-input'))
|
||||
*
|
||||
* Checks for two p elements with some text in them:
|
||||
|
@ -473,15 +486,15 @@ class CakeTestCase extends UnitTestCase {
|
|||
* '/p'
|
||||
* )
|
||||
*
|
||||
* You can also specify a pattern expression as part of the attribute values, or the tag being defined,
|
||||
* if you prepend the value with preg: and enclose it with slashes, like so:
|
||||
* You can also specify a pattern expression as part of the attribute values, or the tag
|
||||
* being defined, if you prepend the value with preg: and enclose it with slashes, like so:
|
||||
* array(
|
||||
* array('input' => array('name', 'id' => 'preg:/FieldName\d+/')),
|
||||
* 'preg:/My\s+field/'
|
||||
* )
|
||||
*
|
||||
* Important: This function is very forgiving about whitespace and also accepts any permutation of attribute order.
|
||||
* It will also allow whitespaces between specified tags.
|
||||
* Important: This function is very forgiving about whitespace and also accepts any
|
||||
* permutation of attribute order. It will also allow whitespaces between specified tags.
|
||||
*
|
||||
* @param string $string An HTML/XHTML/XML string
|
||||
* @param array $expected An array, see above
|
||||
|
@ -504,8 +517,11 @@ class CakeTestCase extends UnitTestCase {
|
|||
if (is_string($tags) && $tags{0} == '<') {
|
||||
$tags = array(substr($tags, 1) => array());
|
||||
} elseif (is_string($tags)) {
|
||||
if (preg_match('/^\*?\//', $tags, $match)) {
|
||||
$tagsTrimmed = preg_replace('/\s+/m', '', $tags);
|
||||
|
||||
if (preg_match('/^\*?\//', $tags, $match) && $tagsTrimmed !== '//') {
|
||||
$prefix = array(null, null);
|
||||
|
||||
if ($match[0] == '*/') {
|
||||
$prefix = array('Anything, ', '.*?');
|
||||
}
|
||||
|
@ -552,7 +568,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
$attr = $val;
|
||||
$val = '.+?';
|
||||
$explanations[] = sprintf('Attribute "%s" present', $attr);
|
||||
} else if (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
|
||||
} elseif (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
|
||||
$quotes = '"?';
|
||||
$val = $matches[1];
|
||||
$explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
|
||||
|
|
|
@ -277,6 +277,8 @@ class TestManager {
|
|||
}
|
||||
|
||||
$files = glob($directory . DS . '*');
|
||||
$files = $files ? $files : array();
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_dir($file)) {
|
||||
$fileList = array_merge($fileList, $this->_getRecursiveFileList($file, $fileTestFunction));
|
||||
|
|
Loading…
Reference in a new issue