mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '2.1' of github.com:cakephp/cakephp into 2.1
This commit is contained in:
commit
ece8b57809
51 changed files with 547 additions and 167 deletions
|
@ -24,7 +24,7 @@ App::uses('Debugger', 'Utility');
|
||||||
<p>For updates and important announcements, visit http://cakefest.org</p>
|
<p>For updates and important announcements, visit http://cakefest.org</p>
|
||||||
</iframe>
|
</iframe>
|
||||||
<h2><?php echo __d('cake_dev', 'Release Notes for CakePHP %s.', Configure::version()); ?></h2>
|
<h2><?php echo __d('cake_dev', 'Release Notes for CakePHP %s.', Configure::version()); ?></h2>
|
||||||
<a href="http://cakephp.org/changelogs/2.0.2"><?php __d('cake_dev', 'Read the changelog'); ?> </a>
|
<a href="http://cakephp.org/changelogs/2.0.3"><?php __d('cake_dev', 'Read the changelog'); ?> </a>
|
||||||
<?php
|
<?php
|
||||||
if (Configure::read('debug') > 0):
|
if (Configure::read('debug') > 0):
|
||||||
Debugger::checkSecurityKeys();
|
Debugger::checkSecurityKeys();
|
||||||
|
|
|
@ -81,7 +81,8 @@ class CommandListShell extends Shell {
|
||||||
protected function _getShellList() {
|
protected function _getShellList() {
|
||||||
$shellList = array();
|
$shellList = array();
|
||||||
|
|
||||||
$shells = App::objects('file', App::core('Console/Command'));
|
$corePath = App::core('Console/Command');
|
||||||
|
$shells = App::objects('file', $corePath[0]);
|
||||||
$shellList = $this->_appendShells('CORE', $shells, $shellList);
|
$shellList = $this->_appendShells('CORE', $shells, $shellList);
|
||||||
|
|
||||||
$appShells = App::objects('Console/Command', null, false);
|
$appShells = App::objects('Console/Command', null, false);
|
||||||
|
|
|
@ -424,12 +424,8 @@ class AuthComponent extends Component {
|
||||||
* You can use allow with either an array, or var args.
|
* You can use allow with either an array, or var args.
|
||||||
*
|
*
|
||||||
* `$this->Auth->allow(array('edit', 'add'));` or
|
* `$this->Auth->allow(array('edit', 'add'));` or
|
||||||
* `$this->Auth->allow('edit', 'add');`
|
* `$this->Auth->allow('edit', 'add');` or
|
||||||
* `$this->Auth->allow();` to allow all actions.
|
* `$this->Auth->allow();` to allow all actions
|
||||||
*
|
|
||||||
* allow() also supports '*' as a wildcard to mean all actions.
|
|
||||||
*
|
|
||||||
* `$this->Auth->allow('*');`
|
|
||||||
*
|
*
|
||||||
* @param mixed $action,... Controller action name or array of actions
|
* @param mixed $action,... Controller action name or array of actions
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -437,7 +433,7 @@ class AuthComponent extends Component {
|
||||||
*/
|
*/
|
||||||
public function allow($action = null) {
|
public function allow($action = null) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
if (empty($args) || $args == array('*')) {
|
if (empty($args)) {
|
||||||
$this->allowedActions = $this->_methods;
|
$this->allowedActions = $this->_methods;
|
||||||
} else {
|
} else {
|
||||||
if (isset($args[0]) && is_array($args[0])) {
|
if (isset($args[0]) && is_array($args[0])) {
|
||||||
|
|
|
@ -139,9 +139,9 @@ class RequestHandlerComponent extends Component {
|
||||||
}
|
}
|
||||||
$extensions = Router::extensions();
|
$extensions = Router::extensions();
|
||||||
$preferred = array_shift($accept);
|
$preferred = array_shift($accept);
|
||||||
$preferredTypes = $this->mapType($preferred);
|
$preferredTypes = $this->response->mapType($preferred);
|
||||||
$similarTypes = array_intersect($extensions, $preferredTypes);
|
$similarTypes = array_intersect($extensions, $preferredTypes);
|
||||||
if (count($similarTypes) === 1 && !in_array('html', $preferredTypes)) {
|
if (count($similarTypes) === 1 && !in_array('xhtml', $preferredTypes) && !in_array('html', $preferredTypes)) {
|
||||||
$this->ext = array_shift($similarTypes);
|
$this->ext = array_shift($similarTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,6 +208,9 @@ class SecurityComponent extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->_generateToken($controller);
|
$this->_generateToken($controller);
|
||||||
|
if ($isPost) {
|
||||||
|
unset($controller->request->data['_Token']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -212,6 +212,7 @@ class App {
|
||||||
* @param string $type type of path
|
* @param string $type type of path
|
||||||
* @param string $plugin name of plugin
|
* @param string $plugin name of plugin
|
||||||
* @return string array
|
* @return string array
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::path
|
||||||
*/
|
*/
|
||||||
public static function path($type, $plugin = null) {
|
public static function path($type, $plugin = null) {
|
||||||
if (!empty(self::$legacy[$type])) {
|
if (!empty(self::$legacy[$type])) {
|
||||||
|
@ -243,6 +244,7 @@ class App {
|
||||||
* use App::path()
|
* use App::path()
|
||||||
*
|
*
|
||||||
* @return array An array of packages and their associated paths.
|
* @return array An array of packages and their associated paths.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::paths
|
||||||
*/
|
*/
|
||||||
public static function paths() {
|
public static function paths() {
|
||||||
return self::$_packages;
|
return self::$_packages;
|
||||||
|
@ -266,6 +268,7 @@ class App {
|
||||||
* @param array $paths associative array with package names as keys and a list of directories for new search paths
|
* @param array $paths associative array with package names as keys and a list of directories for new search paths
|
||||||
* @param mixed $mode App::RESET will set paths, App::APPEND with append paths, App::PREPEND will prepend paths, [default] App::PREPEND
|
* @param mixed $mode App::RESET will set paths, App::APPEND with append paths, App::PREPEND will prepend paths, [default] App::PREPEND
|
||||||
* @return void
|
* @return void
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::build
|
||||||
*/
|
*/
|
||||||
public static function build($paths = array(), $mode = App::PREPEND) {
|
public static function build($paths = array(), $mode = App::PREPEND) {
|
||||||
//Provides Backwards compatibility for old-style package names
|
//Provides Backwards compatibility for old-style package names
|
||||||
|
@ -348,6 +351,7 @@ class App {
|
||||||
*
|
*
|
||||||
* @param string $plugin CamelCased/lower_cased plugin name to find the path of.
|
* @param string $plugin CamelCased/lower_cased plugin name to find the path of.
|
||||||
* @return string full path to the plugin.
|
* @return string full path to the plugin.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::pluginPath
|
||||||
*/
|
*/
|
||||||
public static function pluginPath($plugin) {
|
public static function pluginPath($plugin) {
|
||||||
return CakePlugin::path($plugin);
|
return CakePlugin::path($plugin);
|
||||||
|
@ -362,6 +366,7 @@ class App {
|
||||||
*
|
*
|
||||||
* @param string $theme theme name to find the path of.
|
* @param string $theme theme name to find the path of.
|
||||||
* @return string full path to the theme.
|
* @return string full path to the theme.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::themePath
|
||||||
*/
|
*/
|
||||||
public static function themePath($theme) {
|
public static function themePath($theme) {
|
||||||
$themeDir = 'Themed' . DS . Inflector::camelize($theme);
|
$themeDir = 'Themed' . DS . Inflector::camelize($theme);
|
||||||
|
@ -382,6 +387,7 @@ class App {
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return string full path to package
|
* @return string full path to package
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::core
|
||||||
*/
|
*/
|
||||||
public static function core($type) {
|
public static function core($type) {
|
||||||
return array(CAKE . str_replace('/', DS, $type) . DS);
|
return array(CAKE . str_replace('/', DS, $type) . DS);
|
||||||
|
@ -408,6 +414,7 @@ class App {
|
||||||
* @param mixed $path Optional Scan only the path given. If null, paths for the chosen type will be used.
|
* @param mixed $path Optional Scan only the path given. If null, paths for the chosen type will be used.
|
||||||
* @param boolean $cache Set to false to rescan objects of the chosen type. Defaults to true.
|
* @param boolean $cache Set to false to rescan objects of the chosen type. Defaults to true.
|
||||||
* @return mixed Either false on incorrect / miss. Or an array of found objects.
|
* @return mixed Either false on incorrect / miss. Or an array of found objects.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::objects
|
||||||
*/
|
*/
|
||||||
public static function objects($type, $path = null, $cache = true) {
|
public static function objects($type, $path = null, $cache = true) {
|
||||||
$extension = '/\.php$/';
|
$extension = '/\.php$/';
|
||||||
|
@ -499,6 +506,7 @@ class App {
|
||||||
* @param string $className the name of the class to configure package for
|
* @param string $className the name of the class to configure package for
|
||||||
* @param string $location the package name
|
* @param string $location the package name
|
||||||
* @return void
|
* @return void
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::uses
|
||||||
*/
|
*/
|
||||||
public static function uses($className, $location) {
|
public static function uses($className, $location) {
|
||||||
self::$_classMap[$className] = $location;
|
self::$_classMap[$className] = $location;
|
||||||
|
@ -540,12 +548,14 @@ class App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//To help apps migrate to 2.0 old style file names are allowed
|
// To help apps migrate to 2.0 old style file names are allowed
|
||||||
|
// if the trailing segment is one of the types that changed, alternates will be tried.
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
$underscored = Inflector::underscore($className);
|
$underscored = Inflector::underscore($className);
|
||||||
$tries = array($path . $underscored . '.php');
|
$tries = array($path . $underscored . '.php');
|
||||||
$parts = explode('_', $underscored);
|
$parts = explode('_', $underscored);
|
||||||
if (count($parts) > 1) {
|
$numParts = count($parts);
|
||||||
|
if ($numParts > 1 && in_array($parts[$numParts - 1], array('behavior', 'helper', 'component'))) {
|
||||||
array_pop($parts);
|
array_pop($parts);
|
||||||
$tries[] = $path . implode('_', $parts) . '.php';
|
$tries[] = $path . implode('_', $parts) . '.php';
|
||||||
}
|
}
|
||||||
|
@ -565,6 +575,7 @@ class App {
|
||||||
*
|
*
|
||||||
* @param string $className name of the class to obtain the package name from
|
* @param string $className name of the class to obtain the package name from
|
||||||
* @return string package name or null if not declared
|
* @return string package name or null if not declared
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::location
|
||||||
*/
|
*/
|
||||||
public static function location($className) {
|
public static function location($className) {
|
||||||
if (!empty(self::$_classMap[$className])) {
|
if (!empty(self::$_classMap[$className])) {
|
||||||
|
@ -691,7 +702,7 @@ class App {
|
||||||
* @param boolean $return whether this function should return the contents of the file after being parsed by php or just a success notice
|
* @param boolean $return whether this function should return the contents of the file after being parsed by php or just a success notice
|
||||||
* @return mixed if $return contents of the file after php parses it, boolean indicating success otherwise
|
* @return mixed if $return contents of the file after php parses it, boolean indicating success otherwise
|
||||||
*/
|
*/
|
||||||
protected function _loadFile($name, $plugin, $search, $file, $return) {
|
protected static function _loadFile($name, $plugin, $search, $file, $return) {
|
||||||
$mapped = self::_mapped($name, $plugin);
|
$mapped = self::_mapped($name, $plugin);
|
||||||
if ($mapped) {
|
if ($mapped) {
|
||||||
$file = $mapped;
|
$file = $mapped;
|
||||||
|
@ -806,6 +817,11 @@ class App {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets then returns the templates for each customizable package path
|
||||||
|
*
|
||||||
|
* @return array templates for each customizable package path
|
||||||
|
*/
|
||||||
protected static function _packageFormat() {
|
protected static function _packageFormat() {
|
||||||
if (empty(self::$_packageFormat)) {
|
if (empty(self::$_packageFormat)) {
|
||||||
self::$_packageFormat = array(
|
self::$_packageFormat = array(
|
||||||
|
|
|
@ -55,8 +55,18 @@ class Object {
|
||||||
* or tie plugins into a main application. requestAction can be used to return rendered views
|
* or tie plugins into a main application. requestAction can be used to return rendered views
|
||||||
* or fetch the return value from controller actions.
|
* or fetch the return value from controller actions.
|
||||||
*
|
*
|
||||||
* @param mixed $url String or array-based url.
|
* Under the hood this method uses Router::reverse() to convert the $url parmeter into a string
|
||||||
* @param array $extra if array includes the key "return" it sets the AutoRender to true.
|
* URL. You should use URL formats that are compatible with Router::reverse()
|
||||||
|
*
|
||||||
|
* #### Passing POST and GET data
|
||||||
|
*
|
||||||
|
* POST and GET data can be simulated in requestAction. Use `$extra['url']` for
|
||||||
|
* GET data. The `$extra['data']` parameter allows POST data simulation.
|
||||||
|
*
|
||||||
|
* @param mixed $url String or array-based url. Unlike other url arrays in CakePHP, this
|
||||||
|
* url will not automatically handle passed and named arguments in the $url paramenter.
|
||||||
|
* @param array $extra if array includes the key "return" it sets the AutoRender to true. Can
|
||||||
|
* also be used to submit GET/POST data, and named/passed arguments.
|
||||||
* @return mixed Boolean true or false on success/failure, or contents
|
* @return mixed Boolean true or false on success/failure, or contents
|
||||||
* of rendered action if 'return' is set in $extra.
|
* of rendered action if 'return' is set in $extra.
|
||||||
*/
|
*/
|
||||||
|
@ -74,6 +84,8 @@ class Object {
|
||||||
$extra['url'] = array();
|
$extra['url'] = array();
|
||||||
}
|
}
|
||||||
$extra = array_merge(array('autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1), $extra);
|
$extra = array_merge(array('autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1), $extra);
|
||||||
|
$data = isset($extra['data']) ? $extra['data'] : null;
|
||||||
|
unset($extra['data']);
|
||||||
|
|
||||||
if (is_string($url)) {
|
if (is_string($url)) {
|
||||||
$request = new CakeRequest($url);
|
$request = new CakeRequest($url);
|
||||||
|
@ -81,9 +93,9 @@ class Object {
|
||||||
$params = $url + array('pass' => array(), 'named' => array(), 'base' => false);
|
$params = $url + array('pass' => array(), 'named' => array(), 'base' => false);
|
||||||
$params = array_merge($params, $extra);
|
$params = array_merge($params, $extra);
|
||||||
$request = new CakeRequest(Router::reverse($params), false);
|
$request = new CakeRequest(Router::reverse($params), false);
|
||||||
if (isset($params['data'])) {
|
|
||||||
$request->data = $params['data'];
|
|
||||||
}
|
}
|
||||||
|
if (isset($data)) {
|
||||||
|
$request->data = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dispatcher = new Dispatcher();
|
$dispatcher = new Dispatcher();
|
||||||
|
|
|
@ -546,9 +546,10 @@ class CakeSchema extends Object {
|
||||||
$difference[$key] = $value;
|
$difference[$key] = $value;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$compare = strval($value);
|
if (is_array($value) && is_array($correspondingValue)) {
|
||||||
$correspondingValue = strval($correspondingValue);
|
continue;
|
||||||
if ($compare === $correspondingValue) {
|
}
|
||||||
|
if ($value === $correspondingValue) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$difference[$key] = $value;
|
$difference[$key] = $value;
|
||||||
|
|
|
@ -440,8 +440,10 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
if (!$query->columnCount()) {
|
if (!$query->columnCount()) {
|
||||||
$query->closeCursor();
|
$query->closeCursor();
|
||||||
|
if (!$query->rowCount()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $query;
|
return $query;
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
if (isset($query->queryString)) {
|
if (isset($query->queryString)) {
|
||||||
|
|
|
@ -546,9 +546,9 @@ class CakeEmail {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Subject
|
* Get/Set Subject.
|
||||||
*
|
*
|
||||||
* @param string $subject
|
* @param null|string $subject
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function subject($subject = null) {
|
public function subject($subject = null) {
|
||||||
|
|
|
@ -214,7 +214,8 @@ class SmtpTransport extends AbstractTransport {
|
||||||
if (substr($response, -2) !== "\r\n") {
|
if (substr($response, -2) !== "\r\n") {
|
||||||
throw new SocketException(__d('cake_dev', 'SMTP timeout.'));
|
throw new SocketException(__d('cake_dev', 'SMTP timeout.'));
|
||||||
}
|
}
|
||||||
$response = end(explode("\r\n", rtrim($response, "\r\n")));
|
$responseLines = explode("\r\n", rtrim($response, "\r\n"));
|
||||||
|
$response = end($responseLines);
|
||||||
|
|
||||||
if (preg_match('/^(' . $checkCode . ')(.)/', $response, $code)) {
|
if (preg_match('/^(' . $checkCode . ')(.)/', $response, $code)) {
|
||||||
if ($code[2] === '-') {
|
if ($code[2] === '-') {
|
||||||
|
|
|
@ -63,6 +63,7 @@ class HttpSocket extends CakeSocket {
|
||||||
'User-Agent' => 'CakePHP'
|
'User-Agent' => 'CakePHP'
|
||||||
),
|
),
|
||||||
'raw' => null,
|
'raw' => null,
|
||||||
|
'redirect' => false,
|
||||||
'cookies' => array()
|
'cookies' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -91,13 +92,13 @@ class HttpSocket extends CakeSocket {
|
||||||
'protocol' => 'tcp',
|
'protocol' => 'tcp',
|
||||||
'port' => 80,
|
'port' => 80,
|
||||||
'timeout' => 30,
|
'timeout' => 30,
|
||||||
'redirect' => false,
|
|
||||||
'request' => array(
|
'request' => array(
|
||||||
'uri' => array(
|
'uri' => array(
|
||||||
'scheme' => 'http',
|
'scheme' => 'http',
|
||||||
'host' => 'localhost',
|
'host' => 'localhost',
|
||||||
'port' => 80
|
'port' => 80
|
||||||
),
|
),
|
||||||
|
'redirect' => false,
|
||||||
'cookies' => array()
|
'cookies' => array()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -378,8 +379,10 @@ class HttpSocket extends CakeSocket {
|
||||||
}
|
}
|
||||||
$this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response->cookies);
|
$this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response->cookies);
|
||||||
}
|
}
|
||||||
if($this->config['redirect'] && $this->response->isRedirect()) {
|
|
||||||
|
if($this->request['redirect'] && $this->response->isRedirect()) {
|
||||||
$request['uri'] = $this->response->getHeader('Location');
|
$request['uri'] = $this->response->getHeader('Location');
|
||||||
|
$request['redirect'] = is_int($this->request['redirect']) ? $this->request['redirect'] - 1 : $this->request['redirect'];
|
||||||
$this->response = $this->request($request);
|
$this->response = $this->request($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ class TaskCollectionTest extends CakeTestCase {
|
||||||
$dispatcher = $this->getMock('ShellDispatcher', array(), array(), '', false);
|
$dispatcher = $this->getMock('ShellDispatcher', array(), array(), '', false);
|
||||||
$shell = $this->getMock('Shell', array(), array(), '', false);
|
$shell = $this->getMock('Shell', array(), array(), '', false);
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
|
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
|
||||||
));
|
));
|
||||||
CakePlugin::load('TestPlugin');
|
CakePlugin::load('TestPlugin');
|
||||||
$this->Tasks = new TaskCollection($shell, $dispatcher);
|
$this->Tasks = new TaskCollection($shell, $dispatcher);
|
||||||
|
|
|
@ -628,7 +628,7 @@ class AuthComponentTest extends CakeTestCase {
|
||||||
$this->Controller->request['action'] = 'camelCase';
|
$this->Controller->request['action'] = 'camelCase';
|
||||||
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
|
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
|
||||||
|
|
||||||
$this->Controller->Auth->allow('*');
|
$this->Controller->Auth->allow();
|
||||||
$this->Controller->Auth->deny(array('add', 'camelCase'));
|
$this->Controller->Auth->deny(array('add', 'camelCase'));
|
||||||
|
|
||||||
$this->Controller->request['action'] = 'delete';
|
$this->Controller->request['action'] = 'delete';
|
||||||
|
@ -663,7 +663,7 @@ class AuthComponentTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testDenyWithCamelCaseMethods() {
|
public function testDenyWithCamelCaseMethods() {
|
||||||
$this->Controller->Auth->initialize($this->Controller);
|
$this->Controller->Auth->initialize($this->Controller);
|
||||||
$this->Controller->Auth->allow('*');
|
$this->Controller->Auth->allow();
|
||||||
$this->Controller->Auth->deny('add', 'camelCase');
|
$this->Controller->Auth->deny('add', 'camelCase');
|
||||||
|
|
||||||
$url = '/auth_test/camelCase';
|
$url = '/auth_test/camelCase';
|
||||||
|
@ -685,7 +685,7 @@ class AuthComponentTest extends CakeTestCase {
|
||||||
$this->Controller->Auth->initialize($this->Controller);
|
$this->Controller->Auth->initialize($this->Controller);
|
||||||
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
|
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
|
||||||
$this->Controller->Auth->userModel = 'AuthUser';
|
$this->Controller->Auth->userModel = 'AuthUser';
|
||||||
$this->Controller->Auth->allow('*');
|
$this->Controller->Auth->allow();
|
||||||
$result = $this->Controller->Auth->startup($this->Controller);
|
$result = $this->Controller->Auth->startup($this->Controller);
|
||||||
$this->assertTrue($result, 'startup() should return true, as action is allowed. %s');
|
$this->assertTrue($result, 'startup() should return true, as action is allowed. %s');
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
||||||
$this->RequestHandler->initialize($this->Controller);
|
$this->RequestHandler->initialize($this->Controller);
|
||||||
$this->assertNull($this->RequestHandler->ext);
|
$this->assertNull($this->RequestHandler->ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that ext is not set with multiple accepted content types.
|
* Test that ext is not set with multiple accepted content types.
|
||||||
*
|
*
|
||||||
|
@ -228,6 +229,20 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
||||||
$this->assertNull($this->RequestHandler->ext);
|
$this->assertNull($this->RequestHandler->ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that ext is not set with confusing android accepts headers.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInitializeAmbiguousAndroidAccepts() {
|
||||||
|
$_SERVER['HTTP_ACCEPT'] = 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
|
||||||
|
$this->assertNull($this->RequestHandler->ext);
|
||||||
|
Router::parseExtensions('html', 'xml');
|
||||||
|
|
||||||
|
$this->RequestHandler->initialize($this->Controller);
|
||||||
|
$this->assertNull($this->RequestHandler->ext);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that a type mismatch doesn't incorrectly set the ext
|
* Test that a type mismatch doesn't incorrectly set the ext
|
||||||
*
|
*
|
||||||
|
|
|
@ -40,23 +40,6 @@ class ParamTestComponent extends Component {
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $components = array('Banana' => array('config' => 'value'));
|
public $components = array('Banana' => array('config' => 'value'));
|
||||||
|
|
||||||
/**
|
|
||||||
* initialize method
|
|
||||||
*
|
|
||||||
* @param mixed $controller
|
|
||||||
* @param mixed $settings
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function initialize(&$controller, $settings) {
|
|
||||||
foreach ($settings as $key => $value) {
|
|
||||||
if (is_numeric($key)) {
|
|
||||||
$this->{$value} = true;
|
|
||||||
} else {
|
|
||||||
$this->{$key} = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,7 +92,7 @@ class AppleComponent extends Component {
|
||||||
* @param mixed $controller
|
* @param mixed $controller
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startup(&$controller) {
|
public function startup($controller) {
|
||||||
$this->testName = $controller->name;
|
$this->testName = $controller->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +117,7 @@ class OrangeComponent extends Component {
|
||||||
* @param mixed $controller
|
* @param mixed $controller
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize(&$controller) {
|
public function initialize($controller) {
|
||||||
$this->Controller = $controller;
|
$this->Controller = $controller;
|
||||||
$this->Banana->testField = 'OrangeField';
|
$this->Banana->testField = 'OrangeField';
|
||||||
}
|
}
|
||||||
|
@ -145,7 +128,7 @@ class OrangeComponent extends Component {
|
||||||
* @param Controller $controller
|
* @param Controller $controller
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function startup(&$controller) {
|
public function startup($controller) {
|
||||||
$controller->foo = 'pass';
|
$controller->foo = 'pass';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +153,7 @@ class BananaComponent extends Component {
|
||||||
* @param Controller $controller
|
* @param Controller $controller
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function startup(&$controller) {
|
public function startup($controller) {
|
||||||
$controller->bar = 'fail';
|
$controller->bar = 'fail';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ class ControllerPost extends CakeTestModel {
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function find($type, $options = array()) {
|
public function find($type = 'first', $options = array()) {
|
||||||
if ($type == 'popular') {
|
if ($type == 'popular') {
|
||||||
$conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1');
|
$conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1');
|
||||||
$options = Set::merge($options, compact('conditions'));
|
$options = Set::merge($options, compact('conditions'));
|
||||||
|
|
|
@ -26,15 +26,6 @@ App::uses('PagesController', 'Controller');
|
||||||
*/
|
*/
|
||||||
class PagesControllerTest extends CakeTestCase {
|
class PagesControllerTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
|
||||||
* endTest method
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function endTest() {
|
|
||||||
App::build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testDisplay method
|
* testDisplay method
|
||||||
*
|
*
|
||||||
|
|
|
@ -87,12 +87,12 @@ class ScaffoldMockControllerWithFields extends Controller {
|
||||||
class TestScaffoldMock extends Scaffold {
|
class TestScaffoldMock extends Scaffold {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overload __scaffold
|
* Overload _scaffold
|
||||||
*
|
*
|
||||||
* @param unknown_type $params
|
* @param unknown_type $params
|
||||||
*/
|
*/
|
||||||
function _scaffold($params) {
|
function _scaffold(CakeRequest $request) {
|
||||||
$this->_params = $params;
|
$this->_params = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -115,7 +115,7 @@ class RequestActionController extends Controller {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function post_pass() {
|
public function post_pass() {
|
||||||
return $this->data;
|
return $this->request->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -490,7 +490,7 @@ class ObjectTest extends CakeTestCase {
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
|
'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
|
||||||
), true);
|
), true);
|
||||||
CakePlugin::loadAll();
|
CakePlugin::load('TestPlugin');
|
||||||
Router::reload();
|
Router::reload();
|
||||||
|
|
||||||
$result = $this->object->requestAction('/test_plugin/tests/index', array('return'));
|
$result = $this->object->requestAction('/test_plugin/tests/index', array('return'));
|
||||||
|
@ -609,11 +609,12 @@ class ObjectTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test requestAction and POST parameter passing, and not passing when url is an array.
|
* test that requestAction does not fish data out of the POST
|
||||||
|
* superglobal.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRequestActionPostPassing() {
|
public function testRequestActionNoPostPassing() {
|
||||||
$_tmp = $_POST;
|
$_tmp = $_POST;
|
||||||
|
|
||||||
$_POST = array('data' => array(
|
$_POST = array('data' => array(
|
||||||
|
@ -636,4 +637,26 @@ class ObjectTest extends CakeTestCase {
|
||||||
|
|
||||||
$_POST = $_tmp;
|
$_POST = $_tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test requestAction with post data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testRequestActionPostWithData() {
|
||||||
|
$data = array(
|
||||||
|
'Post' => array('id' => 2)
|
||||||
|
);
|
||||||
|
$result = $this->object->requestAction(
|
||||||
|
array('controller' => 'request_action', 'action' => 'post_pass'),
|
||||||
|
array('data' => $data)
|
||||||
|
);
|
||||||
|
$this->assertEquals($data, $result);
|
||||||
|
|
||||||
|
$result = $this->object->requestAction(
|
||||||
|
'/request_action/post_pass',
|
||||||
|
array('data' => $data)
|
||||||
|
);
|
||||||
|
$this->assertEquals($data, $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class BlueberryComponent extends Component {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize(&$controller) {
|
public function initialize($controller) {
|
||||||
$this->testName = 'BlueberryComponent';
|
$this->testName = 'BlueberryComponent';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3305,9 +3305,9 @@ class ContainableBehaviorTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->assertTrue(empty($this->Article->hasMany['ArticlesTag']));
|
$this->assertTrue(empty($this->Article->hasMany['ArticlesTag']));
|
||||||
|
|
||||||
$this->JoinA =& ClassRegistry::init('JoinA');
|
$this->JoinA = ClassRegistry::init('JoinA');
|
||||||
$this->JoinB =& ClassRegistry::init('JoinB');
|
$this->JoinB = ClassRegistry::init('JoinB');
|
||||||
$this->JoinC =& ClassRegistry::init('JoinC');
|
$this->JoinC = ClassRegistry::init('JoinC');
|
||||||
|
|
||||||
$this->JoinA->Behaviors->attach('Containable');
|
$this->JoinA->Behaviors->attach('Containable');
|
||||||
$this->JoinB->Behaviors->attach('Containable');
|
$this->JoinB->Behaviors->attach('Containable');
|
||||||
|
|
|
@ -955,7 +955,7 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertEqual($compare, $expected);
|
$this->assertEquals($expected, $compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -223,6 +223,30 @@ class MysqlTest extends CakeTestCase {
|
||||||
$this->assertIdentical($result['Tinyint']['small_int'], '0');
|
$this->assertIdentical($result['Tinyint']['small_int'], '0');
|
||||||
$this->model->deleteAll(true);
|
$this->model->deleteAll(true);
|
||||||
|
|
||||||
|
$this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* testLastAffected method
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testLastAffected() {
|
||||||
|
$this->Dbo->cacheSources = false;
|
||||||
|
$tableName = 'tinyint_' . uniqid();
|
||||||
|
$this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
|
||||||
|
|
||||||
|
$this->model = new CakeTestModel(array(
|
||||||
|
'name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test'
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertTrue((bool)$this->model->save(array('bool' => 5, 'small_int' => 5)));
|
||||||
|
$this->assertEqual(1, $this->model->find('count'));
|
||||||
|
$this->model->deleteAll(true);
|
||||||
|
$result = $this->Dbo->lastAffected();
|
||||||
|
$this->assertEqual(1, $result);
|
||||||
|
$this->assertEqual(0, $this->model->find('count'));
|
||||||
|
|
||||||
$this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName));
|
$this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class DboPostgresTestDb extends Postgres {
|
||||||
* @param mixed $sql
|
* @param mixed $sql
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _execute($sql, $params = array()) {
|
function _execute($sql, $params = array(), $prepareOptions = array()) {
|
||||||
$this->simulated[] = $sql;
|
$this->simulated[] = $sql;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ class DboSqliteTestDb extends Sqlite {
|
||||||
* @param mixed $sql
|
* @param mixed $sql
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _execute($sql, $params = array()) {
|
function _execute($sql, $params = array(), $prepareOptions = array()) {
|
||||||
$this->simulated[] = $sql;
|
$this->simulated[] = $sql;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,11 @@ class SqlserverTestDb extends Sqlserver {
|
||||||
* execute method
|
* execute method
|
||||||
*
|
*
|
||||||
* @param mixed $sql
|
* @param mixed $sql
|
||||||
|
* @param mixed $params
|
||||||
|
* @param mixed $prepareOptions
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function _execute($sql) {
|
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
|
||||||
$this->simulated[] = $sql;
|
$this->simulated[] = $sql;
|
||||||
return empty($this->executeResultsStack) ? null : array_pop($this->executeResultsStack);
|
return empty($this->executeResultsStack) ? null : array_pop($this->executeResultsStack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,10 @@ class DboTestSource extends DboSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mergeAssociation(&$data, &$merge, $association, $type, $selfJoin = false) {
|
public function mergeAssociation(&$data, &$merge, $association, $type, $selfJoin = false) {
|
||||||
return parent::_mergeAssociation(&$data, &$merge, $association, $type, $selfJoin);
|
return parent::_mergeAssociation($data, $merge, $association, $type, $selfJoin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setConfig($config) {
|
public function setConfig($config = array()) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,11 +733,11 @@ class DboSourceTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testFieldsUsingMethodCache() {
|
public function testFieldsUsingMethodCache() {
|
||||||
$this->testDb->cacheMethods = false;
|
$this->testDb->cacheMethods = false;
|
||||||
$this->assertTrue(empty($this->testDb->methodCache['fields']), 'Cache not empty');
|
DboTestSource::$methodCache = array();
|
||||||
|
|
||||||
$Article = ClassRegistry::init('Article');
|
$Article = ClassRegistry::init('Article');
|
||||||
$this->testDb->fields($Article, null, array('title', 'body', 'published'));
|
$this->testDb->fields($Article, null, array('title', 'body', 'published'));
|
||||||
$this->assertTrue(empty($this->testDb->methodCache['fields']), 'Cache not empty');
|
$this->assertTrue(empty(DboTestSource::$methodCache['fields']), 'Cache not empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1557,6 +1557,146 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->assertEqual(Set::extract('/JoinC/JoinAsJoinC/other', $result), $expected);
|
$this->assertEqual(Set::extract('/JoinC/JoinAsJoinC/other', $result), $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testSaveHabtmNoPrimaryData method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testSaveHabtmNoPrimaryData() {
|
||||||
|
$this->loadFixtures('Article', 'User', 'Comment', 'Tag', 'ArticlesTag');
|
||||||
|
$TestModel = new Article();
|
||||||
|
|
||||||
|
$TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')), false);
|
||||||
|
$result = $TestModel->findById(2);
|
||||||
|
$expected = array(
|
||||||
|
'Article' => array(
|
||||||
|
'id' => '2',
|
||||||
|
'user_id' => '3',
|
||||||
|
'title' => 'Second Article',
|
||||||
|
'body' => 'Second Article Body',
|
||||||
|
'published' => 'Y',
|
||||||
|
'created' => '2007-03-18 10:41:23',
|
||||||
|
'updated' => '2007-03-18 10:43:31'
|
||||||
|
),
|
||||||
|
'Tag' => array(
|
||||||
|
array(
|
||||||
|
'id' => '1',
|
||||||
|
'tag' => 'tag1',
|
||||||
|
'created' => '2007-03-18 12:22:23',
|
||||||
|
'updated' => '2007-03-18 12:24:31'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => '3',
|
||||||
|
'tag' => 'tag3',
|
||||||
|
'created' => '2007-03-18 12:26:23',
|
||||||
|
'updated' => '2007-03-18 12:28:31'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
|
||||||
|
$ts = date('Y-m-d H:i:s');
|
||||||
|
$TestModel->id = 2;
|
||||||
|
$data = array('Tag' => array('Tag' => array(2)));
|
||||||
|
$TestModel->save($data);
|
||||||
|
|
||||||
|
$result = $TestModel->findById(2);
|
||||||
|
$expected = array(
|
||||||
|
'Article' => array(
|
||||||
|
'id' => '2',
|
||||||
|
'user_id' => '3',
|
||||||
|
'title' => 'Second Article',
|
||||||
|
'body' => 'Second Article Body',
|
||||||
|
'published' => 'Y',
|
||||||
|
'created' => '2007-03-18 10:41:23',
|
||||||
|
'updated' => $ts
|
||||||
|
),
|
||||||
|
'Tag' => array(
|
||||||
|
array(
|
||||||
|
'id' => '2',
|
||||||
|
'tag' => 'tag2',
|
||||||
|
'created' => '2007-03-18 12:24:23',
|
||||||
|
'updated' => '2007-03-18 12:26:31'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
|
||||||
|
$this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio');
|
||||||
|
$TestModel = new Portfolio();
|
||||||
|
$result = $TestModel->findById(2);
|
||||||
|
$expected = array(
|
||||||
|
'Portfolio' => array(
|
||||||
|
'id' => 2,
|
||||||
|
'seller_id' => 1,
|
||||||
|
'name' => 'Portfolio 2'
|
||||||
|
),
|
||||||
|
'Item' => array(
|
||||||
|
array(
|
||||||
|
'id' => 2,
|
||||||
|
'syfile_id' => 2,
|
||||||
|
'published' => '',
|
||||||
|
'name' => 'Item 2',
|
||||||
|
'ItemsPortfolio' => array(
|
||||||
|
'id' => 2,
|
||||||
|
'item_id' => 2,
|
||||||
|
'portfolio_id' => 2
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 6,
|
||||||
|
'syfile_id' => 6,
|
||||||
|
'published' => '',
|
||||||
|
'name' => 'Item 6',
|
||||||
|
'ItemsPortfolio' => array(
|
||||||
|
'id' => 6,
|
||||||
|
'item_id' => 6,
|
||||||
|
'portfolio_id' => 2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
|
||||||
|
$data = array('Item' => array('Item' => array(1, 2)));
|
||||||
|
$TestModel->id = 2;
|
||||||
|
$TestModel->save($data);
|
||||||
|
$result = $TestModel->findById(2);
|
||||||
|
$result['Item'] = Set::sort($result['Item'], '{n}.id', 'asc');
|
||||||
|
$expected = array(
|
||||||
|
'Portfolio' => array(
|
||||||
|
'id' => 2,
|
||||||
|
'seller_id' => 1,
|
||||||
|
'name' => 'Portfolio 2'
|
||||||
|
),
|
||||||
|
'Item' => array(
|
||||||
|
array(
|
||||||
|
'id' => 1,
|
||||||
|
'syfile_id' => 1,
|
||||||
|
'published' => '',
|
||||||
|
'name' => 'Item 1',
|
||||||
|
'ItemsPortfolio' => array(
|
||||||
|
'id' => 7,
|
||||||
|
'item_id' => 1,
|
||||||
|
'portfolio_id' => 2
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 2,
|
||||||
|
'syfile_id' => 2,
|
||||||
|
'published' => '',
|
||||||
|
'name' => 'Item 2',
|
||||||
|
'ItemsPortfolio' => array(
|
||||||
|
'id' => 8,
|
||||||
|
'item_id' => 2,
|
||||||
|
'portfolio_id' => 2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testSaveHabtmCustomKeys method
|
* testSaveHabtmCustomKeys method
|
||||||
*
|
*
|
||||||
|
|
|
@ -300,11 +300,14 @@ class CakeResponseTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the compress method
|
* Tests the compress method
|
||||||
*
|
*
|
||||||
*/
|
* @return void
|
||||||
|
*/
|
||||||
public function testCompress() {
|
public function testCompress() {
|
||||||
$this->skipIf(php_sapi_name() !== 'cli', 'The response compression can only be tested in cli.');
|
if (php_sapi_name() !== 'cli') {
|
||||||
|
$this->markTestSkipped('The response compression can only be tested in cli.');
|
||||||
|
}
|
||||||
|
|
||||||
$response = new CakeResponse();
|
$response = new CakeResponse();
|
||||||
if (ini_get("zlib.output_compression") === '1' || !extension_loaded("zlib")) {
|
if (ini_get("zlib.output_compression") === '1' || !extension_loaded("zlib")) {
|
||||||
|
|
|
@ -390,10 +390,6 @@ class CakeEmailTest extends CakeTestCase {
|
||||||
$this->CakeEmail->subject(1);
|
$this->CakeEmail->subject(1);
|
||||||
$this->assertIdentical($this->CakeEmail->subject(), '1');
|
$this->assertIdentical($this->CakeEmail->subject(), '1');
|
||||||
|
|
||||||
$result = $this->CakeEmail->subject(array('something'));
|
|
||||||
$this->assertIdentical($this->CakeEmail->subject(), 'Array');
|
|
||||||
$this->assertIdentical($this->CakeEmail, $result);
|
|
||||||
|
|
||||||
$this->CakeEmail->subject('هذه رسالة بعنوان طويل مرسل للمستلم');
|
$this->CakeEmail->subject('هذه رسالة بعنوان طويل مرسل للمستلم');
|
||||||
$expected = '=?UTF-8?B?2YfYsNmHINix2LPYp9mE2Kkg2KjYudmG2YjYp9mGINi32YjZitmEINmF2LE=?=' . "\r\n" . ' =?UTF-8?B?2LPZhCDZhNmE2YXYs9iq2YTZhQ==?=';
|
$expected = '=?UTF-8?B?2YfYsNmHINix2LPYp9mE2Kkg2KjYudmG2YjYp9mGINi32YjZitmEINmF2LE=?=' . "\r\n" . ' =?UTF-8?B?2LPZhCDZhNmE2YXYs9iq2YTZhQ==?=';
|
||||||
$this->assertIdentical($this->CakeEmail->subject(), $expected);
|
$this->assertIdentical($this->CakeEmail->subject(), $expected);
|
||||||
|
|
|
@ -35,7 +35,7 @@ class DigestHttpSocket extends HttpSocket {
|
||||||
* @param mixed $request
|
* @param mixed $request
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function request($request) {
|
public function request($request = array()) {
|
||||||
if ($request === false) {
|
if ($request === false) {
|
||||||
if (isset($this->response['header']['WWW-Authenticate'])) {
|
if (isset($this->response['header']['WWW-Authenticate'])) {
|
||||||
unset($this->response['header']['WWW-Authenticate']);
|
unset($this->response['header']['WWW-Authenticate']);
|
||||||
|
|
|
@ -252,13 +252,13 @@ class HttpSocketTest extends CakeTestCase {
|
||||||
'protocol' => 'tcp',
|
'protocol' => 'tcp',
|
||||||
'port' => 23,
|
'port' => 23,
|
||||||
'timeout' => 30,
|
'timeout' => 30,
|
||||||
'redirect' => false,
|
|
||||||
'request' => array(
|
'request' => array(
|
||||||
'uri' => array(
|
'uri' => array(
|
||||||
'scheme' => 'https',
|
'scheme' => 'https',
|
||||||
'host' => 'www.cakephp.org',
|
'host' => 'www.cakephp.org',
|
||||||
'port' => 23
|
'port' => 23
|
||||||
),
|
),
|
||||||
|
'redirect' => false,
|
||||||
'cookies' => array()
|
'cookies' => array()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -277,13 +277,13 @@ class HttpSocketTest extends CakeTestCase {
|
||||||
'protocol' => 'tcp',
|
'protocol' => 'tcp',
|
||||||
'port' => 80,
|
'port' => 80,
|
||||||
'timeout' => 30,
|
'timeout' => 30,
|
||||||
'redirect' => false,
|
|
||||||
'request' => array(
|
'request' => array(
|
||||||
'uri' => array(
|
'uri' => array(
|
||||||
'scheme' => 'http',
|
'scheme' => 'http',
|
||||||
'host' => 'www.foo.com',
|
'host' => 'www.foo.com',
|
||||||
'port' => 80
|
'port' => 80
|
||||||
),
|
),
|
||||||
|
'redirect' => false,
|
||||||
'cookies' => array()
|
'cookies' => array()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -318,13 +318,13 @@ class HttpSocketTest extends CakeTestCase {
|
||||||
'protocol' => 'tcp',
|
'protocol' => 'tcp',
|
||||||
'port' => 80,
|
'port' => 80,
|
||||||
'timeout' => 30,
|
'timeout' => 30,
|
||||||
'redirect' => false,
|
|
||||||
'request' => array(
|
'request' => array(
|
||||||
'uri' => array (
|
'uri' => array (
|
||||||
'scheme' => 'http',
|
'scheme' => 'http',
|
||||||
'host' => 'www.cakephp.org',
|
'host' => 'www.cakephp.org',
|
||||||
'port' => 80
|
'port' => 80
|
||||||
),
|
),
|
||||||
|
'redirect' => false,
|
||||||
'cookies' => array()
|
'cookies' => array()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -345,6 +345,7 @@ class HttpSocketTest extends CakeTestCase {
|
||||||
'line' => "GET /?foo=bar HTTP/1.1\r\n",
|
'line' => "GET /?foo=bar HTTP/1.1\r\n",
|
||||||
'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n",
|
'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n",
|
||||||
'raw' => "",
|
'raw' => "",
|
||||||
|
'redirect' => false,
|
||||||
'cookies' => array(),
|
'cookies' => array(),
|
||||||
'proxy' => array(),
|
'proxy' => array(),
|
||||||
'auth' => array()
|
'auth' => array()
|
||||||
|
@ -722,20 +723,51 @@ class HttpSocketTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRequestWithRedirect() {
|
public function testRequestWithRedirectAsTrue() {
|
||||||
$request = array(
|
$request = array(
|
||||||
'uri' => 'http://localhost/oneuri'
|
'uri' => 'http://localhost/oneuri',
|
||||||
|
'redirect' => true
|
||||||
);
|
);
|
||||||
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
|
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
|
||||||
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>You have been redirected</h1>";
|
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>You have been redirected</h1>";
|
||||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
|
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
|
||||||
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
|
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
|
||||||
$this->Socket->config['redirect'] = true;
|
|
||||||
|
|
||||||
$response = $this->Socket->request($request);
|
$response = $this->Socket->request($request);
|
||||||
$this->assertEquals('<h1>You have been redirected</h1>', $response->body());
|
$this->assertEquals('<h1>You have been redirected</h1>', $response->body());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRequestWithRedirectAsInt() {
|
||||||
|
$request = array(
|
||||||
|
'uri' => 'http://localhost/oneuri',
|
||||||
|
'redirect' => 2
|
||||||
|
);
|
||||||
|
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
|
||||||
|
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>You have been redirected</h1>";
|
||||||
|
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
|
||||||
|
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
|
||||||
|
|
||||||
|
$response = $this->Socket->request($request);
|
||||||
|
$this->assertEquals(1, $this->Socket->request['redirect']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRequestWithRedirectAsIntReachingZero() {
|
||||||
|
$request = array(
|
||||||
|
'uri' => 'http://localhost/oneuri',
|
||||||
|
'redirect' => 1
|
||||||
|
);
|
||||||
|
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/oneruri\r\n\r\n";
|
||||||
|
$serverResponse2 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
|
||||||
|
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
|
||||||
|
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
|
||||||
|
|
||||||
|
$response = $this->Socket->request($request);
|
||||||
|
$this->assertEquals(0, $this->Socket->request['redirect']);
|
||||||
|
$this->assertEquals(302, $response->code);
|
||||||
|
$this->assertEquals('http://localhost/anotheruri', $response->getHeader('Location'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testProxy method
|
* testProxy method
|
||||||
*
|
*
|
||||||
|
|
|
@ -75,15 +75,15 @@ class FolderTest extends CakeTestCase {
|
||||||
$Folder = new Folder($path);
|
$Folder = new Folder($path);
|
||||||
|
|
||||||
$result = $Folder->pwd();
|
$result = $Folder->pwd();
|
||||||
$this->assertEqual($result, $path);
|
$this->assertEquals($result, $path);
|
||||||
|
|
||||||
$result = Folder::addPathElement($path, 'test');
|
$result = Folder::addPathElement($path, 'test');
|
||||||
$expected = $path . DS . 'test';
|
$expected = $path . DS . 'test';
|
||||||
$this->assertEqual($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $Folder->cd(ROOT);
|
$result = $Folder->cd(ROOT);
|
||||||
$expected = ROOT;
|
$expected = ROOT;
|
||||||
$this->assertEqual($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $Folder->cd(ROOT . DS . 'non-existent');
|
$result = $Folder->cd(ROOT . DS . 'non-existent');
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
@ -101,13 +101,13 @@ class FolderTest extends CakeTestCase {
|
||||||
$Folder = new Folder($path);
|
$Folder = new Folder($path);
|
||||||
|
|
||||||
$result = $Folder->pwd();
|
$result = $Folder->pwd();
|
||||||
$this->assertEqual($result, $path);
|
$this->assertEquals($result, $path);
|
||||||
|
|
||||||
$result = Folder::isSlashTerm($inside);
|
$result = Folder::isSlashTerm($inside);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
|
||||||
$result = $Folder->realpath('Test/');
|
$result = $Folder->realpath('Test/');
|
||||||
$this->assertEqual($result, $path . DS .'Test' . DS);
|
$this->assertEquals($result, $path . DS .'Test' . DS);
|
||||||
|
|
||||||
$result = $Folder->inPath('Test' . DS);
|
$result = $Folder->inPath('Test' . DS);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@ -230,7 +230,7 @@ class FolderTest extends CakeTestCase {
|
||||||
|
|
||||||
$expected = $new . ' is a file';
|
$expected = $new . ' is a file';
|
||||||
$result = $Folder->errors();
|
$result = $Folder->errors();
|
||||||
$this->assertEqual($result[0], $expected);
|
$this->assertEquals($result[0], $expected);
|
||||||
|
|
||||||
$new = TMP . 'test_folder_new';
|
$new = TMP . 'test_folder_new';
|
||||||
$result = $Folder->create($new);
|
$result = $Folder->create($new);
|
||||||
|
@ -268,10 +268,25 @@ class FolderTest extends CakeTestCase {
|
||||||
$filePath = $new . DS . 'test1.php';
|
$filePath = $new . DS . 'test1.php';
|
||||||
$File = new File($filePath);
|
$File = new File($filePath);
|
||||||
$this->assertTrue($File->create());
|
$this->assertTrue($File->create());
|
||||||
$copy = TMP . 'test_folder_copy';
|
|
||||||
|
|
||||||
$this->assertTrue($Folder->chmod($new, 0777, true));
|
$filePath = $new . DS . 'skip_me.php';
|
||||||
$this->assertEqual($File->perms(), '0777');
|
$File = new File($filePath);
|
||||||
|
$this->assertTrue($File->create());
|
||||||
|
|
||||||
|
$this->assertTrue($Folder->chmod($new, 0755, true));
|
||||||
|
$this->assertTrue($Folder->chmod($new, 0777, true, array('skip_me.php', 'test2')));
|
||||||
|
|
||||||
|
$perms = substr(sprintf('%o', fileperms($new . DS . 'test1')), -4);
|
||||||
|
$this->assertEquals($perms, '0777');
|
||||||
|
|
||||||
|
$perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4);
|
||||||
|
$this->assertEquals($perms, '0755');
|
||||||
|
|
||||||
|
$perms = substr(sprintf('%o', fileperms($new . DS . 'test1.php')), -4);
|
||||||
|
$this->assertEquals($perms, '0777');
|
||||||
|
|
||||||
|
$perms = substr(sprintf('%o', fileperms($new . DS . 'skip_me.php')), -4);
|
||||||
|
$this->assertEquals($perms, '0755');
|
||||||
|
|
||||||
$Folder->delete($new);
|
$Folder->delete($new);
|
||||||
}
|
}
|
||||||
|
@ -283,7 +298,7 @@ class FolderTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testRealPathForWebroot() {
|
public function testRealPathForWebroot() {
|
||||||
$Folder = new Folder('files/');
|
$Folder = new Folder('files/');
|
||||||
$this->assertEqual(realpath('files/'), $Folder->path);
|
$this->assertEquals(realpath('files/'), $Folder->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,11 +313,11 @@ class FolderTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $Folder->read(true, true);
|
$result = $Folder->read(true, true);
|
||||||
$expected = array('0', 'cache', 'logs', 'sessions', 'tests');
|
$expected = array('0', 'cache', 'logs', 'sessions', 'tests');
|
||||||
$this->assertEqual($expected, $result[0]);
|
$this->assertEquals($expected, $result[0]);
|
||||||
|
|
||||||
$result = $Folder->read(true, array('logs'));
|
$result = $Folder->read(true, array('logs'));
|
||||||
$expected = array('0', 'cache', 'sessions', 'tests');
|
$expected = array('0', 'cache', 'sessions', 'tests');
|
||||||
$this->assertEqual($expected, $result[0]);
|
$this->assertEquals($expected, $result[0]);
|
||||||
|
|
||||||
$result = $Folder->delete($new);
|
$result = $Folder->delete($new);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@ -315,10 +330,10 @@ class FolderTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testAddPathElement() {
|
public function testAddPathElement() {
|
||||||
$result = Folder::addPathElement(DS . 'some' . DS . 'dir', 'another_path');
|
$result = Folder::addPathElement(DS . 'some' . DS . 'dir', 'another_path');
|
||||||
$this->assertEqual($result, DS . 'some' . DS . 'dir' . DS . 'another_path');
|
$this->assertEquals($result, DS . 'some' . DS . 'dir' . DS . 'another_path');
|
||||||
|
|
||||||
$result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, 'another_path');
|
$result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, 'another_path');
|
||||||
$this->assertEqual($result, DS . 'some' . DS . 'dir' . DS . 'another_path');
|
$this->assertEquals($result, DS . 'some' . DS . 'dir' . DS . 'another_path');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testFolderRead method
|
* testFolderRead method
|
||||||
|
@ -330,12 +345,12 @@ class FolderTest extends CakeTestCase {
|
||||||
|
|
||||||
$expected = array('cache', 'logs', 'sessions', 'tests');
|
$expected = array('cache', 'logs', 'sessions', 'tests');
|
||||||
$result = $Folder->read(true, true);
|
$result = $Folder->read(true, true);
|
||||||
$this->assertEqual($result[0], $expected);
|
$this->assertEquals($result[0], $expected);
|
||||||
|
|
||||||
$Folder->path = TMP . 'non-existent';
|
$Folder->path = TMP . 'non-existent';
|
||||||
$expected = array(array(), array());
|
$expected = array(array(), array());
|
||||||
$result = $Folder->read(true, true);
|
$result = $Folder->read(true, true);
|
||||||
$this->assertEqual($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -438,7 +453,7 @@ class FolderTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testSlashTerm() {
|
public function testSlashTerm() {
|
||||||
$result = Folder::slashTerm('/path/to/file');
|
$result = Folder::slashTerm('/path/to/file');
|
||||||
$this->assertEqual($result, '/path/to/file/');
|
$this->assertEquals($result, '/path/to/file/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -449,15 +464,15 @@ class FolderTest extends CakeTestCase {
|
||||||
public function testNormalizePath() {
|
public function testNormalizePath() {
|
||||||
$path = '/path/to/file';
|
$path = '/path/to/file';
|
||||||
$result = Folder::normalizePath($path);
|
$result = Folder::normalizePath($path);
|
||||||
$this->assertEqual($result, '/');
|
$this->assertEquals($result, '/');
|
||||||
|
|
||||||
$path = '\\path\\\to\\\file';
|
$path = '\\path\\\to\\\file';
|
||||||
$result = Folder::normalizePath($path);
|
$result = Folder::normalizePath($path);
|
||||||
$this->assertEqual($result, '/');
|
$this->assertEquals($result, '/');
|
||||||
|
|
||||||
$path = 'C:\\path\\to\\file';
|
$path = 'C:\\path\\to\\file';
|
||||||
$result = Folder::normalizePath($path);
|
$result = Folder::normalizePath($path);
|
||||||
$this->assertEqual($result, '\\');
|
$this->assertEquals($result, '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -468,15 +483,15 @@ class FolderTest extends CakeTestCase {
|
||||||
public function testCorrectSlashFor() {
|
public function testCorrectSlashFor() {
|
||||||
$path = '/path/to/file';
|
$path = '/path/to/file';
|
||||||
$result = Folder::correctSlashFor($path);
|
$result = Folder::correctSlashFor($path);
|
||||||
$this->assertEqual($result, '/');
|
$this->assertEquals($result, '/');
|
||||||
|
|
||||||
$path = '\\path\\to\\file';
|
$path = '\\path\\to\\file';
|
||||||
$result = Folder::correctSlashFor($path);
|
$result = Folder::correctSlashFor($path);
|
||||||
$this->assertEqual($result, '/');
|
$this->assertEquals($result, '/');
|
||||||
|
|
||||||
$path = 'C:\\path\to\\file';
|
$path = 'C:\\path\to\\file';
|
||||||
$result = Folder::correctSlashFor($path);
|
$result = Folder::correctSlashFor($path);
|
||||||
$this->assertEqual($result, '\\');
|
$this->assertEquals($result, '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -630,13 +645,13 @@ class FolderTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testDirSize() {
|
public function testDirSize() {
|
||||||
$Folder = new Folder(TMP . 'config_non_existant', true);
|
$Folder = new Folder(TMP . 'config_non_existant', true);
|
||||||
$this->assertEqual($Folder->dirSize(), 0);
|
$this->assertEquals($Folder->dirSize(), 0);
|
||||||
|
|
||||||
$File = new File($Folder->pwd() . DS . 'my.php', true, 0777);
|
$File = new File($Folder->pwd() . DS . 'my.php', true, 0777);
|
||||||
$File->create();
|
$File->create();
|
||||||
$File->write('something here');
|
$File->write('something here');
|
||||||
$File->close();
|
$File->close();
|
||||||
$this->assertEqual($Folder->dirSize(), 14);
|
$this->assertEquals($Folder->dirSize(), 14);
|
||||||
|
|
||||||
$Folder->cd(TMP);
|
$Folder->cd(TMP);
|
||||||
$Folder->delete($Folder->pwd() . 'config_non_existant');
|
$Folder->delete($Folder->pwd() . 'config_non_existant');
|
||||||
|
@ -666,7 +681,7 @@ class FolderTest extends CakeTestCase {
|
||||||
$path . DS . 'file2 removed',
|
$path . DS . 'file2 removed',
|
||||||
$path . ' removed'
|
$path . ' removed'
|
||||||
);
|
);
|
||||||
$this->assertEqual($expected, $messages);
|
$this->assertEquals($expected, $messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -720,7 +735,7 @@ class FolderTest extends CakeTestCase {
|
||||||
$result = $Folder->copy($folder3);
|
$result = $Folder->copy($folder3);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
|
$this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
|
||||||
$this->assertEqual(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched');
|
$this->assertEquals(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched');
|
||||||
|
|
||||||
$Folder = new Folder($path);
|
$Folder = new Folder($path);
|
||||||
$Folder->delete();
|
$Folder->delete();
|
||||||
|
@ -794,7 +809,7 @@ class FolderTest extends CakeTestCase {
|
||||||
$result = $Folder->move($folder3);
|
$result = $Folder->move($folder3);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
|
$this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
|
||||||
$this->assertEqual(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched');
|
$this->assertEquals(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched');
|
||||||
$this->assertFalse(file_exists($file1));
|
$this->assertFalse(file_exists($file1));
|
||||||
$this->assertFalse(file_exists($folder2));
|
$this->assertFalse(file_exists($folder2));
|
||||||
$this->assertFalse(file_exists($file2));
|
$this->assertFalse(file_exists($file2));
|
||||||
|
|
|
@ -80,6 +80,7 @@ class SessionHelperTest extends CakeTestCase {
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
$_SESSION = array();
|
$_SESSION = array();
|
||||||
unset($this->View, $this->Session);
|
unset($this->View, $this->Session);
|
||||||
|
CakePlugin::unload();
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +161,7 @@ class SessionHelperTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testFlashElementInAttrs() {
|
public function testFlashElementInAttrs() {
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'views' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
|
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
|
||||||
));
|
));
|
||||||
$result = $this->Session->flash('flash', array(
|
$result = $this->Session->flash('flash', array(
|
||||||
'element' => 'session_helper',
|
'element' => 'session_helper',
|
||||||
|
@ -168,4 +169,23 @@ class SessionHelperTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
$expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a calling</p>\n</div>";
|
$expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a calling</p>\n</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test using eleents in plugins.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testFlashWithPluginElement() {
|
||||||
|
App::build(array(
|
||||||
|
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'. DS)
|
||||||
|
));
|
||||||
|
CakePlugin::load('TestPlugin');
|
||||||
|
|
||||||
|
$result = $this->Session->flash('flash', array(
|
||||||
|
'element' => 'plugin_element',
|
||||||
|
'params' => array('plugin' => 'TestPlugin')
|
||||||
|
));
|
||||||
|
$expected = 'this is the plugin element using params[plugin]';
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,6 +170,13 @@ class TestAfterHelper extends Helper {
|
||||||
*/
|
*/
|
||||||
class ViewTest extends CakeTestCase {
|
class ViewTest extends CakeTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixtures used in this test.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $fixtures = array('core.user', 'core.post');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUp method
|
* setUp method
|
||||||
*
|
*
|
||||||
|
@ -190,7 +197,7 @@ class ViewTest extends CakeTestCase {
|
||||||
CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS
|
CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS
|
||||||
)
|
)
|
||||||
), true);
|
), true);
|
||||||
CakePlugin::loadAll();
|
CakePlugin::load(array('TestPlugin', 'TestPlugin', 'PluginJs'));
|
||||||
Configure::write('debug', 2);
|
Configure::write('debug', 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,14 +583,14 @@ class ViewTest extends CakeTestCase {
|
||||||
$View->Helpers = $this->getMock('HelperCollection', array('trigger'), array($View));
|
$View->Helpers = $this->getMock('HelperCollection', array('trigger'), array($View));
|
||||||
|
|
||||||
$View->Helpers->expects($this->at(0))->method('trigger')
|
$View->Helpers->expects($this->at(0))->method('trigger')
|
||||||
->with('beforeRender', new PHPUnit_Framework_Constraint_IsAnything());
|
->with('beforeRender', $this->anything());
|
||||||
$View->Helpers->expects($this->at(1))->method('trigger')
|
$View->Helpers->expects($this->at(1))->method('trigger')
|
||||||
->with('afterRender', new PHPUnit_Framework_Constraint_IsAnything());
|
->with('afterRender', $this->anything());
|
||||||
|
|
||||||
$View->Helpers->expects($this->at(2))->method('trigger')
|
$View->Helpers->expects($this->at(2))->method('trigger')
|
||||||
->with('beforeLayout', new PHPUnit_Framework_Constraint_IsAnything());
|
->with('beforeLayout', $this->anything());
|
||||||
$View->Helpers->expects($this->at(3))->method('trigger')
|
$View->Helpers->expects($this->at(3))->method('trigger')
|
||||||
->with('afterLayout', new PHPUnit_Framework_Constraint_IsAnything());
|
->with('afterLayout', $this->anything());
|
||||||
|
|
||||||
$View->render('index');
|
$View->render('index');
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,23 +5,23 @@ class Test2OtherSource extends DataSource {
|
||||||
return compact('model');
|
return compact('model');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listSources() {
|
public function listSources($data = null) {
|
||||||
return array('test_source');
|
return array('test_source');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($model, $fields = array(), $values = array()) {
|
public function create(Model $model, $fields = null, $values = null) {
|
||||||
return compact('model', 'fields', 'values');
|
return compact('model', 'fields', 'values');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read($model, $queryData = array()) {
|
public function read(Model $model, $queryData = array()) {
|
||||||
return compact('model', 'queryData');
|
return compact('model', 'queryData');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($model, $fields = array(), $values = array()) {
|
public function update(Model $model, $fields = array(), $values = array()) {
|
||||||
return compact('model', 'fields', 'values');
|
return compact('model', 'fields', 'values');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($model, $id) {
|
public function delete(Model $model, $id = null) {
|
||||||
return compact('model', 'id');
|
return compact('model', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,23 +5,23 @@ class Test2Source extends DataSource {
|
||||||
return compact('model');
|
return compact('model');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listSources() {
|
public function listSources($data = null) {
|
||||||
return array('test_source');
|
return array('test_source');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($model, $fields = array(), $values = array()) {
|
public function create(Model $model, $fields = null, $values = null) {
|
||||||
return compact('model', 'fields', 'values');
|
return compact('model', 'fields', 'values');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read($model, $queryData = array()) {
|
public function read(Model $model, $queryData = array()) {
|
||||||
return compact('model', 'queryData');
|
return compact('model', 'queryData');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($model, $fields = array(), $values = array()) {
|
public function update(Model $model, $fields = array(), $values = array()) {
|
||||||
return compact('model', 'fields', 'values');
|
return compact('model', 'fields', 'values');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($model, $id) {
|
public function delete(Model $model, $id = null) {
|
||||||
return compact('model', 'id');
|
return compact('model', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,23 +7,23 @@ class TestSource extends DataSource {
|
||||||
return compact('model');
|
return compact('model');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listSources() {
|
public function listSources($data = null) {
|
||||||
return array('test_source');
|
return array('test_source');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($model, $fields = array(), $values = array()) {
|
public function create(Model $model, $fields = array(), $values = array()) {
|
||||||
return compact('model', 'fields', 'values');
|
return compact('model', 'fields', 'values');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read($model, $queryData = array()) {
|
public function read(Model $model, $queryData = array()) {
|
||||||
return compact('model', 'queryData');
|
return compact('model', 'queryData');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($model, $fields = array(), $values = array()) {
|
public function update(Model $model, $fields = array(), $values = array()) {
|
||||||
return compact('model', 'fields', 'values');
|
return compact('model', 'fields', 'values');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($model, $id) {
|
public function delete(Model $model, $id = null) {
|
||||||
return compact('model', 'id');
|
return compact('model', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,23 +5,23 @@ class TestOtherSource extends DataSource {
|
||||||
return compact('model');
|
return compact('model');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listSources() {
|
public function listSources($data = null) {
|
||||||
return array('test_source');
|
return array('test_source');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($model, $fields = array(), $values = array()) {
|
public function create(Model $model, $fields = null, $values = array()) {
|
||||||
return compact('model', 'fields', 'values');
|
return compact('model', 'fields', 'values');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read($model, $queryData = array()) {
|
public function read(Model $model, $queryData = array()) {
|
||||||
return compact('model', 'queryData');
|
return compact('model', 'queryData');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($model, $fields = array(), $values = array()) {
|
public function update(Model $model, $fields = array(), $values = array()) {
|
||||||
return compact('model', 'fields', 'values');
|
return compact('model', 'fields', 'values');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($model, $id) {
|
public function delete(Model $model, $id = null) {
|
||||||
return compact('model', 'id');
|
return compact('model', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,12 +133,12 @@ class ClassRegistry {
|
||||||
App::uses($class, $pluginPath . 'Model');
|
App::uses($class, $pluginPath . 'Model');
|
||||||
|
|
||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
${$class} = new $class($settings);
|
$instance = new $class($settings);
|
||||||
if ($strict) {
|
if ($strict) {
|
||||||
${$class} = (${$class} instanceof Model) ? ${$class} : null;
|
$instance = ($instance instanceof Model) ? $instance : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isset(${$class})) {
|
if (!isset($instance)) {
|
||||||
if ($strict) {
|
if ($strict) {
|
||||||
return false;
|
return false;
|
||||||
} elseif ($plugin && class_exists($plugin . 'AppModel')) {
|
} elseif ($plugin && class_exists($plugin . 'AppModel')) {
|
||||||
|
@ -148,10 +148,10 @@ class ClassRegistry {
|
||||||
}
|
}
|
||||||
if (!empty($appModel)) {
|
if (!empty($appModel)) {
|
||||||
$settings['name'] = $class;
|
$settings['name'] = $class;
|
||||||
${$class} = new $appModel($settings);
|
$instance = new $appModel($settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset(${$class})) {
|
if (!isset($instance)) {
|
||||||
trigger_error(__d('cake_dev', '(ClassRegistry::init() could not create instance of %1$s class %2$s ', $class, $type), E_USER_WARNING);
|
trigger_error(__d('cake_dev', '(ClassRegistry::init() could not create instance of %1$s class %2$s ', $class, $type), E_USER_WARNING);
|
||||||
return $false;
|
return $false;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ class ClassRegistry {
|
||||||
if ($count > 1) {
|
if ($count > 1) {
|
||||||
return $true;
|
return $true;
|
||||||
}
|
}
|
||||||
return ${$class};
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -80,6 +80,7 @@ class File {
|
||||||
* @param string $path Path to file
|
* @param string $path Path to file
|
||||||
* @param boolean $create Create file if it does not exist (if true)
|
* @param boolean $create Create file if it does not exist (if true)
|
||||||
* @param integer $mode Mode to apply to the folder holding the file
|
* @param integer $mode Mode to apply to the folder holding the file
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File
|
||||||
*/
|
*/
|
||||||
public function __construct($path, $create = false, $mode = 0755) {
|
public function __construct($path, $create = false, $mode = 0755) {
|
||||||
$this->Folder = new Folder(dirname($path), $create, $mode);
|
$this->Folder = new Folder(dirname($path), $create, $mode);
|
||||||
|
@ -102,6 +103,7 @@ class File {
|
||||||
* Creates the File.
|
* Creates the File.
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::create
|
||||||
*/
|
*/
|
||||||
public function create() {
|
public function create() {
|
||||||
$dir = $this->Folder->pwd();
|
$dir = $this->Folder->pwd();
|
||||||
|
@ -121,6 +123,7 @@ class File {
|
||||||
* @param string $mode A valid 'fopen' mode string (r|w|a ...)
|
* @param string $mode A valid 'fopen' mode string (r|w|a ...)
|
||||||
* @param boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
|
* @param boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
|
||||||
* @return boolean True on success, false on failure
|
* @return boolean True on success, false on failure
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::open
|
||||||
*/
|
*/
|
||||||
public function open($mode = 'r', $force = false) {
|
public function open($mode = 'r', $force = false) {
|
||||||
if (!$force && is_resource($this->handle)) {
|
if (!$force && is_resource($this->handle)) {
|
||||||
|
@ -147,6 +150,7 @@ class File {
|
||||||
* @param string $mode A `fread` compatible mode.
|
* @param string $mode A `fread` compatible mode.
|
||||||
* @param boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
|
* @param boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
|
||||||
* @return mixed string on success, false on failure
|
* @return mixed string on success, false on failure
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::read
|
||||||
*/
|
*/
|
||||||
public function read($bytes = false, $mode = 'rb', $force = false) {
|
public function read($bytes = false, $mode = 'rb', $force = false) {
|
||||||
if ($bytes === false && $this->lock === null) {
|
if ($bytes === false && $this->lock === null) {
|
||||||
|
@ -182,6 +186,7 @@ class File {
|
||||||
* @param mixed $offset The $offset in bytes to seek. If set to false then the current offset is returned.
|
* @param mixed $offset The $offset in bytes to seek. If set to false then the current offset is returned.
|
||||||
* @param integer $seek PHP Constant SEEK_SET | SEEK_CUR | SEEK_END determining what the $offset is relative to
|
* @param integer $seek PHP Constant SEEK_SET | SEEK_CUR | SEEK_END determining what the $offset is relative to
|
||||||
* @return mixed True on success, false on failure (set mode), false on failure or integer offset on success (get mode)
|
* @return mixed True on success, false on failure (set mode), false on failure or integer offset on success (get mode)
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::offset
|
||||||
*/
|
*/
|
||||||
public function offset($offset = false, $seek = SEEK_SET) {
|
public function offset($offset = false, $seek = SEEK_SET) {
|
||||||
if ($offset === false) {
|
if ($offset === false) {
|
||||||
|
@ -202,6 +207,7 @@ class File {
|
||||||
* @param string $data Data to prepare for writing.
|
* @param string $data Data to prepare for writing.
|
||||||
* @param boolean $forceWindows
|
* @param boolean $forceWindows
|
||||||
* @return string The with converted line endings.
|
* @return string The with converted line endings.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::prepare
|
||||||
*/
|
*/
|
||||||
public static function prepare($data, $forceWindows = false) {
|
public static function prepare($data, $forceWindows = false) {
|
||||||
$lineBreak = "\n";
|
$lineBreak = "\n";
|
||||||
|
@ -218,6 +224,7 @@ class File {
|
||||||
* @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}.
|
* @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}.
|
||||||
* @param string $force force the file to open
|
* @param string $force force the file to open
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::write
|
||||||
*/
|
*/
|
||||||
public function write($data, $mode = 'w', $force = false) {
|
public function write($data, $mode = 'w', $force = false) {
|
||||||
$success = false;
|
$success = false;
|
||||||
|
@ -244,6 +251,7 @@ class File {
|
||||||
* @param string $data Data to write
|
* @param string $data Data to write
|
||||||
* @param string $force force the file to open
|
* @param string $force force the file to open
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::append
|
||||||
*/
|
*/
|
||||||
public function append($data, $force = false) {
|
public function append($data, $force = false) {
|
||||||
return $this->write($data, 'a', $force);
|
return $this->write($data, 'a', $force);
|
||||||
|
@ -253,6 +261,7 @@ class File {
|
||||||
* Closes the current file if it is opened.
|
* Closes the current file if it is opened.
|
||||||
*
|
*
|
||||||
* @return boolean True if closing was successful or file was already closed, otherwise false
|
* @return boolean True if closing was successful or file was already closed, otherwise false
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::close
|
||||||
*/
|
*/
|
||||||
public function close() {
|
public function close() {
|
||||||
if (!is_resource($this->handle)) {
|
if (!is_resource($this->handle)) {
|
||||||
|
@ -265,6 +274,7 @@ class File {
|
||||||
* Deletes the File.
|
* Deletes the File.
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::delete
|
||||||
*/
|
*/
|
||||||
public function delete() {
|
public function delete() {
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
@ -282,6 +292,7 @@ class File {
|
||||||
* Returns the File info.
|
* Returns the File info.
|
||||||
*
|
*
|
||||||
* @return string The File extension
|
* @return string The File extension
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::info
|
||||||
*/
|
*/
|
||||||
public function info() {
|
public function info() {
|
||||||
if ($this->info == null) {
|
if ($this->info == null) {
|
||||||
|
@ -300,6 +311,7 @@ class File {
|
||||||
* Returns the File extension.
|
* Returns the File extension.
|
||||||
*
|
*
|
||||||
* @return string The File extension
|
* @return string The File extension
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::ext
|
||||||
*/
|
*/
|
||||||
public function ext() {
|
public function ext() {
|
||||||
if ($this->info == null) {
|
if ($this->info == null) {
|
||||||
|
@ -315,6 +327,7 @@ class File {
|
||||||
* Returns the File name without extension.
|
* Returns the File name without extension.
|
||||||
*
|
*
|
||||||
* @return string The File name without extension.
|
* @return string The File name without extension.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::name
|
||||||
*/
|
*/
|
||||||
public function name() {
|
public function name() {
|
||||||
if ($this->info == null) {
|
if ($this->info == null) {
|
||||||
|
@ -334,6 +347,7 @@ class File {
|
||||||
* @param string $name The name of the file to make safe if different from $this->name
|
* @param string $name The name of the file to make safe if different from $this->name
|
||||||
* @param string $ext The name of the extension to make safe if different from $this->ext
|
* @param string $ext The name of the extension to make safe if different from $this->ext
|
||||||
* @return string $ext the extension of the file
|
* @return string $ext the extension of the file
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::safe
|
||||||
*/
|
*/
|
||||||
public function safe($name = null, $ext = null) {
|
public function safe($name = null, $ext = null) {
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
|
@ -350,6 +364,7 @@ class File {
|
||||||
*
|
*
|
||||||
* @param mixed $maxsize in MB or true to force
|
* @param mixed $maxsize in MB or true to force
|
||||||
* @return string md5 Checksum {@link http://php.net/md5_file See md5_file()}
|
* @return string md5 Checksum {@link http://php.net/md5_file See md5_file()}
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::md5
|
||||||
*/
|
*/
|
||||||
public function md5($maxsize = 5) {
|
public function md5($maxsize = 5) {
|
||||||
if ($maxsize === true) {
|
if ($maxsize === true) {
|
||||||
|
@ -368,6 +383,7 @@ class File {
|
||||||
* Returns the full path of the File.
|
* Returns the full path of the File.
|
||||||
*
|
*
|
||||||
* @return string Full path to file
|
* @return string Full path to file
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd
|
||||||
*/
|
*/
|
||||||
public function pwd() {
|
public function pwd() {
|
||||||
if (is_null($this->path)) {
|
if (is_null($this->path)) {
|
||||||
|
@ -380,6 +396,7 @@ class File {
|
||||||
* Returns true if the File exists.
|
* Returns true if the File exists.
|
||||||
*
|
*
|
||||||
* @return boolean true if it exists, false otherwise
|
* @return boolean true if it exists, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::exists
|
||||||
*/
|
*/
|
||||||
public function exists() {
|
public function exists() {
|
||||||
return (file_exists($this->path) && is_file($this->path));
|
return (file_exists($this->path) && is_file($this->path));
|
||||||
|
@ -389,6 +406,7 @@ class File {
|
||||||
* Returns the "chmod" (permissions) of the File.
|
* Returns the "chmod" (permissions) of the File.
|
||||||
*
|
*
|
||||||
* @return string Permissions for the file
|
* @return string Permissions for the file
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::perms
|
||||||
*/
|
*/
|
||||||
public function perms() {
|
public function perms() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -401,6 +419,7 @@ class File {
|
||||||
* Returns the Filesize
|
* Returns the Filesize
|
||||||
*
|
*
|
||||||
* @return integer size of the file in bytes, or false in case of an error
|
* @return integer size of the file in bytes, or false in case of an error
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::size
|
||||||
*/
|
*/
|
||||||
public function size() {
|
public function size() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -413,6 +432,7 @@ class File {
|
||||||
* Returns true if the File is writable.
|
* Returns true if the File is writable.
|
||||||
*
|
*
|
||||||
* @return boolean true if its writable, false otherwise
|
* @return boolean true if its writable, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::writable
|
||||||
*/
|
*/
|
||||||
public function writable() {
|
public function writable() {
|
||||||
return is_writable($this->path);
|
return is_writable($this->path);
|
||||||
|
@ -422,6 +442,7 @@ class File {
|
||||||
* Returns true if the File is executable.
|
* Returns true if the File is executable.
|
||||||
*
|
*
|
||||||
* @return boolean true if its executable, false otherwise
|
* @return boolean true if its executable, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::executable
|
||||||
*/
|
*/
|
||||||
public function executable() {
|
public function executable() {
|
||||||
return is_executable($this->path);
|
return is_executable($this->path);
|
||||||
|
@ -431,6 +452,7 @@ class File {
|
||||||
* Returns true if the File is readable.
|
* Returns true if the File is readable.
|
||||||
*
|
*
|
||||||
* @return boolean true if file is readable, false otherwise
|
* @return boolean true if file is readable, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::readable
|
||||||
*/
|
*/
|
||||||
public function readable() {
|
public function readable() {
|
||||||
return is_readable($this->path);
|
return is_readable($this->path);
|
||||||
|
@ -440,6 +462,7 @@ class File {
|
||||||
* Returns the File's owner.
|
* Returns the File's owner.
|
||||||
*
|
*
|
||||||
* @return integer the Fileowner
|
* @return integer the Fileowner
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::owner
|
||||||
*/
|
*/
|
||||||
public function owner() {
|
public function owner() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -452,6 +475,7 @@ class File {
|
||||||
* Returns the File's group.
|
* Returns the File's group.
|
||||||
*
|
*
|
||||||
* @return integer the Filegroup
|
* @return integer the Filegroup
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::group
|
||||||
*/
|
*/
|
||||||
public function group() {
|
public function group() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -464,6 +488,7 @@ class File {
|
||||||
* Returns last access time.
|
* Returns last access time.
|
||||||
*
|
*
|
||||||
* @return integer timestamp Timestamp of last access time
|
* @return integer timestamp Timestamp of last access time
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::lastAccess
|
||||||
*/
|
*/
|
||||||
public function lastAccess() {
|
public function lastAccess() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -476,6 +501,7 @@ class File {
|
||||||
* Returns last modified time.
|
* Returns last modified time.
|
||||||
*
|
*
|
||||||
* @return integer timestamp Timestamp of last modification
|
* @return integer timestamp Timestamp of last modification
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::lastChange
|
||||||
*/
|
*/
|
||||||
public function lastChange() {
|
public function lastChange() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -488,6 +514,7 @@ class File {
|
||||||
* Returns the current folder.
|
* Returns the current folder.
|
||||||
*
|
*
|
||||||
* @return Folder Current folder
|
* @return Folder Current folder
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::Folder
|
||||||
*/
|
*/
|
||||||
public function &Folder() {
|
public function &Folder() {
|
||||||
return $this->Folder;
|
return $this->Folder;
|
||||||
|
@ -498,7 +525,8 @@ class File {
|
||||||
*
|
*
|
||||||
* @param string $dest destination for the copy
|
* @param string $dest destination for the copy
|
||||||
* @param boolean $overwrite Overwrite $dest if exists
|
* @param boolean $overwrite Overwrite $dest if exists
|
||||||
* @return boolean Succes
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::copy
|
||||||
*/
|
*/
|
||||||
public function copy($dest, $overwrite = true) {
|
public function copy($dest, $overwrite = true) {
|
||||||
if (!$this->exists() || is_file($dest) && !$overwrite) {
|
if (!$this->exists() || is_file($dest) && !$overwrite) {
|
||||||
|
|
|
@ -81,6 +81,7 @@ class Folder {
|
||||||
* @param string $path Path to folder
|
* @param string $path Path to folder
|
||||||
* @param boolean $create Create folder if not found
|
* @param boolean $create Create folder if not found
|
||||||
* @param mixed $mode Mode (CHMOD) to apply to created folder, false to ignore
|
* @param mixed $mode Mode (CHMOD) to apply to created folder, false to ignore
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder
|
||||||
*/
|
*/
|
||||||
public function __construct($path = false, $create = false, $mode = false) {
|
public function __construct($path = false, $create = false, $mode = false) {
|
||||||
if (empty($path)) {
|
if (empty($path)) {
|
||||||
|
@ -105,6 +106,7 @@ class Folder {
|
||||||
* Return current path.
|
* Return current path.
|
||||||
*
|
*
|
||||||
* @return string Current path
|
* @return string Current path
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::pwd
|
||||||
*/
|
*/
|
||||||
public function pwd() {
|
public function pwd() {
|
||||||
return $this->path;
|
return $this->path;
|
||||||
|
@ -115,6 +117,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to the directory to change to
|
* @param string $path Path to the directory to change to
|
||||||
* @return string The new path. Returns false on failure
|
* @return string The new path. Returns false on failure
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::cd
|
||||||
*/
|
*/
|
||||||
public function cd($path) {
|
public function cd($path) {
|
||||||
$path = $this->realpath($path);
|
$path = $this->realpath($path);
|
||||||
|
@ -133,6 +136,7 @@ class Folder {
|
||||||
* @param mixed $exceptions Either an array or boolean true will not grab dot files
|
* @param mixed $exceptions Either an array or boolean true will not grab dot files
|
||||||
* @param boolean $fullPath True returns the full path
|
* @param boolean $fullPath True returns the full path
|
||||||
* @return mixed Contents of current directory as an array, an empty array on failure
|
* @return mixed Contents of current directory as an array, an empty array on failure
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::read
|
||||||
*/
|
*/
|
||||||
public function read($sort = true, $exceptions = false, $fullPath = false) {
|
public function read($sort = true, $exceptions = false, $fullPath = false) {
|
||||||
$dirs = $files = array();
|
$dirs = $files = array();
|
||||||
|
@ -181,6 +185,7 @@ class Folder {
|
||||||
* @param string $regexpPattern Preg_match pattern (Defaults to: .*)
|
* @param string $regexpPattern Preg_match pattern (Defaults to: .*)
|
||||||
* @param boolean $sort Whether results should be sorted.
|
* @param boolean $sort Whether results should be sorted.
|
||||||
* @return array Files that match given pattern
|
* @return array Files that match given pattern
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::find
|
||||||
*/
|
*/
|
||||||
public function find($regexpPattern = '.*', $sort = false) {
|
public function find($regexpPattern = '.*', $sort = false) {
|
||||||
list($dirs, $files) = $this->read($sort);
|
list($dirs, $files) = $this->read($sort);
|
||||||
|
@ -193,6 +198,7 @@ class Folder {
|
||||||
* @param string $pattern Preg_match pattern (Defaults to: .*)
|
* @param string $pattern Preg_match pattern (Defaults to: .*)
|
||||||
* @param boolean $sort Whether results should be sorted.
|
* @param boolean $sort Whether results should be sorted.
|
||||||
* @return array Files matching $pattern
|
* @return array Files matching $pattern
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::findRecursive
|
||||||
*/
|
*/
|
||||||
public function findRecursive($pattern = '.*', $sort = false) {
|
public function findRecursive($pattern = '.*', $sort = false) {
|
||||||
if (!$this->pwd()) {
|
if (!$this->pwd()) {
|
||||||
|
@ -234,6 +240,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return boolean true if windows path, false otherwise
|
* @return boolean true if windows path, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isWindowsPath
|
||||||
*/
|
*/
|
||||||
public static function isWindowsPath($path) {
|
public static function isWindowsPath($path) {
|
||||||
return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
||||||
|
@ -244,6 +251,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return boolean true if path is absolute.
|
* @return boolean true if path is absolute.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isAbsolute
|
||||||
*/
|
*/
|
||||||
public static function isAbsolute($path) {
|
public static function isAbsolute($path) {
|
||||||
return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
||||||
|
@ -254,6 +262,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return string Set of slashes ("\\" or "/")
|
* @return string Set of slashes ("\\" or "/")
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::normalizePath
|
||||||
*/
|
*/
|
||||||
public static function normalizePath($path) {
|
public static function normalizePath($path) {
|
||||||
return Folder::correctSlashFor($path);
|
return Folder::correctSlashFor($path);
|
||||||
|
@ -264,6 +273,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return string Set of slashes ("\\" or "/")
|
* @return string Set of slashes ("\\" or "/")
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::correctSlashFor
|
||||||
*/
|
*/
|
||||||
public static function correctSlashFor($path) {
|
public static function correctSlashFor($path) {
|
||||||
return (Folder::isWindowsPath($path)) ? '\\' : '/';
|
return (Folder::isWindowsPath($path)) ? '\\' : '/';
|
||||||
|
@ -274,6 +284,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return string Path with ending slash
|
* @return string Path with ending slash
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::slashTerm
|
||||||
*/
|
*/
|
||||||
public static function slashTerm($path) {
|
public static function slashTerm($path) {
|
||||||
if (Folder::isSlashTerm($path)) {
|
if (Folder::isSlashTerm($path)) {
|
||||||
|
@ -288,6 +299,7 @@ class Folder {
|
||||||
* @param string $path Path
|
* @param string $path Path
|
||||||
* @param string $element Element to and at end of path
|
* @param string $element Element to and at end of path
|
||||||
* @return string Combined path
|
* @return string Combined path
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::addPathElement
|
||||||
*/
|
*/
|
||||||
public static function addPathElement($path, $element) {
|
public static function addPathElement($path, $element) {
|
||||||
return rtrim($path, DS) . DS . $element;
|
return rtrim($path, DS) . DS . $element;
|
||||||
|
@ -298,6 +310,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path The path to check.
|
* @param string $path The path to check.
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::inCakePath
|
||||||
*/
|
*/
|
||||||
public function inCakePath($path = '') {
|
public function inCakePath($path = '') {
|
||||||
$dir = substr(Folder::slashTerm(ROOT), 0, -1);
|
$dir = substr(Folder::slashTerm(ROOT), 0, -1);
|
||||||
|
@ -312,6 +325,7 @@ class Folder {
|
||||||
* @param string $path The path to check that the current pwd() resides with in.
|
* @param string $path The path to check that the current pwd() resides with in.
|
||||||
* @param boolean $reverse
|
* @param boolean $reverse
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::inPath
|
||||||
*/
|
*/
|
||||||
public function inPath($path = '', $reverse = false) {
|
public function inPath($path = '', $reverse = false) {
|
||||||
$dir = Folder::slashTerm($path);
|
$dir = Folder::slashTerm($path);
|
||||||
|
@ -333,6 +347,7 @@ class Folder {
|
||||||
* @param boolean $recursive chmod recursively, set to false to only change the current directory.
|
* @param boolean $recursive chmod recursively, set to false to only change the current directory.
|
||||||
* @param array $exceptions array of files, directories to skip
|
* @param array $exceptions array of files, directories to skip
|
||||||
* @return boolean Returns TRUE on success, FALSE on failure
|
* @return boolean Returns TRUE on success, FALSE on failure
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::chmod
|
||||||
*/
|
*/
|
||||||
public function chmod($path, $mode = false, $recursive = true, $exceptions = array()) {
|
public function chmod($path, $mode = false, $recursive = true, $exceptions = array()) {
|
||||||
if (!$mode) {
|
if (!$mode) {
|
||||||
|
@ -383,6 +398,7 @@ class Folder {
|
||||||
* @param mixed $exceptions Array of files to exclude, defaults to excluding hidden files.
|
* @param mixed $exceptions Array of files to exclude, defaults to excluding hidden files.
|
||||||
* @param string $type either file or dir. null returns both files and directories
|
* @param string $type either file or dir. null returns both files and directories
|
||||||
* @return mixed array of nested directories and files in each directory
|
* @return mixed array of nested directories and files in each directory
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::tree
|
||||||
*/
|
*/
|
||||||
public function tree($path = null, $exceptions = true, $type = null) {
|
public function tree($path = null, $exceptions = true, $type = null) {
|
||||||
if ($path == null) {
|
if ($path == null) {
|
||||||
|
@ -449,6 +465,7 @@ class Folder {
|
||||||
* @param string $pathname The directory structure to create
|
* @param string $pathname The directory structure to create
|
||||||
* @param integer $mode octal value 0755
|
* @param integer $mode octal value 0755
|
||||||
* @return boolean Returns TRUE on success, FALSE on failure
|
* @return boolean Returns TRUE on success, FALSE on failure
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::create
|
||||||
*/
|
*/
|
||||||
public function create($pathname, $mode = false) {
|
public function create($pathname, $mode = false) {
|
||||||
if (is_dir($pathname) || empty($pathname)) {
|
if (is_dir($pathname) || empty($pathname)) {
|
||||||
|
@ -487,6 +504,7 @@ class Folder {
|
||||||
* Returns the size in bytes of this Folder and its contents.
|
* Returns the size in bytes of this Folder and its contents.
|
||||||
*
|
*
|
||||||
* @return integer size in bytes of current folder
|
* @return integer size in bytes of current folder
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::dirsize
|
||||||
*/
|
*/
|
||||||
public function dirsize() {
|
public function dirsize() {
|
||||||
$size = 0;
|
$size = 0;
|
||||||
|
@ -523,6 +541,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path of directory to delete
|
* @param string $path Path of directory to delete
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::delete
|
||||||
*/
|
*/
|
||||||
public function delete($path = null) {
|
public function delete($path = null) {
|
||||||
if (!$path) {
|
if (!$path) {
|
||||||
|
@ -579,6 +598,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param mixed $options Either an array of options (see above) or a string of the destination directory.
|
* @param mixed $options Either an array of options (see above) or a string of the destination directory.
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::copy
|
||||||
*/
|
*/
|
||||||
public function copy($options = array()) {
|
public function copy($options = array()) {
|
||||||
if (!$this->pwd()) {
|
if (!$this->pwd()) {
|
||||||
|
@ -664,6 +684,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param array $options (to, from, chmod, skip)
|
* @param array $options (to, from, chmod, skip)
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::move
|
||||||
*/
|
*/
|
||||||
public function move($options) {
|
public function move($options) {
|
||||||
$to = null;
|
$to = null;
|
||||||
|
@ -688,6 +709,7 @@ class Folder {
|
||||||
* get messages from latest method
|
* get messages from latest method
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::messages
|
||||||
*/
|
*/
|
||||||
public function messages() {
|
public function messages() {
|
||||||
return $this->_messages;
|
return $this->_messages;
|
||||||
|
@ -697,6 +719,7 @@ class Folder {
|
||||||
* get error from latest method
|
* get error from latest method
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::errors
|
||||||
*/
|
*/
|
||||||
public function errors() {
|
public function errors() {
|
||||||
return $this->_errors;
|
return $this->_errors;
|
||||||
|
@ -707,6 +730,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to resolve
|
* @param string $path Path to resolve
|
||||||
* @return string The resolved path
|
* @return string The resolved path
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::realpath
|
||||||
*/
|
*/
|
||||||
public function realpath($path) {
|
public function realpath($path) {
|
||||||
$path = str_replace('/', DS, trim($path));
|
$path = str_replace('/', DS, trim($path));
|
||||||
|
@ -747,6 +771,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return boolean true if path ends with slash, false otherwise
|
* @return boolean true if path ends with slash, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isSlashTerm
|
||||||
*/
|
*/
|
||||||
public static function isSlashTerm($path) {
|
public static function isSlashTerm($path) {
|
||||||
$lastChar = $path[strlen($path) - 1];
|
$lastChar = $path[strlen($path) - 1];
|
||||||
|
|
|
@ -569,6 +569,7 @@ class FormHelper extends AppHelper {
|
||||||
*
|
*
|
||||||
* @param string $name The dot separated name for the field.
|
* @param string $name The dot separated name for the field.
|
||||||
* @return mixed Either null, or the list of fields.
|
* @return mixed Either null, or the list of fields.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::unlockField
|
||||||
*/
|
*/
|
||||||
public function unlockField($name = null) {
|
public function unlockField($name = null) {
|
||||||
if ($name === null) {
|
if ($name === null) {
|
||||||
|
|
|
@ -181,6 +181,7 @@ class HtmlHelper extends AppHelper {
|
||||||
* @param mixed $options Link attributes e.g. array('id'=>'selected')
|
* @param mixed $options Link attributes e.g. array('id'=>'selected')
|
||||||
* @return void
|
* @return void
|
||||||
* @see HtmlHelper::link() for details on $options that can be used.
|
* @see HtmlHelper::link() for details on $options that can be used.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper
|
||||||
*/
|
*/
|
||||||
public function addCrumb($name, $link = null, $options = null) {
|
public function addCrumb($name, $link = null, $options = null) {
|
||||||
$this->_crumbs[] = array($name, $link, $options);
|
$this->_crumbs[] = array($name, $link, $options);
|
||||||
|
@ -615,6 +616,7 @@ class HtmlHelper extends AppHelper {
|
||||||
* @param string $separator Text to separate crumbs.
|
* @param string $separator Text to separate crumbs.
|
||||||
* @param string $startText This will be the first crumb, if false it defaults to first crumb in array
|
* @param string $startText This will be the first crumb, if false it defaults to first crumb in array
|
||||||
* @return string Composed bread crumbs
|
* @return string Composed bread crumbs
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper
|
||||||
*/
|
*/
|
||||||
public function getCrumbs($separator = '»', $startText = false) {
|
public function getCrumbs($separator = '»', $startText = false) {
|
||||||
if (!empty($this->_crumbs)) {
|
if (!empty($this->_crumbs)) {
|
||||||
|
@ -645,6 +647,7 @@ class HtmlHelper extends AppHelper {
|
||||||
*
|
*
|
||||||
* @param array $options Array of html attributes to apply to the generated list elements.
|
* @param array $options Array of html attributes to apply to the generated list elements.
|
||||||
* @return string breadcrumbs html list
|
* @return string breadcrumbs html list
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper
|
||||||
*/
|
*/
|
||||||
public function getCrumbList($options = array()) {
|
public function getCrumbList($options = array()) {
|
||||||
if (!empty($this->_crumbs)) {
|
if (!empty($this->_crumbs)) {
|
||||||
|
@ -975,6 +978,7 @@ class HtmlHelper extends AppHelper {
|
||||||
* @param string $path Path with config file
|
* @param string $path Path with config file
|
||||||
* @return mixed False to error or loaded configs
|
* @return mixed False to error or loaded configs
|
||||||
* @throws ConfigureException
|
* @throws ConfigureException
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#changing-the-tags-output-by-htmlhelper
|
||||||
*/
|
*/
|
||||||
public function loadConfig($configFile, $path = null) {
|
public function loadConfig($configFile, $path = null) {
|
||||||
if (!$path) {
|
if (!$path) {
|
||||||
|
|
|
@ -154,7 +154,10 @@ abstract class JsBaseEngineHelper extends AppHelper {
|
||||||
* @param boolean $quoteString If false, leaves string values unquoted
|
* @param boolean $quoteString If false, leaves string values unquoted
|
||||||
* @return string a JavaScript-safe/JSON representation of $val
|
* @return string a JavaScript-safe/JSON representation of $val
|
||||||
*/
|
*/
|
||||||
public function value($val, $quoteString = true) {
|
public function value($val = array(), $quoteString = null, $key = 'value') {
|
||||||
|
if ($quoteString === null) {
|
||||||
|
$quoteString = true;
|
||||||
|
}
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case (is_array($val) || is_object($val)):
|
case (is_array($val) || is_object($val)):
|
||||||
$val = $this->object($val);
|
$val = $this->object($val);
|
||||||
|
|
|
@ -159,8 +159,12 @@ class JsHelper extends AppHelper {
|
||||||
* @param mixed $val A PHP variable to be converted to JSON
|
* @param mixed $val A PHP variable to be converted to JSON
|
||||||
* @param boolean $quoteString If false, leaves string values unquoted
|
* @param boolean $quoteString If false, leaves string values unquoted
|
||||||
* @return string a JavaScript-safe/JSON representation of $val
|
* @return string a JavaScript-safe/JSON representation of $val
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html#JsHelper::value
|
||||||
**/
|
**/
|
||||||
public function value($val, $quoteString = true) {
|
public function value($val = array(), $quoteString = null, $key = 'value') {
|
||||||
|
if ($quoteString === null) {
|
||||||
|
$quoteString = true;
|
||||||
|
}
|
||||||
return $this->{$this->_engineName}->value($val, $quoteString);
|
return $this->{$this->_engineName}->value($val, $quoteString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +186,7 @@ class JsHelper extends AppHelper {
|
||||||
* @param array $options options for the code block
|
* @param array $options options for the code block
|
||||||
* @return mixed Completed javascript tag if there are scripts, if there are no buffered
|
* @return mixed Completed javascript tag if there are scripts, if there are no buffered
|
||||||
* scripts null will be returned.
|
* scripts null will be returned.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html#JsHelper::writeBuffer
|
||||||
*/
|
*/
|
||||||
public function writeBuffer($options = array()) {
|
public function writeBuffer($options = array()) {
|
||||||
$domReady = $this->request->is('ajax');
|
$domReady = $this->request->is('ajax');
|
||||||
|
@ -224,6 +229,7 @@ class JsHelper extends AppHelper {
|
||||||
* @param boolean $top If true the script will be added to the top of the
|
* @param boolean $top If true the script will be added to the top of the
|
||||||
* buffered scripts array. If false the bottom.
|
* buffered scripts array. If false the bottom.
|
||||||
* @return void
|
* @return void
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html#JsHelper::buffer
|
||||||
*/
|
*/
|
||||||
public function buffer($script, $top = false) {
|
public function buffer($script, $top = false) {
|
||||||
if ($top) {
|
if ($top) {
|
||||||
|
@ -238,6 +244,7 @@ class JsHelper extends AppHelper {
|
||||||
*
|
*
|
||||||
* @param boolean $clear Whether or not to clear the script caches (default true)
|
* @param boolean $clear Whether or not to clear the script caches (default true)
|
||||||
* @return array Array of scripts added to the request.
|
* @return array Array of scripts added to the request.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html#JsHelper::getBuffer
|
||||||
*/
|
*/
|
||||||
public function getBuffer($clear = true) {
|
public function getBuffer($clear = true) {
|
||||||
$this->_createVars();
|
$this->_createVars();
|
||||||
|
@ -278,6 +285,7 @@ class JsHelper extends AppHelper {
|
||||||
* @param mixed $url Mixed either a string URL or an cake url array.
|
* @param mixed $url Mixed either a string URL or an cake url array.
|
||||||
* @param array $options Options for both the HTML element and Js::request()
|
* @param array $options Options for both the HTML element and Js::request()
|
||||||
* @return string Completed link. If buffering is disabled a script tag will be returned as well.
|
* @return string Completed link. If buffering is disabled a script tag will be returned as well.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html#JsHelper::link
|
||||||
*/
|
*/
|
||||||
public function link($title, $url = null, $options = array()) {
|
public function link($title, $url = null, $options = array()) {
|
||||||
if (!isset($options['id'])) {
|
if (!isset($options['id'])) {
|
||||||
|
@ -352,6 +360,7 @@ class JsHelper extends AppHelper {
|
||||||
* @param string $caption The display text of the submit button.
|
* @param string $caption The display text of the submit button.
|
||||||
* @param array $options Array of options to use. See the options for the above mentioned methods.
|
* @param array $options Array of options to use. See the options for the above mentioned methods.
|
||||||
* @return string Completed submit button.
|
* @return string Completed submit button.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html#JsHelper::submit
|
||||||
*/
|
*/
|
||||||
public function submit($caption = null, $options = array()) {
|
public function submit($caption = null, $options = array()) {
|
||||||
if (!isset($options['id'])) {
|
if (!isset($options['id'])) {
|
||||||
|
|
|
@ -247,6 +247,7 @@ class NumberHelper extends AppHelper {
|
||||||
* @param array $options The array of options for this format.
|
* @param array $options The array of options for this format.
|
||||||
* @return void
|
* @return void
|
||||||
* @see NumberHelper::currency()
|
* @see NumberHelper::currency()
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::addFormat
|
||||||
*/
|
*/
|
||||||
public function addFormat($formatName, $options) {
|
public function addFormat($formatName, $options) {
|
||||||
$this->_currencies[$formatName] = $options + $this->_currencyDefaults;
|
$this->_currencies[$formatName] = $options + $this->_currencyDefaults;
|
||||||
|
|
|
@ -134,6 +134,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
* @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 PaginatorHelper::$options for list of keys.
|
* is used as the DOM id element to update. See PaginatorHelper::$options for list of keys.
|
||||||
* @return void
|
* @return void
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::options
|
||||||
*/
|
*/
|
||||||
public function options($options = array()) {
|
public function options($options = array()) {
|
||||||
if (is_string($options)) {
|
if (is_string($options)) {
|
||||||
|
@ -245,6 +246,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
* @param string $disabledTitle Title when the link is disabled.
|
* @param string $disabledTitle Title when the link is disabled.
|
||||||
* @param array $disabledOptions Options for the disabled pagination link. See #options for list of keys.
|
* @param array $disabledOptions Options for the disabled pagination link. See #options for list of keys.
|
||||||
* @return string A "previous" link or $disabledTitle text if the link is disabled.
|
* @return string A "previous" link or $disabledTitle text if the link is disabled.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::prev
|
||||||
*/
|
*/
|
||||||
public function prev($title = '<< Previous', $options = array(), $disabledTitle = null, $disabledOptions = array()) {
|
public function prev($title = '<< Previous', $options = array(), $disabledTitle = null, $disabledOptions = array()) {
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
|
@ -268,6 +270,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
* @param string $disabledTitle Title when the link is disabled.
|
* @param string $disabledTitle Title when the link is disabled.
|
||||||
* @param mixed $disabledOptions Options for the disabled pagination link. See above for list of keys.
|
* @param mixed $disabledOptions Options for the disabled pagination link. See above for list of keys.
|
||||||
* @return string A "next" link or or $disabledTitle text if the link is disabled.
|
* @return string A "next" link or or $disabledTitle text if the link is disabled.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::next
|
||||||
*/
|
*/
|
||||||
public function next($title = 'Next >>', $options = array(), $disabledTitle = null, $disabledOptions = array()) {
|
public function next($title = 'Next >>', $options = array(), $disabledTitle = null, $disabledOptions = array()) {
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
|
@ -293,6 +296,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
* @param array $options Options for sorting link. See above for list of keys.
|
* @param array $options Options for sorting link. See above 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'.
|
* key the returned link will sort by 'desc'.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::sort
|
||||||
*/
|
*/
|
||||||
public function sort($key, $title = null, $options = array()) {
|
public function sort($key, $title = null, $options = array()) {
|
||||||
$options = array_merge(array('url' => array(), 'model' => null), $options);
|
$options = array_merge(array('url' => array(), 'model' => null), $options);
|
||||||
|
@ -345,6 +349,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
* @param mixed $url Url for the action. See Router::url()
|
* @param mixed $url Url for the action. See Router::url()
|
||||||
* @param array $options Options for the link. See #options for list of keys.
|
* @param array $options Options for the link. See #options for list of keys.
|
||||||
* @return string A link with pagination parameters.
|
* @return string A link with pagination parameters.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::link
|
||||||
*/
|
*/
|
||||||
public function link($title, $url = array(), $options = array()) {
|
public function link($title, $url = array(), $options = array()) {
|
||||||
$options = array_merge(array('model' => null, 'escape' => true), $options);
|
$options = array_merge(array('model' => null, 'escape' => true), $options);
|
||||||
|
@ -373,6 +378,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
* @param boolean $asArray Return the url as an array, or a URI string
|
* @param boolean $asArray Return the url as an array, or a URI string
|
||||||
* @param string $model Which model to paginate on
|
* @param string $model Which model to paginate on
|
||||||
* @return mixed By default, returns a full pagination URL string for use in non-standard contexts (i.e. JavaScript)
|
* @return mixed By default, returns a full pagination URL string for use in non-standard contexts (i.e. JavaScript)
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::url
|
||||||
*/
|
*/
|
||||||
public function url($options = array(), $asArray = false, $model = null) {
|
public function url($options = array(), $asArray = false, $model = null) {
|
||||||
$paging = $this->params($model);
|
$paging = $this->params($model);
|
||||||
|
@ -547,6 +553,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
* @param mixed $options Options for the counter string. See #options for list of keys.
|
* @param mixed $options Options for the counter string. See #options for list of keys.
|
||||||
* @return string Counter string.
|
* @return string Counter string.
|
||||||
* @deprecated The %page% style placeholders are deprecated.
|
* @deprecated The %page% style placeholders are deprecated.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::counter
|
||||||
*/
|
*/
|
||||||
public function counter($options = array()) {
|
public function counter($options = array()) {
|
||||||
if (is_string($options)) {
|
if (is_string($options)) {
|
||||||
|
@ -630,6 +637,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
*
|
*
|
||||||
* @param mixed $options Options for the numbers, (before, after, model, modulus, separator)
|
* @param mixed $options Options for the numbers, (before, after, model, modulus, separator)
|
||||||
* @return string numbers string.
|
* @return string numbers string.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::numbers
|
||||||
*/
|
*/
|
||||||
public function numbers($options = array()) {
|
public function numbers($options = array()) {
|
||||||
if ($options === true) {
|
if ($options === true) {
|
||||||
|
@ -766,6 +774,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
* you want at the beginning of the range.
|
* you want at the beginning of the range.
|
||||||
* @param mixed $options An array of options.
|
* @param mixed $options An array of options.
|
||||||
* @return string numbers string.
|
* @return string numbers string.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::first
|
||||||
*/
|
*/
|
||||||
public function first($first = '<< first', $options = array()) {
|
public function first($first = '<< first', $options = array()) {
|
||||||
$options = array_merge(
|
$options = array_merge(
|
||||||
|
@ -831,6 +840,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
* @param mixed $last if string use as label for the link, if numeric print page numbers
|
* @param mixed $last if string use as label for the link, if numeric print page numbers
|
||||||
* @param mixed $options Array of options
|
* @param mixed $options Array of options
|
||||||
* @return string numbers string.
|
* @return string numbers string.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::last
|
||||||
*/
|
*/
|
||||||
public function last($last = 'last >>', $options = array()) {
|
public function last($last = 'last >>', $options = array()) {
|
||||||
$options = array_merge(
|
$options = array_merge(
|
||||||
|
|
|
@ -38,7 +38,7 @@ class SessionHelper extends AppHelper {
|
||||||
*
|
*
|
||||||
* @param string $name the name of the session key you want to read
|
* @param string $name the name of the session key you want to read
|
||||||
* @return mixed values from the session vars
|
* @return mixed values from the session vars
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/session.html#displaying-notifcations-or-flash-messages
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/session.html#SessionHelper::read
|
||||||
*/
|
*/
|
||||||
public function read($name = null) {
|
public function read($name = null) {
|
||||||
return CakeSession::read($name);
|
return CakeSession::read($name);
|
||||||
|
@ -51,7 +51,7 @@ class SessionHelper extends AppHelper {
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/session.html#displaying-notifcations-or-flash-messages
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/session.html#SessionHelper::check
|
||||||
*/
|
*/
|
||||||
public function check($name) {
|
public function check($name) {
|
||||||
return CakeSession::check($name);
|
return CakeSession::check($name);
|
||||||
|
@ -100,11 +100,20 @@ class SessionHelper extends AppHelper {
|
||||||
* echo $this->Session->flash('flash', array('element' => 'my_custom_element'));
|
* echo $this->Session->flash('flash', array('element' => 'my_custom_element'));
|
||||||
* }}}
|
* }}}
|
||||||
*
|
*
|
||||||
|
* If you want to use an element from a plugin for rendering your flash message you can do that using the
|
||||||
|
* plugin param:
|
||||||
|
*
|
||||||
|
* {{{
|
||||||
|
* echo $this->Session->flash('flash', array(
|
||||||
|
* 'element' => 'my_custom_element',
|
||||||
|
* 'params' => array('plugin' => 'my_plugin')
|
||||||
|
* ));
|
||||||
|
* }}}
|
||||||
|
*
|
||||||
* @param string $key The [Message.]key you are rendering in the view.
|
* @param string $key The [Message.]key you are rendering in the view.
|
||||||
* @param array $attrs Additional attributes to use for the creation of this flash message.
|
* @param array $attrs Additional attributes to use for the creation of this flash message.
|
||||||
* Supports the 'params', and 'element' keys that are used in the helper.
|
* Supports the 'params', and 'element' keys that are used in the helper.
|
||||||
* @return string
|
* @return string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/session.html#displaying-notifcations-or-flash-messages
|
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/session.html#SessionHelper::flash
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/session.html#SessionHelper::flash
|
||||||
*/
|
*/
|
||||||
public function flash($key = 'flash', $attrs = array()) {
|
public function flash($key = 'flash', $attrs = array()) {
|
||||||
|
@ -128,9 +137,13 @@ class SessionHelper extends AppHelper {
|
||||||
} elseif ($flash['element'] == '' || $flash['element'] == null) {
|
} elseif ($flash['element'] == '' || $flash['element'] == null) {
|
||||||
$out = $message;
|
$out = $message;
|
||||||
} else {
|
} else {
|
||||||
|
$options = array();
|
||||||
|
if (isset($flash['params']['plugin'])) {
|
||||||
|
$options['plugin'] = $flash['params']['plugin'];
|
||||||
|
}
|
||||||
$tmpVars = $flash['params'];
|
$tmpVars = $flash['params'];
|
||||||
$tmpVars['message'] = $message;
|
$tmpVars['message'] = $message;
|
||||||
$out = $this->_View->element($flash['element'], $tmpVars);
|
$out = $this->_View->element($flash['element'], $tmpVars, $options);
|
||||||
}
|
}
|
||||||
CakeSession::delete('Message.' . $key);
|
CakeSession::delete('Message.' . $key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue