Merge branch 'master' into 2.3

Conflicts:
	lib/Cake/bootstrap.php
This commit is contained in:
ADmad 2012-10-23 16:53:01 +05:30
commit 1763f46340
8 changed files with 85 additions and 15 deletions

View file

@ -24,13 +24,6 @@ App::uses('CakePlugin', 'Core');
App::uses('L10n', 'I18n'); App::uses('L10n', 'I18n');
App::uses('Multibyte', 'I18n'); App::uses('Multibyte', 'I18n');
if (function_exists('mb_internal_encoding')) {
$encoding = Configure::read('App.encoding');
if (!empty($encoding)) {
mb_internal_encoding($encoding);
}
}
/** /**
* I18n handles translation of Text and time format strings. * I18n handles translation of Text and time format strings.
* *

View file

@ -2997,7 +2997,7 @@ class DboSource extends DataSource {
$tableParameters = array_merge($tableParameters, $this->buildTableParameters($col, $table)); $tableParameters = array_merge($tableParameters, $this->buildTableParameters($col, $table));
} }
} }
if (empty($indexes) && !empty($primary)) { if (!isset($columns['indexes']['PRIMARY']) && !empty($primary)) {
$col = array('PRIMARY' => array('column' => $primary, 'unique' => 1)); $col = array('PRIMARY' => array('column' => $primary, 'unique' => 1));
$indexes = array_merge($indexes, $this->buildIndex($col, $table)); $indexes = array_merge($indexes, $this->buildIndex($col, $table));
} }

View file

@ -2028,7 +2028,7 @@ class Model extends Object implements CakeEventListener {
* @link http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveassociated-array-data-null-array-options-array * @link http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveassociated-array-data-null-array-options-array
* @link http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveall-array-data-null-array-options-array * @link http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveall-array-data-null-array-options-array
*/ */
public function saveAll($data, $options = array()) { public function saveAll($data = array(), $options = array()) {
$options = array_merge(array('validate' => 'first'), $options); $options = array_merge(array('validate' => 'first'), $options);
if (Hash::numeric(array_keys($data))) { if (Hash::numeric(array_keys($data))) {
if ($options['validate'] === 'only') { if ($options['validate'] === 'only') {

View file

@ -926,6 +926,52 @@ class MysqlTest extends CakeTestCase {
$this->assertContains('`user_id` int(11) NOT NULL,', $result); $this->assertContains('`user_id` int(11) NOT NULL,', $result);
} }
/**
* Test that the primary flag is handled correctly.
*
* @return void
*/
public function testCreateSchemaAutoPrimaryKey() {
$schema = new CakeSchema();
$schema->tables = array(
'no_indexes' => array(
'id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'),
'data' => array('type' => 'integer', 'null' => false),
'indexes' => array(),
)
);
$result = $this->Dbo->createSchema($schema, 'no_indexes');
$this->assertContains('PRIMARY KEY (`id`)', $result);
$this->assertNotContains('UNIQUE KEY', $result);
$schema->tables = array(
'primary_index' => array(
'id' => array('type' => 'integer', 'null' => false),
'data' => array('type' => 'integer', 'null' => false),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'some_index' => array('column' => 'data', 'unique' => 1)
),
)
);
$result = $this->Dbo->createSchema($schema, 'primary_index');
$this->assertContains('PRIMARY KEY (`id`)', $result);
$this->assertContains('UNIQUE KEY `some_index` (`data`)', $result);
$schema->tables = array(
'primary_flag_has_index' => array(
'id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'),
'data' => array('type' => 'integer', 'null' => false),
'indexes' => array (
'some_index' => array('column' => 'data', 'unique' => 1)
),
)
);
$result = $this->Dbo->createSchema($schema, 'primary_flag_has_index');
$this->assertContains('PRIMARY KEY (`id`)', $result);
$this->assertContains('UNIQUE KEY `some_index` (`data`)', $result);
}
/** /**
* Tests that listSources method sends the correct query and parses the result accordingly * Tests that listSources method sends the correct query and parses the result accordingly
* @return void * @return void

View file

@ -4725,6 +4725,32 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEquals($expected, $TestModel->Comment->validationErrors); $this->assertEquals($expected, $TestModel->Comment->validationErrors);
} }
/**
* test that saveAll still behaves like previous versions (does not necessarily need a first argument)
*
* @return void
*/
public function testSaveAllWithSet() {
$this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag');
$data = array(
'Article' => array(
'user_id' => 1,
'title' => 'Article Has and belongs to Many Tags'
),
'Tag' => array(
'Tag' => array(1, 2)
),
'Comment' => array(
array(
'comment' => 'Article comment',
'user_id' => 1
)));
$Article = new Article();
$Article->set($data);
$result = $Article->saveAll();
$this->assertFalse(empty($result));
}
/** /**
* test that saveAll behaves like plain save() when supplied empty data * test that saveAll behaves like plain save() when supplied empty data
* *
@ -4740,7 +4766,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertFalse(empty($result)); $this->assertFalse(empty($result));
$model = new ProductUpdateAll(); $model = new ProductUpdateAll();
$result = $model->saveAll(array()); $result = $model->saveAll();
$this->assertFalse($result); $this->assertFalse($result);
} }

View file

@ -109,6 +109,7 @@ class InflectorTest extends CakeTestCase {
$this->assertEquals(Inflector::singularize('roofs'), 'roof'); $this->assertEquals(Inflector::singularize('roofs'), 'roof');
$this->assertEquals(Inflector::singularize('foes'), 'foe'); $this->assertEquals(Inflector::singularize('foes'), 'foe');
$this->assertEquals(Inflector::singularize('databases'), 'database'); $this->assertEquals(Inflector::singularize('databases'), 'database');
$this->assertEquals(Inflector::singularize('cookies'), 'cookie');
$this->assertEquals(Inflector::singularize(''), ''); $this->assertEquals(Inflector::singularize(''), '');
} }
@ -160,6 +161,7 @@ class InflectorTest extends CakeTestCase {
$this->assertEquals(Inflector::pluralize('cafe'), 'cafes'); $this->assertEquals(Inflector::pluralize('cafe'), 'cafes');
$this->assertEquals(Inflector::pluralize('roof'), 'roofs'); $this->assertEquals(Inflector::pluralize('roof'), 'roofs');
$this->assertEquals(Inflector::pluralize('foe'), 'foes'); $this->assertEquals(Inflector::pluralize('foe'), 'foes');
$this->assertEquals(Inflector::pluralize('cookie'), 'cookies');
$this->assertEquals(Inflector::pluralize(''), ''); $this->assertEquals(Inflector::pluralize(''), '');
} }

View file

@ -55,7 +55,7 @@ class Inflector {
'/$/' => 's', '/$/' => 's',
), ),
'uninflected' => array( 'uninflected' => array(
'.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people' '.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people', 'cookie'
), ),
'irregular' => array( 'irregular' => array(
'atlas' => 'atlases', 'atlas' => 'atlases',
@ -63,6 +63,7 @@ class Inflector {
'brother' => 'brothers', 'brother' => 'brothers',
'cafe' => 'cafes', 'cafe' => 'cafes',
'child' => 'children', 'child' => 'children',
'cookie' => 'cookies',
'corpus' => 'corpuses', 'corpus' => 'corpuses',
'cow' => 'cows', 'cow' => 'cows',
'ganglion' => 'ganglions', 'ganglion' => 'ganglions',

View file

@ -129,14 +129,10 @@ if (!defined('JS_URL')) {
define('JS_URL', 'js/'); define('JS_URL', 'js/');
} }
require CAKE . 'basics.php'; require CAKE . 'basics.php';
require CAKE . 'Core' . DS . 'App.php'; require CAKE . 'Core' . DS . 'App.php';
require CAKE . 'Error' . DS . 'exceptions.php'; require CAKE . 'Error' . DS . 'exceptions.php';
/** /**
* Full url prefix * Full url prefix
*/ */
@ -165,3 +161,9 @@ App::$bootstrapping = true;
Configure::bootstrap(isset($boot) ? $boot : true); Configure::bootstrap(isset($boot) ? $boot : true);
if (function_exists('mb_internal_encoding')) {
$encoding = Configure::read('App.encoding');
if (!empty($encoding)) {
mb_internal_encoding($encoding);
}
}