diff --git a/app/View/Pages/home.ctp b/app/View/Pages/home.ctp index 2612ff49e..4184f1cd9 100644 --- a/app/View/Pages/home.ctp +++ b/app/View/Pages/home.ctp @@ -24,7 +24,7 @@ App::uses('Debugger', 'Utility');

For updates and important announcements, visit http://cakefest.org

- + 0): Debugger::checkSecurityKeys(); diff --git a/lib/Cake/Console/Command/CommandListShell.php b/lib/Cake/Console/Command/CommandListShell.php index 67e0005cb..051436a7d 100644 --- a/lib/Cake/Console/Command/CommandListShell.php +++ b/lib/Cake/Console/Command/CommandListShell.php @@ -81,7 +81,8 @@ class CommandListShell extends Shell { protected function _getShellList() { $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); $appShells = App::objects('Console/Command', null, false); diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 27c63520d..bdef56995 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -424,12 +424,8 @@ class AuthComponent extends Component { * You can use allow with either an array, or var args. * * `$this->Auth->allow(array('edit', 'add'));` or - * `$this->Auth->allow('edit', 'add');` - * `$this->Auth->allow();` to allow all actions. - * - * allow() also supports '*' as a wildcard to mean all actions. - * - * `$this->Auth->allow('*');` + * `$this->Auth->allow('edit', 'add');` or + * `$this->Auth->allow();` to allow all actions * * @param mixed $action,... Controller action name or array of actions * @return void @@ -437,7 +433,7 @@ class AuthComponent extends Component { */ public function allow($action = null) { $args = func_get_args(); - if (empty($args) || $args == array('*')) { + if (empty($args)) { $this->allowedActions = $this->_methods; } else { if (isset($args[0]) && is_array($args[0])) { diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index d5f855387..dbdaa8dd6 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -139,9 +139,9 @@ class RequestHandlerComponent extends Component { } $extensions = Router::extensions(); $preferred = array_shift($accept); - $preferredTypes = $this->mapType($preferred); + $preferredTypes = $this->response->mapType($preferred); $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); } } diff --git a/lib/Cake/Controller/Component/SecurityComponent.php b/lib/Cake/Controller/Component/SecurityComponent.php index df4a7899f..204209db0 100644 --- a/lib/Cake/Controller/Component/SecurityComponent.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -208,6 +208,9 @@ class SecurityComponent extends Component { } } $this->_generateToken($controller); + if ($isPost) { + unset($controller->request->data['_Token']); + } } /** diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index c2234deba..3f1ed2f4c 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -212,6 +212,7 @@ class App { * @param string $type type of path * @param string $plugin name of plugin * @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) { if (!empty(self::$legacy[$type])) { @@ -243,6 +244,7 @@ class App { * use App::path() * * @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() { 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 mixed $mode App::RESET will set paths, App::APPEND with append paths, App::PREPEND will prepend paths, [default] App::PREPEND * @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) { //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. * @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) { return CakePlugin::path($plugin); @@ -362,6 +366,7 @@ class App { * * @param string $theme theme name to find the path of. * @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) { $themeDir = 'Themed' . DS . Inflector::camelize($theme); @@ -382,6 +387,7 @@ class App { * * @param string $type * @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) { 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 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. + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::objects */ public static function objects($type, $path = null, $cache = true) { $extension = '/\.php$/'; @@ -499,6 +506,7 @@ class App { * @param string $className the name of the class to configure package for * @param string $location the package name * @return void + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::uses */ public static function uses($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) { $underscored = Inflector::underscore($className); $tries = array($path . $underscored . '.php'); $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); $tries[] = $path . implode('_', $parts) . '.php'; } @@ -565,6 +575,7 @@ class App { * * @param string $className name of the class to obtain the package name from * @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) { 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 * @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); if ($mapped) { $file = $mapped; @@ -806,6 +817,11 @@ class App { return false; } +/** + * Sets then returns the templates for each customizable package path + * + * @return array templates for each customizable package path + */ protected static function _packageFormat() { if (empty(self::$_packageFormat)) { self::$_packageFormat = array( diff --git a/lib/Cake/Core/Object.php b/lib/Cake/Core/Object.php index b450d1961..43b80bf57 100644 --- a/lib/Cake/Core/Object.php +++ b/lib/Cake/Core/Object.php @@ -55,8 +55,18 @@ class Object { * or tie plugins into a main application. requestAction can be used to return rendered views * or fetch the return value from controller actions. * - * @param mixed $url String or array-based url. - * @param array $extra if array includes the key "return" it sets the AutoRender to true. + * Under the hood this method uses Router::reverse() to convert the $url parmeter into a string + * 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 * of rendered action if 'return' is set in $extra. */ @@ -74,6 +84,8 @@ class Object { $extra['url'] = array(); } $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)) { $request = new CakeRequest($url); @@ -81,9 +93,9 @@ class Object { $params = $url + array('pass' => array(), 'named' => array(), 'base' => false); $params = array_merge($params, $extra); $request = new CakeRequest(Router::reverse($params), false); - if (isset($params['data'])) { - $request->data = $params['data']; - } + } + if (isset($data)) { + $request->data = $data; } $dispatcher = new Dispatcher(); diff --git a/lib/Cake/Model/CakeSchema.php b/lib/Cake/Model/CakeSchema.php index f3bd3841b..b38429719 100644 --- a/lib/Cake/Model/CakeSchema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -546,9 +546,10 @@ class CakeSchema extends Object { $difference[$key] = $value; continue; } - $compare = strval($value); - $correspondingValue = strval($correspondingValue); - if ($compare === $correspondingValue) { + if (is_array($value) && is_array($correspondingValue)) { + continue; + } + if ($value === $correspondingValue) { continue; } $difference[$key] = $value; diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 967f4bade..0546690ea 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -440,7 +440,9 @@ class DboSource extends DataSource { } if (!$query->columnCount()) { $query->closeCursor(); - return true; + if (!$query->rowCount()) { + return true; + } } return $query; } catch (PDOException $e) { diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 8690624ef..3bcdb3338 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -546,9 +546,9 @@ class CakeEmail { } /** - * Set Subject + * Get/Set Subject. * - * @param string $subject + * @param null|string $subject * @return mixed */ public function subject($subject = null) { diff --git a/lib/Cake/Network/Email/SmtpTransport.php b/lib/Cake/Network/Email/SmtpTransport.php index cc58bdd96..e6bb9544f 100644 --- a/lib/Cake/Network/Email/SmtpTransport.php +++ b/lib/Cake/Network/Email/SmtpTransport.php @@ -214,7 +214,8 @@ class SmtpTransport extends AbstractTransport { if (substr($response, -2) !== "\r\n") { 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 ($code[2] === '-') { diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index e2355018b..0b2d00531 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -63,6 +63,7 @@ class HttpSocket extends CakeSocket { 'User-Agent' => 'CakePHP' ), 'raw' => null, + 'redirect' => false, 'cookies' => array() ); @@ -91,13 +92,13 @@ class HttpSocket extends CakeSocket { 'protocol' => 'tcp', 'port' => 80, 'timeout' => 30, - 'redirect' => false, 'request' => array( 'uri' => array( 'scheme' => 'http', 'host' => 'localhost', 'port' => 80 ), + 'redirect' => false, '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); } - if($this->config['redirect'] && $this->response->isRedirect()) { + + if($this->request['redirect'] && $this->response->isRedirect()) { $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); } diff --git a/lib/Cake/Test/Case/Console/TaskCollectionTest.php b/lib/Cake/Test/Case/Console/TaskCollectionTest.php index 75b7908ee..3648fb2b4 100644 --- a/lib/Cake/Test/Case/Console/TaskCollectionTest.php +++ b/lib/Cake/Test/Case/Console/TaskCollectionTest.php @@ -88,7 +88,7 @@ class TaskCollectionTest extends CakeTestCase { $dispatcher = $this->getMock('ShellDispatcher', array(), array(), '', false); $shell = $this->getMock('Shell', array(), array(), '', false); 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'); $this->Tasks = new TaskCollection($shell, $dispatcher); diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 4e2aa268a..d0dddc1f7 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -628,7 +628,7 @@ class AuthComponentTest extends CakeTestCase { $this->Controller->request['action'] = 'camelCase'; $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->request['action'] = 'delete'; @@ -663,7 +663,7 @@ class AuthComponentTest extends CakeTestCase { */ public function testDenyWithCamelCaseMethods() { $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->allow('*'); + $this->Controller->Auth->allow(); $this->Controller->Auth->deny('add', 'camelCase'); $url = '/auth_test/camelCase'; @@ -685,7 +685,7 @@ class AuthComponentTest extends CakeTestCase { $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->allow('*'); + $this->Controller->Auth->allow(); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'startup() should return true, as action is allowed. %s'); diff --git a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php index 0c1c49f95..8f789d311 100644 --- a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php @@ -214,6 +214,7 @@ class RequestHandlerComponentTest extends CakeTestCase { $this->RequestHandler->initialize($this->Controller); $this->assertNull($this->RequestHandler->ext); } + /** * Test that ext is not set with multiple accepted content types. * @@ -227,6 +228,20 @@ class RequestHandlerComponentTest extends CakeTestCase { $this->RequestHandler->initialize($this->Controller); $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 diff --git a/lib/Cake/Test/Case/Controller/ComponentTest.php b/lib/Cake/Test/Case/Controller/ComponentTest.php index a613c944d..888a1f014 100644 --- a/lib/Cake/Test/Case/Controller/ComponentTest.php +++ b/lib/Cake/Test/Case/Controller/ComponentTest.php @@ -40,23 +40,6 @@ class ParamTestComponent extends Component { * @var array */ 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 * @return void */ - public function startup(&$controller) { + public function startup($controller) { $this->testName = $controller->name; } } @@ -134,7 +117,7 @@ class OrangeComponent extends Component { * @param mixed $controller * @return void */ - public function initialize(&$controller) { + public function initialize($controller) { $this->Controller = $controller; $this->Banana->testField = 'OrangeField'; } @@ -145,7 +128,7 @@ class OrangeComponent extends Component { * @param Controller $controller * @return string */ - public function startup(&$controller) { + public function startup($controller) { $controller->foo = 'pass'; } } @@ -170,7 +153,7 @@ class BananaComponent extends Component { * @param Controller $controller * @return string */ - public function startup(&$controller) { + public function startup($controller) { $controller->bar = 'fail'; } } diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index c93079b62..d492b1d8a 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -102,7 +102,7 @@ class ControllerPost extends CakeTestModel { * @param array $options * @return void */ - public function find($type, $options = array()) { + public function find($type = 'first', $options = array()) { if ($type == 'popular') { $conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1'); $options = Set::merge($options, compact('conditions')); diff --git a/lib/Cake/Test/Case/Controller/PagesControllerTest.php b/lib/Cake/Test/Case/Controller/PagesControllerTest.php index 8a71cb5ae..cd451f2d8 100644 --- a/lib/Cake/Test/Case/Controller/PagesControllerTest.php +++ b/lib/Cake/Test/Case/Controller/PagesControllerTest.php @@ -26,15 +26,6 @@ App::uses('PagesController', 'Controller'); */ class PagesControllerTest extends CakeTestCase { -/** - * endTest method - * - * @return void - */ - public function endTest() { - App::build(); - } - /** * testDisplay method * diff --git a/lib/Cake/Test/Case/Controller/ScaffoldTest.php b/lib/Cake/Test/Case/Controller/ScaffoldTest.php index fcd7648be..f28f03828 100644 --- a/lib/Cake/Test/Case/Controller/ScaffoldTest.php +++ b/lib/Cake/Test/Case/Controller/ScaffoldTest.php @@ -87,12 +87,12 @@ class ScaffoldMockControllerWithFields extends Controller { class TestScaffoldMock extends Scaffold { /** - * Overload __scaffold + * Overload _scaffold * * @param unknown_type $params */ - function _scaffold($params) { - $this->_params = $params; + function _scaffold(CakeRequest $request) { + $this->_params = $request; } /** diff --git a/lib/Cake/Test/Case/Core/ObjectTest.php b/lib/Cake/Test/Case/Core/ObjectTest.php index 1b63c0bb2..b02d523be 100644 --- a/lib/Cake/Test/Case/Core/ObjectTest.php +++ b/lib/Cake/Test/Case/Core/ObjectTest.php @@ -115,7 +115,7 @@ class RequestActionController extends Controller { * @return array */ public function post_pass() { - return $this->data; + return $this->request->data; } /** @@ -490,7 +490,7 @@ class ObjectTest extends CakeTestCase { App::build(array( 'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), ), true); - CakePlugin::loadAll(); + CakePlugin::load('TestPlugin'); Router::reload(); $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 */ - public function testRequestActionPostPassing() { + public function testRequestActionNoPostPassing() { $_tmp = $_POST; $_POST = array('data' => array( @@ -636,4 +637,26 @@ class ObjectTest extends CakeTestCase { $_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); + } } diff --git a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php index 106e3757c..4db4ed318 100644 --- a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php +++ b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php @@ -64,7 +64,7 @@ class BlueberryComponent extends Component { * * @return void */ - public function initialize(&$controller) { + public function initialize($controller) { $this->testName = 'BlueberryComponent'; } } diff --git a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php index 909c5dbf9..332a01d43 100644 --- a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php @@ -3305,9 +3305,9 @@ class ContainableBehaviorTest extends CakeTestCase { $this->assertTrue(empty($this->Article->hasMany['ArticlesTag'])); - $this->JoinA =& ClassRegistry::init('JoinA'); - $this->JoinB =& ClassRegistry::init('JoinB'); - $this->JoinC =& ClassRegistry::init('JoinC'); + $this->JoinA = ClassRegistry::init('JoinA'); + $this->JoinB = ClassRegistry::init('JoinB'); + $this->JoinC = ClassRegistry::init('JoinC'); $this->JoinA->Behaviors->attach('Containable'); $this->JoinB->Behaviors->attach('Containable'); diff --git a/lib/Cake/Test/Case/Model/CakeSchemaTest.php b/lib/Cake/Test/Case/Model/CakeSchemaTest.php index f83c5a61b..d4fd29a77 100644 --- a/lib/Cake/Test/Case/Model/CakeSchemaTest.php +++ b/lib/Cake/Test/Case/Model/CakeSchemaTest.php @@ -955,7 +955,7 @@ class CakeSchemaTest extends CakeTestCase { ) ) ); - $this->assertEqual($compare, $expected); + $this->assertEquals($expected, $compare); } /** diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 2f0c37060..6585c098b 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -223,6 +223,30 @@ class MysqlTest extends CakeTestCase { $this->assertIdentical($result['Tinyint']['small_int'], '0'); $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)); } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php index 68003fd15..7aa531359 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php @@ -43,7 +43,7 @@ class DboPostgresTestDb extends Postgres { * @param mixed $sql * @return void */ - function _execute($sql, $params = array()) { + function _execute($sql, $params = array(), $prepareOptions = array()) { $this->simulated[] = $sql; return null; } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php index 9b08b4bdf..e5a5d1000 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php @@ -42,7 +42,7 @@ class DboSqliteTestDb extends Sqlite { * @param mixed $sql * @return void */ - function _execute($sql, $params = array()) { + function _execute($sql, $params = array(), $prepareOptions = array()) { $this->simulated[] = $sql; return null; } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php index 54fdad8dc..92a244a35 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php @@ -48,9 +48,11 @@ class SqlserverTestDb extends Sqlserver { * execute method * * @param mixed $sql + * @param mixed $params + * @param mixed $prepareOptions * @return mixed */ - protected function _execute($sql) { + protected function _execute($sql, $params = array(), $prepareOptions = array()) { $this->simulated[] = $sql; return empty($this->executeResultsStack) ? null : array_pop($this->executeResultsStack); } diff --git a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php index f870aac1c..02182fe2f 100644 --- a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php @@ -33,10 +33,10 @@ class DboTestSource extends DboSource { } 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; } @@ -733,11 +733,11 @@ class DboSourceTest extends CakeTestCase { */ public function testFieldsUsingMethodCache() { $this->testDb->cacheMethods = false; - $this->assertTrue(empty($this->testDb->methodCache['fields']), 'Cache not empty'); + DboTestSource::$methodCache = array(); $Article = ClassRegistry::init('Article'); $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'); } /** diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index b95cc3f07..f7ea39632 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -1557,6 +1557,146 @@ class ModelWriteTest extends BaseModelTest { $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 * diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index d5d2d3e41..496e8eee1 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -300,11 +300,14 @@ class CakeResponseTest extends CakeTestCase { } /** -* Tests the compress method -* -*/ + * Tests the compress method + * + * @return void + */ 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(); if (ini_get("zlib.output_compression") === '1' || !extension_loaded("zlib")) { diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index fdd2f9b9c..6711b2823 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -390,10 +390,6 @@ class CakeEmailTest extends CakeTestCase { $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('هذه رسالة بعنوان طويل مرسل للمستلم'); $expected = '=?UTF-8?B?2YfYsNmHINix2LPYp9mE2Kkg2KjYudmG2YjYp9mGINi32YjZitmEINmF2LE=?=' . "\r\n" . ' =?UTF-8?B?2LPZhCDZhNmE2YXYs9iq2YTZhQ==?='; $this->assertIdentical($this->CakeEmail->subject(), $expected); diff --git a/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php b/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php index ca8a9dc3b..62699b8d6 100644 --- a/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php +++ b/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php @@ -35,7 +35,7 @@ class DigestHttpSocket extends HttpSocket { * @param mixed $request * @return void */ - public function request($request) { + public function request($request = array()) { if ($request === false) { if (isset($this->response['header']['WWW-Authenticate'])) { unset($this->response['header']['WWW-Authenticate']); @@ -192,4 +192,4 @@ class DigestAuthenticationTest extends CakeTestCase { $this->assertFalse(isset($this->HttpSocket->request['header']['Authorization'])); } -} \ No newline at end of file +} diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php index 8f38e3f43..a7813b540 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php @@ -252,13 +252,13 @@ class HttpSocketTest extends CakeTestCase { 'protocol' => 'tcp', 'port' => 23, 'timeout' => 30, - 'redirect' => false, 'request' => array( 'uri' => array( 'scheme' => 'https', 'host' => 'www.cakephp.org', 'port' => 23 ), + 'redirect' => false, 'cookies' => array() ) ); @@ -277,13 +277,13 @@ class HttpSocketTest extends CakeTestCase { 'protocol' => 'tcp', 'port' => 80, 'timeout' => 30, - 'redirect' => false, 'request' => array( 'uri' => array( 'scheme' => 'http', 'host' => 'www.foo.com', 'port' => 80 ), + 'redirect' => false, 'cookies' => array() ) ); @@ -318,13 +318,13 @@ class HttpSocketTest extends CakeTestCase { 'protocol' => 'tcp', 'port' => 80, 'timeout' => 30, - 'redirect' => false, 'request' => array( 'uri' => array ( 'scheme' => 'http', 'host' => 'www.cakephp.org', 'port' => 80 ), + 'redirect' => false, 'cookies' => array() ) ), @@ -345,6 +345,7 @@ class HttpSocketTest extends CakeTestCase { 'line' => "GET /?foo=bar HTTP/1.1\r\n", 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n", 'raw' => "", + 'redirect' => false, 'cookies' => array(), 'proxy' => array(), 'auth' => array() @@ -722,19 +723,50 @@ class HttpSocketTest extends CakeTestCase { * * @return void */ - public function testRequestWithRedirect() { + public function testRequestWithRedirectAsTrue() { $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"; $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

You have been redirected

"; $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->config['redirect'] = true; $response = $this->Socket->request($request); $this->assertEquals('

You have been redirected

', $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

You have been redirected

"; + $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 diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 48855bc34..33b5149fc 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -75,15 +75,15 @@ class FolderTest extends CakeTestCase { $Folder = new Folder($path); $result = $Folder->pwd(); - $this->assertEqual($result, $path); + $this->assertEquals($result, $path); $result = Folder::addPathElement($path, 'test'); $expected = $path . DS . 'test'; - $this->assertEqual($expected, $result); + $this->assertEquals($expected, $result); $result = $Folder->cd(ROOT); $expected = ROOT; - $this->assertEqual($expected, $result); + $this->assertEquals($expected, $result); $result = $Folder->cd(ROOT . DS . 'non-existent'); $this->assertFalse($result); @@ -101,13 +101,13 @@ class FolderTest extends CakeTestCase { $Folder = new Folder($path); $result = $Folder->pwd(); - $this->assertEqual($result, $path); + $this->assertEquals($result, $path); $result = Folder::isSlashTerm($inside); $this->assertTrue($result); $result = $Folder->realpath('Test/'); - $this->assertEqual($result, $path . DS .'Test' . DS); + $this->assertEquals($result, $path . DS .'Test' . DS); $result = $Folder->inPath('Test' . DS); $this->assertTrue($result); @@ -230,7 +230,7 @@ class FolderTest extends CakeTestCase { $expected = $new . ' is a file'; $result = $Folder->errors(); - $this->assertEqual($result[0], $expected); + $this->assertEquals($result[0], $expected); $new = TMP . 'test_folder_new'; $result = $Folder->create($new); @@ -268,11 +268,26 @@ class FolderTest extends CakeTestCase { $filePath = $new . DS . 'test1.php'; $File = new File($filePath); $this->assertTrue($File->create()); - $copy = TMP . 'test_folder_copy'; - - $this->assertTrue($Folder->chmod($new, 0777, true)); - $this->assertEqual($File->perms(), '0777'); + + $filePath = $new . DS . 'skip_me.php'; + $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); } @@ -283,7 +298,7 @@ class FolderTest extends CakeTestCase { */ public function testRealPathForWebroot() { $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); $expected = array('0', 'cache', 'logs', 'sessions', 'tests'); - $this->assertEqual($expected, $result[0]); + $this->assertEquals($expected, $result[0]); $result = $Folder->read(true, array('logs')); $expected = array('0', 'cache', 'sessions', 'tests'); - $this->assertEqual($expected, $result[0]); + $this->assertEquals($expected, $result[0]); $result = $Folder->delete($new); $this->assertTrue($result); @@ -315,10 +330,10 @@ class FolderTest extends CakeTestCase { */ public function testAddPathElement() { $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'); - $this->assertEqual($result, DS . 'some' . DS . 'dir' . DS . 'another_path'); + $this->assertEquals($result, DS . 'some' . DS . 'dir' . DS . 'another_path'); } /** * testFolderRead method @@ -330,12 +345,12 @@ class FolderTest extends CakeTestCase { $expected = array('cache', 'logs', 'sessions', 'tests'); $result = $Folder->read(true, true); - $this->assertEqual($result[0], $expected); + $this->assertEquals($result[0], $expected); $Folder->path = TMP . 'non-existent'; $expected = array(array(), array()); $result = $Folder->read(true, true); - $this->assertEqual($expected, $result); + $this->assertEquals($expected, $result); } /** @@ -438,7 +453,7 @@ class FolderTest extends CakeTestCase { */ public function testSlashTerm() { $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() { $path = '/path/to/file'; $result = Folder::normalizePath($path); - $this->assertEqual($result, '/'); + $this->assertEquals($result, '/'); $path = '\\path\\\to\\\file'; $result = Folder::normalizePath($path); - $this->assertEqual($result, '/'); + $this->assertEquals($result, '/'); $path = 'C:\\path\\to\\file'; $result = Folder::normalizePath($path); - $this->assertEqual($result, '\\'); + $this->assertEquals($result, '\\'); } /** @@ -468,15 +483,15 @@ class FolderTest extends CakeTestCase { public function testCorrectSlashFor() { $path = '/path/to/file'; $result = Folder::correctSlashFor($path); - $this->assertEqual($result, '/'); + $this->assertEquals($result, '/'); $path = '\\path\\to\\file'; $result = Folder::correctSlashFor($path); - $this->assertEqual($result, '/'); + $this->assertEquals($result, '/'); $path = 'C:\\path\to\\file'; $result = Folder::correctSlashFor($path); - $this->assertEqual($result, '\\'); + $this->assertEquals($result, '\\'); } /** @@ -630,13 +645,13 @@ class FolderTest extends CakeTestCase { */ public function testDirSize() { $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->create(); $File->write('something here'); $File->close(); - $this->assertEqual($Folder->dirSize(), 14); + $this->assertEquals($Folder->dirSize(), 14); $Folder->cd(TMP); $Folder->delete($Folder->pwd() . 'config_non_existant'); @@ -666,7 +681,7 @@ class FolderTest extends CakeTestCase { $path . DS . 'file2 removed', $path . ' removed' ); - $this->assertEqual($expected, $messages); + $this->assertEquals($expected, $messages); } /** @@ -720,7 +735,7 @@ class FolderTest extends CakeTestCase { $result = $Folder->copy($folder3); $this->assertTrue($result); $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->delete(); @@ -794,7 +809,7 @@ class FolderTest extends CakeTestCase { $result = $Folder->move($folder3); $this->assertTrue($result); $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($folder2)); $this->assertFalse(file_exists($file2)); diff --git a/lib/Cake/Test/Case/View/Helper/SessionHelperTest.php b/lib/Cake/Test/Case/View/Helper/SessionHelperTest.php index 1d36810bb..acf6475f5 100644 --- a/lib/Cake/Test/Case/View/Helper/SessionHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/SessionHelperTest.php @@ -80,6 +80,7 @@ class SessionHelperTest extends CakeTestCase { public function tearDown() { $_SESSION = array(); unset($this->View, $this->Session); + CakePlugin::unload(); parent::tearDown(); } @@ -160,7 +161,7 @@ class SessionHelperTest extends CakeTestCase { */ public function testFlashElementInAttrs() { 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( 'element' => 'session_helper', @@ -168,4 +169,23 @@ class SessionHelperTest extends CakeTestCase { )); $expected = "
\n\t

Alert!

\n\t

Notice!

\n\t

This is a calling

\n
"; } + +/** + * 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); + } } diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index d5428c46b..2f5ce2fbd 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -170,6 +170,13 @@ class TestAfterHelper extends Helper { */ class ViewTest extends CakeTestCase { +/** + * Fixtures used in this test. + * + * @var array + */ + public $fixtures = array('core.user', 'core.post'); + /** * setUp method * @@ -190,7 +197,7 @@ class ViewTest extends CakeTestCase { CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS ) ), true); - CakePlugin::loadAll(); + CakePlugin::load(array('TestPlugin', 'TestPlugin', 'PluginJs')); Configure::write('debug', 2); } @@ -576,14 +583,14 @@ class ViewTest extends CakeTestCase { $View->Helpers = $this->getMock('HelperCollection', array('trigger'), array($View)); $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') - ->with('afterRender', new PHPUnit_Framework_Constraint_IsAnything()); + ->with('afterRender', $this->anything()); $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') - ->with('afterLayout', new PHPUnit_Framework_Constraint_IsAnything()); + ->with('afterLayout', $this->anything()); $View->render('index'); } diff --git a/lib/Cake/Test/test_app/Model/Datasource/Test2OtherSource.php b/lib/Cake/Test/test_app/Model/Datasource/Test2OtherSource.php index e9d3bfaf0..88168229a 100644 --- a/lib/Cake/Test/test_app/Model/Datasource/Test2OtherSource.php +++ b/lib/Cake/Test/test_app/Model/Datasource/Test2OtherSource.php @@ -5,23 +5,23 @@ class Test2OtherSource extends DataSource { return compact('model'); } - public function listSources() { + public function listSources($data = null) { 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'); } - public function read($model, $queryData = array()) { + public function read(Model $model, $queryData = array()) { 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'); } - public function delete($model, $id) { + public function delete(Model $model, $id = null) { return compact('model', 'id'); } } diff --git a/lib/Cake/Test/test_app/Model/Datasource/Test2Source.php b/lib/Cake/Test/test_app/Model/Datasource/Test2Source.php index bab312502..bb9f1dc80 100644 --- a/lib/Cake/Test/test_app/Model/Datasource/Test2Source.php +++ b/lib/Cake/Test/test_app/Model/Datasource/Test2Source.php @@ -5,23 +5,23 @@ class Test2Source extends DataSource { return compact('model'); } - public function listSources() { + public function listSources($data = null) { 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'); } - public function read($model, $queryData = array()) { + public function read(Model $model, $queryData = array()) { 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'); } - public function delete($model, $id) { + public function delete(Model $model, $id = null) { return compact('model', 'id'); } } diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/Task/other_task.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/Task/OtherTaskTask.php similarity index 100% rename from lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/Task/other_task.php rename to lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/Task/OtherTaskTask.php diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/TestSource.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/TestSource.php index 3f8eb52c9..371d86a98 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/TestSource.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/TestSource.php @@ -7,23 +7,23 @@ class TestSource extends DataSource { return compact('model'); } - public function listSources() { + public function listSources($data = null) { 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'); } - public function read($model, $queryData = array()) { + public function read(Model $model, $queryData = array()) { 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'); } - public function delete($model, $id) { + public function delete(Model $model, $id = null) { return compact('model', 'id'); } } diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/test_other_source.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/test_other_source.php index d3b77ce01..7ab6febca 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/test_other_source.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/test_other_source.php @@ -5,23 +5,23 @@ class TestOtherSource extends DataSource { return compact('model'); } - public function listSources() { + public function listSources($data = null) { 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'); } - public function read($model, $queryData = array()) { + public function read(Model $model, $queryData = array()) { 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'); } - public function delete($model, $id) { + public function delete(Model $model, $id = null) { return compact('model', 'id'); } } diff --git a/lib/Cake/Utility/ClassRegistry.php b/lib/Cake/Utility/ClassRegistry.php index 11cc8a59a..27fb0a823 100644 --- a/lib/Cake/Utility/ClassRegistry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -133,12 +133,12 @@ class ClassRegistry { App::uses($class, $pluginPath . 'Model'); if (class_exists($class)) { - ${$class} = new $class($settings); + $instance = new $class($settings); if ($strict) { - ${$class} = (${$class} instanceof Model) ? ${$class} : null; + $instance = ($instance instanceof Model) ? $instance : null; } } - if (!isset(${$class})) { + if (!isset($instance)) { if ($strict) { return false; } elseif ($plugin && class_exists($plugin . 'AppModel')) { @@ -148,10 +148,10 @@ class ClassRegistry { } if (!empty($appModel)) { $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); return $false; } @@ -166,7 +166,7 @@ class ClassRegistry { if ($count > 1) { return $true; } - return ${$class}; + return $instance; } /** diff --git a/lib/Cake/Utility/File.php b/lib/Cake/Utility/File.php index 11d409d6d..384b9a029 100644 --- a/lib/Cake/Utility/File.php +++ b/lib/Cake/Utility/File.php @@ -80,6 +80,7 @@ class File { * @param string $path Path to file * @param boolean $create Create file if it does not exist (if true) * @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) { $this->Folder = new Folder(dirname($path), $create, $mode); @@ -102,6 +103,7 @@ class File { * Creates the File. * * @return boolean Success + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::create */ public function create() { $dir = $this->Folder->pwd(); @@ -121,6 +123,7 @@ class File { * @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 * @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) { if (!$force && is_resource($this->handle)) { @@ -147,6 +150,7 @@ class File { * @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 * @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) { 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 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) + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::offset */ public function offset($offset = false, $seek = SEEK_SET) { if ($offset === false) { @@ -202,6 +207,7 @@ class File { * @param string $data Data to prepare for writing. * @param boolean $forceWindows * @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) { $lineBreak = "\n"; @@ -218,6 +224,7 @@ class File { * @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}. * @param string $force force the file to open * @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) { $success = false; @@ -244,6 +251,7 @@ class File { * @param string $data Data to write * @param string $force force the file to open * @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) { return $this->write($data, 'a', $force); @@ -253,6 +261,7 @@ class File { * Closes the current file if it is opened. * * @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() { if (!is_resource($this->handle)) { @@ -265,6 +274,7 @@ class File { * Deletes the File. * * @return boolean Success + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::delete */ public function delete() { clearstatcache(); @@ -282,6 +292,7 @@ class File { * Returns the File info. * * @return string The File extension + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::info */ public function info() { if ($this->info == null) { @@ -300,6 +311,7 @@ class File { * Returns 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() { if ($this->info == null) { @@ -315,6 +327,7 @@ class File { * Returns 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() { 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 $ext The name of the extension to make safe if different from $this->ext * @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) { if (!$name) { @@ -350,6 +364,7 @@ class File { * * @param mixed $maxsize in MB or true to force * @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) { if ($maxsize === true) { @@ -368,6 +383,7 @@ class File { * Returns the full path of the 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() { if (is_null($this->path)) { @@ -380,6 +396,7 @@ class File { * Returns true if the File exists. * * @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() { return (file_exists($this->path) && is_file($this->path)); @@ -389,6 +406,7 @@ class File { * Returns the "chmod" (permissions) of 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() { if ($this->exists()) { @@ -401,6 +419,7 @@ class File { * Returns the Filesize * * @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() { if ($this->exists()) { @@ -413,6 +432,7 @@ class File { * Returns true if the File is writable. * * @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() { return is_writable($this->path); @@ -422,6 +442,7 @@ class File { * Returns true if the File is executable. * * @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() { return is_executable($this->path); @@ -431,6 +452,7 @@ class File { * Returns true if the File is readable. * * @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() { return is_readable($this->path); @@ -440,6 +462,7 @@ class File { * Returns the File's owner. * * @return integer the Fileowner + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::owner */ public function owner() { if ($this->exists()) { @@ -452,6 +475,7 @@ class File { * Returns the File's group. * * @return integer the Filegroup + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::group */ public function group() { if ($this->exists()) { @@ -464,6 +488,7 @@ class File { * Returns 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() { if ($this->exists()) { @@ -476,6 +501,7 @@ class File { * Returns last modified time. * * @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() { if ($this->exists()) { @@ -488,6 +514,7 @@ class File { * Returns the 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() { return $this->Folder; @@ -498,7 +525,8 @@ class File { * * @param string $dest destination for the copy * @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) { if (!$this->exists() || is_file($dest) && !$overwrite) { diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index e797d4417..fd1cdd160 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -81,6 +81,7 @@ class Folder { * @param string $path Path to folder * @param boolean $create Create folder if not found * @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) { if (empty($path)) { @@ -105,6 +106,7 @@ class Folder { * Return 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() { return $this->path; @@ -115,6 +117,7 @@ class Folder { * * @param string $path Path to the directory to change to * @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) { $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 boolean $fullPath True returns the full path * @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) { $dirs = $files = array(); @@ -181,6 +185,7 @@ class Folder { * @param string $regexpPattern Preg_match pattern (Defaults to: .*) * @param boolean $sort Whether results should be sorted. * @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) { list($dirs, $files) = $this->read($sort); @@ -193,6 +198,7 @@ class Folder { * @param string $pattern Preg_match pattern (Defaults to: .*) * @param boolean $sort Whether results should be sorted. * @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) { if (!$this->pwd()) { @@ -234,6 +240,7 @@ class Folder { * * @param string $path Path to check * @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) { return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\'); @@ -244,6 +251,7 @@ class Folder { * * @param string $path Path to check * @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) { 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 * @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) { return Folder::correctSlashFor($path); @@ -264,6 +273,7 @@ class Folder { * * @param string $path Path to check * @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) { return (Folder::isWindowsPath($path)) ? '\\' : '/'; @@ -274,6 +284,7 @@ class Folder { * * @param string $path Path to check * @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) { if (Folder::isSlashTerm($path)) { @@ -288,6 +299,7 @@ class Folder { * @param string $path Path * @param string $element Element to and at end of 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) { return rtrim($path, DS) . DS . $element; @@ -298,6 +310,7 @@ class Folder { * * @param string $path The path to check. * @return boolean + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::inCakePath */ public function inCakePath($path = '') { $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 boolean $reverse * @return boolean + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::inPath */ public function inPath($path = '', $reverse = false) { $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 array $exceptions array of files, directories to skip * @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()) { if (!$mode) { @@ -383,6 +398,7 @@ class Folder { * @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 * @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) { if ($path == null) { @@ -449,6 +465,7 @@ class Folder { * @param string $pathname The directory structure to create * @param integer $mode octal value 0755 * @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) { if (is_dir($pathname) || empty($pathname)) { @@ -487,6 +504,7 @@ class Folder { * Returns the size in bytes of this Folder and its contents. * * @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() { $size = 0; @@ -523,6 +541,7 @@ class Folder { * * @param string $path Path of directory to delete * @return boolean Success + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::delete */ public function delete($path = null) { 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. * @return boolean Success + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::copy */ public function copy($options = array()) { if (!$this->pwd()) { @@ -664,6 +684,7 @@ class Folder { * * @param array $options (to, from, chmod, skip) * @return boolean Success + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::move */ public function move($options) { $to = null; @@ -688,6 +709,7 @@ class Folder { * get messages from latest method * * @return array + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::messages */ public function messages() { return $this->_messages; @@ -697,6 +719,7 @@ class Folder { * get error from latest method * * @return array + * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::errors */ public function errors() { return $this->_errors; @@ -707,6 +730,7 @@ class Folder { * * @param string $path Path to resolve * @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) { $path = str_replace('/', DS, trim($path)); @@ -747,6 +771,7 @@ class Folder { * * @param string $path Path to check * @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) { $lastChar = $path[strlen($path) - 1]; diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 580d75a08..6258e8234 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -569,6 +569,7 @@ class FormHelper extends AppHelper { * * @param string $name The dot separated name for the field. * @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) { if ($name === null) { diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index b87fe9a35..9656c2cfb 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -181,6 +181,7 @@ class HtmlHelper extends AppHelper { * @param mixed $options Link attributes e.g. array('id'=>'selected') * @return void * @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) { $this->_crumbs[] = array($name, $link, $options); @@ -615,6 +616,7 @@ class HtmlHelper extends AppHelper { * @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 * @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) { 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. * @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()) { if (!empty($this->_crumbs)) { @@ -975,6 +978,7 @@ class HtmlHelper extends AppHelper { * @param string $path Path with config file * @return mixed False to error or loaded configs * @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) { if (!$path) { diff --git a/lib/Cake/View/Helper/JsBaseEngineHelper.php b/lib/Cake/View/Helper/JsBaseEngineHelper.php index adbf46ee2..34062f07e 100644 --- a/lib/Cake/View/Helper/JsBaseEngineHelper.php +++ b/lib/Cake/View/Helper/JsBaseEngineHelper.php @@ -154,7 +154,10 @@ abstract class JsBaseEngineHelper extends AppHelper { * @param boolean $quoteString If false, leaves string values unquoted * @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) { case (is_array($val) || is_object($val)): $val = $this->object($val); @@ -598,4 +601,4 @@ abstract class JsBaseEngineHelper extends AppHelper { } return $out; } -} \ No newline at end of file +} diff --git a/lib/Cake/View/Helper/JsHelper.php b/lib/Cake/View/Helper/JsHelper.php index f6c6eeffb..701961d13 100644 --- a/lib/Cake/View/Helper/JsHelper.php +++ b/lib/Cake/View/Helper/JsHelper.php @@ -159,8 +159,12 @@ class JsHelper extends AppHelper { * @param mixed $val A PHP variable to be converted to JSON * @param boolean $quoteString If false, leaves string values unquoted * @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); } @@ -182,6 +186,7 @@ class JsHelper extends AppHelper { * @param array $options options for the code block * @return mixed Completed javascript tag if there are scripts, if there are no buffered * 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()) { $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 * buffered scripts array. If false the bottom. * @return void + * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html#JsHelper::buffer */ public function buffer($script, $top = false) { if ($top) { @@ -238,6 +244,7 @@ class JsHelper extends AppHelper { * * @param boolean $clear Whether or not to clear the script caches (default true) * @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) { $this->_createVars(); @@ -278,6 +285,7 @@ class JsHelper extends AppHelper { * @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() * @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()) { if (!isset($options['id'])) { @@ -352,6 +360,7 @@ class JsHelper extends AppHelper { * @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. * @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()) { if (!isset($options['id'])) { diff --git a/lib/Cake/View/Helper/NumberHelper.php b/lib/Cake/View/Helper/NumberHelper.php index a891fd4ec..4d9b3c984 100644 --- a/lib/Cake/View/Helper/NumberHelper.php +++ b/lib/Cake/View/Helper/NumberHelper.php @@ -247,6 +247,7 @@ class NumberHelper extends AppHelper { * @param array $options The array of options for this format. * @return void * @see NumberHelper::currency() + * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::addFormat */ public function addFormat($formatName, $options) { $this->_currencies[$formatName] = $options + $this->_currencyDefaults; diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index d77761065..683105bdb 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -134,6 +134,7 @@ class PaginatorHelper extends AppHelper { * @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. * @return void + * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::options */ public function options($options = array()) { if (is_string($options)) { @@ -245,6 +246,7 @@ class PaginatorHelper extends AppHelper { * @param string $disabledTitle Title when the link is disabled. * @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. + * @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()) { $defaults = array( @@ -268,6 +270,7 @@ class PaginatorHelper extends AppHelper { * @param string $disabledTitle Title when the link is disabled. * @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. + * @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()) { $defaults = array( @@ -293,6 +296,7 @@ class PaginatorHelper extends AppHelper { * @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 * 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()) { $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 array $options Options for the link. See #options for list of keys. * @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()) { $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 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) + * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::url */ public function url($options = array(), $asArray = false, $model = null) { $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. * @return string Counter string. * @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()) { if (is_string($options)) { @@ -630,6 +637,7 @@ class PaginatorHelper extends AppHelper { * * @param mixed $options Options for the numbers, (before, after, model, modulus, separator) * @return string numbers string. + * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::numbers */ public function numbers($options = array()) { if ($options === true) { @@ -766,6 +774,7 @@ class PaginatorHelper extends AppHelper { * you want at the beginning of the range. * @param mixed $options An array of options. * @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()) { $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 $options Array of options * @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()) { $options = array_merge( diff --git a/lib/Cake/View/Helper/SessionHelper.php b/lib/Cake/View/Helper/SessionHelper.php index 696821921..0ea64a38f 100644 --- a/lib/Cake/View/Helper/SessionHelper.php +++ b/lib/Cake/View/Helper/SessionHelper.php @@ -38,7 +38,7 @@ class SessionHelper extends AppHelper { * * @param string $name the name of the session key you want to read * @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) { return CakeSession::read($name); @@ -51,7 +51,7 @@ class SessionHelper extends AppHelper { * * @param string $name * @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) { return CakeSession::check($name); @@ -100,11 +100,20 @@ class SessionHelper extends AppHelper { * 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 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. * @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 */ public function flash($key = 'flash', $attrs = array()) { @@ -128,9 +137,13 @@ class SessionHelper extends AppHelper { } elseif ($flash['element'] == '' || $flash['element'] == null) { $out = $message; } else { + $options = array(); + if (isset($flash['params']['plugin'])) { + $options['plugin'] = $flash['params']['plugin']; + } $tmpVars = $flash['params']; $tmpVars['message'] = $message; - $out = $this->_View->element($flash['element'], $tmpVars); + $out = $this->_View->element($flash['element'], $tmpVars, $options); } CakeSession::delete('Message.' . $key); }