Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch '2.0' of github.com:cakephp/cakephp into 2.0

  • Loading branch information...
commit 95acaba295da31c3b98d04fe44098f6b4addbac0 2 parents bc8b522 + 53be552
@lorenzo lorenzo authored
View
3  lib/Cake/Model/Datasource/Database/Sqlite.php
@@ -18,6 +18,7 @@
*/
App::uses('DboSource', 'Model/Datasource');
+App::uses('String', 'Utility');
/**
* DBO implementation for the SQLite3 DBMS.
@@ -281,7 +282,7 @@ public function resultSet($results) {
$last = strripos($querystring, 'FROM');
if ($last !== false) {
$selectpart = substr($querystring, 7, $last - 8);
- $selects = explode(',', $selectpart);
+ $selects = String::tokenize($selectpart, ',', '(', ')');
}
} elseif (strpos($querystring, 'PRAGMA table_info') === 0) {
$selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk');
View
20 lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
@@ -20,6 +20,8 @@
App::uses('AppModel', 'Model');
App::uses('Sqlite', 'Model/Datasource/Database');
+require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php';
+
/**
* DboSqliteTestDb class
*
@@ -88,6 +90,7 @@ class SqliteTest extends CakeTestCase {
*
*/
public function setUp() {
+ parent::setUp();
Configure::write('Cache.disable', true);
$this->Dbo = ConnectionManager::getDataSource('test');
if (!$this->Dbo instanceof Sqlite) {
@@ -100,6 +103,7 @@ public function setUp() {
*
*/
public function tearDown() {
+ parent::tearDown();
Configure::write('Cache.disable', false);
}
@@ -318,4 +322,20 @@ public function testDescribeWithUuidPrimaryKey() {
$this->assertEqual($result['id'], $expected);
$this->Dbo->query('DROP TABLE ' . $tableName);
}
+
+/**
+ * Test virtualFields with functions.
+ *
+ * @return void
+ */
+ public function testVirtualFieldWithFunction() {
+ $this->loadFixtures('User');
+ $User = ClassRegistry::init('User');
+ $User->virtualFields = array('name' => 'SUBSTR(User.user, 5)');
+
+ $result = $User->find('first', array(
+ 'conditions' => array('User.user' => 'garrett')
+ ));
+ $this->assertEquals('ett', $result['User']['name']);
+ }
}
View
17 lib/Cake/Test/Case/Utility/DebuggerTest.php
@@ -403,7 +403,7 @@ public function testGetInstance() {
*
* @return void
*/
- function testNoDbCredentials() {
+ public function testNoDbCredentials() {
$config = array(
'driver' => 'mysql',
'persistent' => false,
@@ -429,4 +429,19 @@ function testNoDbCredentials() {
$this->assertEqual($expected, $output);
}
+
+/**
+ * test trace exclude
+ *
+ * @return void
+ */
+ public function testTraceExclude() {
+ $result = Debugger::trace();
+ $this->assertPattern('/^DebuggerTest::testTraceExclude/', $result);
+
+ $result = Debugger::trace(array(
+ 'exclude' => array('DebuggerTest::testTraceExclude')
+ ));
+ $this->assertNoPattern('/^DebuggerTest::testTraceExclude/', $result);
+ }
}
View
15 lib/Cake/Test/Case/View/HelperTest.php
@@ -255,7 +255,7 @@ public function testSetEntity($entity, $expected) {
*/
public function testSetEntityScoped() {
$this->Helper->setEntity('HelperTestPost', true);
- $this->assertEquals(array('HelperTestPost'), $this->Helper->entity());
+ $this->assertEquals(array('HelperTestPost'), $this->Helper->entity());
$this->Helper->setEntity('id');
$expected = array('HelperTestPost', 'id');
@@ -311,6 +311,19 @@ public function testSetEntityAssociated() {
}
/**
+ * Test creating saveMany() compatible entities
+ *
+ * @return void
+ */
+ public function testSetEntitySaveMany() {
+ $this->Helper->setEntity('HelperTestPost', true);
+
+ $this->Helper->setEntity('0.HelperTestPost.id');
+ $expected = array('0', 'HelperTestPost', 'id');
+ $this->assertEquals($expected, $this->Helper->entity());
+ }
+
+/**
* Test that setEntity doesn't make CamelCase fields that are not associations an
* associated model.
*
View
36 lib/Cake/TestSuite/CakeTestCase.php
@@ -387,8 +387,8 @@ protected function _array_permute($items, $perms = array()) {
* @param string $message the text to display if the assertion is not correct
* @return void
*/
- protected function assertEqual($result, $expected, $message = '') {
- return $this->assertEquals($expected, $result, $message);
+ protected static function assertEqual($result, $expected, $message = '') {
+ return self::assertEquals($expected, $result, $message);
}
/**
@@ -399,8 +399,8 @@ protected function assertEqual($result, $expected, $message = '') {
* @param string $message the text to display if the assertion is not correct
* @return void
*/
- protected function assertNotEqual($result, $expected, $message = '') {
- return $this->assertNotEquals($expected, $result, $message);
+ protected static function assertNotEqual($result, $expected, $message = '') {
+ return self::assertNotEquals($expected, $result, $message);
}
/**
@@ -411,8 +411,8 @@ protected function assertNotEqual($result, $expected, $message = '') {
* @param string $message the text to display if the assertion is not correct
* @return void
*/
- protected function assertPattern($pattern, $string, $message = '') {
- return $this->assertRegExp($pattern, $string, $message);
+ protected static function assertPattern($pattern, $string, $message = '') {
+ return self::assertRegExp($pattern, $string, $message);
}
/**
@@ -423,8 +423,8 @@ protected function assertPattern($pattern, $string, $message = '') {
* @param string $message the text to display if the assertion is not correct
* @return void
*/
- protected function assertIdentical($actual, $expected, $message = '') {
- return $this->assertSame($expected, $actual, $message);
+ protected static function assertIdentical($actual, $expected, $message = '') {
+ return self::assertSame($expected, $actual, $message);
}
/**
@@ -435,8 +435,8 @@ protected function assertIdentical($actual, $expected, $message = '') {
* @param string $message the text to display if the assertion is not correct
* @return void
*/
- protected function assertNotIdentical($actual, $expected, $message = '') {
- return $this->assertNotSame($expected, $actual, $message);
+ protected static function assertNotIdentical($actual, $expected, $message = '') {
+ return self::assertNotSame($expected, $actual, $message);
}
/**
@@ -447,8 +447,8 @@ protected function assertNotIdentical($actual, $expected, $message = '') {
* @param string $message the text to display if the assertion is not correct
* @return void
*/
- protected function assertNoPattern($pattern, $string, $message = '') {
- return $this->assertNotRegExp($pattern, $string, $message);
+ protected static function assertNoPattern($pattern, $string, $message = '') {
+ return self::assertNotRegExp($pattern, $string, $message);
}
protected function assertNoErrors() {
@@ -487,8 +487,8 @@ protected function expectException($name = 'Exception', $message = '') {
* @param string $message the text to display if the assertion is not correct
* @return void
*/
- protected function assertReference(&$first, &$second, $message = '') {
- return $this->assertSame($first, $second, $message);
+ protected static function assertReference(&$first, &$second, $message = '') {
+ return self::assertSame($first, $second, $message);
}
/**
@@ -499,8 +499,8 @@ protected function assertReference(&$first, &$second, $message = '') {
* @param string $message
* @return void
*/
- protected function assertIsA($object, $type, $message = '') {
- return $this->assertInstanceOf($type, $object, $message);
+ protected static function assertIsA($object, $type, $message = '') {
+ return self::assertInstanceOf($type, $object, $message);
}
/**
@@ -512,10 +512,10 @@ protected function assertIsA($object, $type, $message = '') {
* @param string $message the text to display if the assertion is not correct
* @return void
*/
- protected function assertWithinMargin($result, $expected, $margin, $message = '') {
+ protected static function assertWithinMargin($result, $expected, $margin, $message = '') {
$upper = $result + $margin;
$lower = $result - $margin;
- $this->assertTrue((($expected <= $upper) && ($expected >= $lower)), $message);
+ return self::assertTrue((($expected <= $upper) && ($expected >= $lower)), $message);
}
/**
View
14 lib/Cake/Utility/Debugger.php
@@ -285,9 +285,9 @@ public static function trace($options = array()) {
'args' => false,
'start' => 0,
'scope' => null,
- 'exclude' => null
+ 'exclude' => array('call_user_func_array', 'trigger_error')
);
- $options += $defaults;
+ $options = Set::merge($defaults, $options);
$backtrace = debug_backtrace();
$count = count($backtrace);
@@ -302,13 +302,15 @@ public static function trace($options = array()) {
for ($i = $options['start']; $i < $count && $i < $options['depth']; $i++) {
$trace = array_merge(array('file' => '[internal]', 'line' => '??'), $backtrace[$i]);
+ $signature = $reference = '[main]';
if (isset($backtrace[$i + 1])) {
$next = array_merge($_trace, $backtrace[$i + 1]);
- $reference = $next['function'];
+ $signature = $reference = $next['function'];
if (!empty($next['class'])) {
- $reference = $next['class'] . '::' . $reference . '(';
+ $signature = $next['class'] . '::' . $next['function'];
+ $reference = $signature . '(';
if ($options['args'] && isset($next['args'])) {
$args = array();
foreach ($next['args'] as $arg) {
@@ -318,10 +320,8 @@ public static function trace($options = array()) {
}
$reference .= ')';
}
- } else {
- $reference = '[main]';
}
- if (in_array($reference, array('call_user_func_array', 'trigger_error'))) {
+ if (in_array($signature, $options['exclude'])) {
continue;
}
if ($options['format'] == 'points' && $trace['file'] != '[internal]') {
View
4 lib/Cake/View/Helper.php
@@ -444,9 +444,9 @@ public function setEntity($entity, $setScope = false) {
$entity = $this->_modelScope . '.' . $entity;
}
- // 0.name, 0.created.month style inputs.
+ // 0.name, 0.created.month style inputs. Excludes inputs with the modelScope in them.
if (
- $count >= 2 && is_numeric($parts[0]) && !is_numeric($parts[1]) && $this->_modelScope
+ $count >= 2 && is_numeric($parts[0]) && !is_numeric($parts[1]) && $this->_modelScope && strpos($entity, $this->_modelScope) === false
) {
$entity = $this->_modelScope . '.' . $entity;
}
View
16 lib/Cake/View/View.php
@@ -136,7 +136,7 @@ class View extends Object {
/**
* Sub-directory for this view file. This is often used for extension based routing.
- * for example with an `xml` extension, $subDir would be `xml/`
+ * Eg. With an `xml` extension, $subDir would be `xml/`
*
* @var string
*/
@@ -158,7 +158,7 @@ class View extends Object {
public $cacheAction = false;
/**
- * holds current errors for the model validation
+ * Holds current errors for the model validation.
*
* @var array
*/
@@ -172,7 +172,7 @@ class View extends Object {
public $hasRendered = false;
/**
- * List of generated DOM UUIDs
+ * List of generated DOM UUIDs.
*
* @var array
*/
@@ -205,7 +205,7 @@ class View extends Object {
public $elementCache = 'default';
/**
- * List of variables to collect from the associated controller
+ * List of variables to collect from the associated controller.
*
* @var array
*/
@@ -215,7 +215,7 @@ class View extends Object {
);
/**
- * Scripts (and/or other <head /> tags) for the layout
+ * Scripts (and/or other <head /> tags) for the layout.
*
* @var array
*/
@@ -229,7 +229,7 @@ class View extends Object {
protected $_paths = array();
/**
- * boolean to indicate that helpers have been loaded.
+ * Indicate that helpers have been loaded.
*
* @var boolean
*/
@@ -238,7 +238,7 @@ class View extends Object {
/**
* Constructor
*
- * @param Controller $controller A controller object to pull View::__passedArgs from.
+ * @param Controller $controller A controller object to pull View::_passedVars from.
*/
public function __construct($controller) {
if (is_object($controller)) {
@@ -337,7 +337,7 @@ public function element($name, $data = array(), $options = array()) {
* Renders view for given view file and layout.
*
* Render triggers helper callbacks, which are fired before and after the view are rendered,
- * as well as before and after the layout. The helper callbacks are called
+ * as well as before and after the layout. The helper callbacks are called:
*
* - `beforeRender`
* - `afterRender`
Please sign in to comment.
Something went wrong with that request. Please try again.