Merge branch 'master' into 2.5

This commit is contained in:
mark_story 2014-01-16 15:20:40 -05:00
commit 75dd2ff1fb
10 changed files with 125 additions and 16 deletions

View file

@ -29,6 +29,7 @@
<exclude name="Console/cake.bat" />
<exclude name="Console/cake.php" />
<exclude name="Console/cake" />
<exclude name="./lib/Cake/Test" />
</fileset>
<!--
@ -40,10 +41,6 @@
<include name="cake" />
</fileset>
<fileset id="non-tests" dir="./lib/Cake">
<exclude name=".lib/Cake/Test" />
</fileset>
<!-- start fresh each time. Remove the dist and build dirs -->
<target name="clean">
<delete dir="${build.dir}" includeemptydirs="true" />
@ -140,7 +137,6 @@
<package name="PHPUnit" channel="pear.phpunit.de" minimum_version="3.5.0" type="optional" />
</dependencies>
<dirroles key="bin">script</dirroles>
<dirroles key="Cake/Test">php</dirroles>
<dirroles key="Cake/Console/Templates/skel">php</dirroles>
<dirroles key="Cake/Console/Templates/default">php</dirroles>
<dirroles key="Cake/View">php</dirroles>
@ -244,11 +240,11 @@
<formatter type="pmd" outfile="pmd-cpd.xml"/>
</phpcpd>
<phpdepend>
<fileset refid="non-tests" />
<fileset refid="libs" />
<logger type="jdepend-xml" outfile="jdepend.xml"/>
</phpdepend>
<phpmd rulesets="codesize,unusedcode,design">
<fileset refid="non-tests" />
<fileset refid="libs" />
<formatter type="xml" outfile="reports/pmd.html"/>
</phpmd>
</target>

View file

@ -110,6 +110,7 @@ class ControllerTask extends BakeTask {
$admin = $this->Project->getPrefix();
}
$controllersCreated = 0;
foreach ($this->__tables as $table) {
$model = $this->_modelName($table);
$controller = $this->_controllerName($model);
@ -123,8 +124,13 @@ class ControllerTask extends BakeTask {
if ($this->bake($controller, $actions) && $unitTestExists) {
$this->bakeTest($controller);
}
$controllersCreated++;
}
}
if (!$controllersCreated) {
$this->out(__d('cake_console', 'No Controllers were baked, Models need to exist before Controllers can be baked.'));
}
}
/**

View file

@ -305,7 +305,7 @@ class TranslateBehavior extends ModelBehavior {
}
} else {
$value = '';
if (!empty($row[$Model->alias][$aliasVirtual])) {
if (is_numeric($row[$Model->alias][$aliasVirtual]) || !empty($row[$Model->alias][$aliasVirtual])) {
$value = $row[$Model->alias][$aliasVirtual];
}
$row[$Model->alias][$aliasField] = $value;

View file

@ -354,6 +354,31 @@ class TranslateBehaviorTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
/**
* Test loading fields with 0 as the translated value.
*/
public function testFetchTranslationsWithZero() {
$this->loadFixtures('Translate', 'TranslatedItem');
$model = new TranslatedItem();
$translateModel = $model->translateModel();
$translateModel->updateAll(array('content' => "'0'"));
$model->locale = 'eng';
$result = $model->read(null, 1);
$expected = array(
'TranslatedItem' => array(
'id' => 1,
'slug' => 'first_translated',
'locale' => 'eng',
'title' => '0',
'content' => '0',
'translated_article_id' => 1,
)
);
$this->assertEquals($expected, $result);
}
/**
* testLocaleMultiple method
*

View file

@ -65,7 +65,7 @@ class CakeTestFixtureTestFixture extends CakeTestFixture {
}
/**
* StringFieldsTestFixture class
* StringTestFixture class
*
* @package Cake.Test.Case.TestSuite
*/
@ -109,6 +109,50 @@ class StringsTestFixture extends CakeTestFixture {
);
}
/**
* InvalidTestFixture class
*
* @package Cake.Test.Case.TestSuite
*/
class InvalidTestFixture extends CakeTestFixture {
/**
* Name property
*
* @var string
*/
public $name = 'Invalid';
/**
* Table property
*
* @var string
*/
public $table = 'invalid';
/**
* Fields array - missing "email" row
*
* @var array
*/
public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'name' => array('type' => 'string', 'length' => '255'),
'age' => array('type' => 'integer', 'default' => 10)
);
/**
* Records property
*
* @var array
*/
public $records = array(
array('name' => 'Mark Doe', 'email' => 'mark.doe@email.com'),
array('name' => 'John Doe', 'email' => 'john.doe@email.com', 'age' => 20),
array('email' => 'jane.doe@email.com', 'name' => 'Jane Doe', 'age' => 30)
);
}
/**
* CakeTestFixtureImportFixture class
*
@ -482,6 +526,17 @@ class CakeTestFixtureTest extends CakeTestCase {
$this->assertEquals($expected, $this->insertMulti['fields_values']);
}
/**
* test the insert method with invalid fixture
*
* @expectedException CakeException
* @return void
*/
public function testInsertInvalid() {
$Fixture = new InvalidTestFixture();
$return = $Fixture->insert($this->criticDb);
}
/**
* Test the drop method
*

View file

@ -6315,6 +6315,25 @@ class FormHelperTest extends CakeTestCase {
$this->assertNotRegExp('/selected="selected">\d/', $result);
}
/**
* testDateTime all zeros
*
* @return void
*/
public function testDateTimeAllZeros() {
$result = $this->Form->dateTime('Contact.date',
'DMY',
false,
array(
'empty' => array('day' => '-', 'month' => '-', 'year' => '-'),
'value' => '0000-00-00'
)
);
$this->assertRegExp('/<option value="">-<\/option>/', $result);
$this->assertNotRegExp('/<option value="0" selected="selected">0<\/option>/', $result);
}
/**
* testDateTimeEmptyAsArray
*

View file

@ -265,6 +265,7 @@ class CakeTestFixture {
*
* @param DboSource $db An instance of the database into which the records will be inserted
* @return boolean on success or if there are no records to insert, or false on failure
* @throws CakeException if counts of values and fields do not match.
*/
public function insert($db) {
if (!isset($this->_insert)) {
@ -277,7 +278,11 @@ class CakeTestFixture {
$fields = array_unique($fields);
$default = array_fill_keys($fields, null);
foreach ($this->records as $record) {
$values[] = array_values(array_merge($default, $record));
$merge = array_values(array_merge($default, $record));
if (count($fields) !== count($merge)) {
throw new CakeException('Fixture invalid: Count of fields does not match count of values');
}
$values[] = $merge;
}
$nested = $db->useNestedTransactions;
$db->useNestedTransactions = false;

View file

@ -83,14 +83,14 @@ class CakeTime {
public static $wordEnd = '+1 month';
/**
* Temporary variable containing timestamp value, used internally convertSpecifiers()
* Temporary variable containing the timestamp value, used internally in convertSpecifiers()
*
* @var integer
*/
protected static $_time = null;
/**
* Magic set method for backward compatibility.
* Magic set method for backwards compatibility.
* Used by TimeHelper to modify static variables in CakeTime
*
* @param string $name Variable name
@ -106,7 +106,7 @@ class CakeTime {
}
/**
* Magic set method for backward compatibility.
* Magic set method for backwards compatibility.
* Used by TimeHelper to get static variables in CakeTime
*
* @param string $name Variable name

View file

@ -79,8 +79,7 @@ class Debugger {
'traceLine' => '{:reference} - {:path}, line {:line}',
'trace' => "Trace:\n{:trace}\n",
'context' => "Context:\n{:context}\n",
),
'log' => array(),
)
);
/**

View file

@ -2846,7 +2846,11 @@ class FormHelper extends AppHelper {
if ($min > $max) {
list($min, $max) = array($max, $min);
}
if (!empty($options['value']) && (int)$options['value'] < $min) {
if (
!empty($options['value']) &&
(int)$options['value'] < $min &&
(int)$options['value'] > 0
) {
$min = (int)$options['value'];
} elseif (!empty($options['value']) && (int)$options['value'] > $max) {
$max = (int)$options['value'];