Merge branch 'master' into 2.3

This commit is contained in:
mark_story 2012-08-24 22:50:29 -04:00
commit d66d37c92b
12 changed files with 25 additions and 18 deletions

View file

@ -447,7 +447,7 @@ class DboSource extends DataSource {
*/
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
$sql = trim($sql);
if (preg_match('/^(?:CREATE|ALTER|DROP)/i', $sql)) {
if (preg_match('/^(?:CREATE|ALTER|DROP)\s+(?:TABLE|INDEX)/i', $sql)) {
$statements = array_filter(explode(';', $sql));
if (count($statements) > 1) {
$result = array_map(array($this, '_execute'), $statements);

View file

@ -1745,7 +1745,6 @@ class Model extends Object implements CakeEventListener {
if ($success && $count > 0) {
if (!empty($this->data)) {
$success = $this->data;
if ($created) {
$this->data[$this->alias][$this->primaryKey] = $this->id;
}
@ -1755,7 +1754,7 @@ class Model extends Object implements CakeEventListener {
$this->getEventManager()->dispatch($event);
}
if (!empty($this->data)) {
$success = Hash::merge($success, $this->data);
$success = $this->data;
}
$this->data = false;
$this->_clearCache();

View file

@ -888,6 +888,7 @@ class BehaviorCollectionTest extends CakeTestCase {
$Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'test'));
$Sample->create();
$expected = $record;
unset($expected['Sample']['name']);
$result = $Sample->save($record);
$expected['Sample']['id'] = $Sample->id;
$this->assertSame($expected, $result);

View file

@ -213,7 +213,6 @@ class ModelCrossSchemaHabtmTest extends BaseModelTest {
'Armor' => array(
'Armor' => array(
1, 2, 3, 4,
1, 2, 3, 4,
),
),
);

View file

@ -1170,6 +1170,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertFalse(empty($result));
$result = $TestModel->save();
$this->assertFalse(empty($result));
$this->assertEquals($data['Tag'], $result['Tag']);
$TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));

View file

@ -1498,16 +1498,20 @@ class ValidationTest extends CakeTestCase {
$this->assertTrue(Validation::decimal('+0123.45e6'));
$this->assertTrue(Validation::decimal('-0123.45e6'));
$this->assertTrue(Validation::decimal('0123.45e6'));
$this->assertTrue(Validation::decimal('1234'));
$this->assertTrue(Validation::decimal('-1234'));
$this->assertTrue(Validation::decimal('+1234'));
$this->assertTrue(Validation::decimal(1234.56));
$this->assertTrue(Validation::decimal(1234.00));
$this->assertTrue(Validation::decimal('1234.00'));
$this->assertTrue(Validation::decimal(.0));
$this->assertTrue(Validation::decimal(.00));
$this->assertTrue(Validation::decimal('.00'));
$this->assertTrue(Validation::decimal(.01));
$this->assertTrue(Validation::decimal('.01'));
$this->assertFalse(Validation::decimal(''));
$this->assertFalse(Validation::decimal('string'));
$this->assertFalse(Validation::decimal('1234'));
$this->assertFalse(Validation::decimal('-1234'));
$this->assertFalse(Validation::decimal('+1234'));
}
/**

View file

@ -13,11 +13,11 @@ class Test2OtherSource extends DataSource {
return compact('model', 'fields', 'values');
}
public function read(Model $model, $queryData = array()) {
public function read(Model $model, $queryData = array(), $recursive = null) {
return compact('model', 'queryData');
}
public function update(Model $model, $fields = array(), $values = array()) {
public function update(Model $model, $fields = array(), $values = array(), $conditions = null) {
return compact('model', 'fields', 'values');
}

View file

@ -13,11 +13,11 @@ class Test2Source extends DataSource {
return compact('model', 'fields', 'values');
}
public function read(Model $model, $queryData = array()) {
public function read(Model $model, $queryData = array(), $recursive = null) {
return compact('model', 'queryData');
}
public function update(Model $model, $fields = array(), $values = array()) {
public function update(Model $model, $fields = array(), $values = array(), $conditions = null) {
return compact('model', 'fields', 'values');
}

View file

@ -13,11 +13,11 @@ class TestOtherSource extends DataSource {
return compact('model', 'fields', 'values');
}
public function read(Model $model, $queryData = array()) {
public function read(Model $model, $queryData = array(), $recursive = null) {
return compact('model', 'queryData');
}
public function update(Model $model, $fields = array(), $values = array()) {
public function update(Model $model, $fields = array(), $values = array(), $conditions = null) {
return compact('model', 'fields', 'values');
}

View file

@ -15,11 +15,11 @@ class TestSource extends DataSource {
return compact('model', 'fields', 'values');
}
public function read(Model $model, $queryData = array()) {
public function read(Model $model, $queryData = array(), $recursive = null) {
return compact('model', 'queryData');
}
public function update(Model $model, $fields = array(), $values = array()) {
public function update(Model $model, $fields = array(), $values = array(), $conditions = null) {
return compact('model', 'fields', 'values');
}

View file

@ -381,11 +381,14 @@ class Validation {
* @return boolean Success
*/
public static function decimal($check, $places = null, $regex = null) {
if (is_float($check) && floor($check) === $check) {
$check = sprintf("%.1f", $check);
}
if (is_null($regex)) {
if (is_null($places)) {
$regex = '/^[-+]?[0-9]*(\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?)?$/';
$regex = '/^[-+]?[0-9]*\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/';
} else {
$regex = '/^[-+]?[0-9]*(\\.{1}[0-9]{' . $places . '})?$/';
$regex = '/^[-+]?[0-9]*\\.{1}[0-9]{' . $places . '}$/';
}
}
return self::_check($check, $regex);

View file

@ -142,7 +142,7 @@ class JsHelper extends AppHelper {
$this->buffer($out);
return null;
}
if (is_object($out) && is_a($out, 'JsBaseEngineHelper')) {
if (is_object($out) && $out instanceof JsBaseEngineHelper) {
return $this;
}
return $out;