Skip to content

Commit

Permalink
Merge branch 'master' into 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 16, 2014
2 parents 8b5336a + f25e84f commit 75dd2ff
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 16 deletions.
10 changes: 3 additions & 7 deletions build.xml
Expand Up @@ -29,6 +29,7 @@
<exclude name="Console/cake.bat" />
<exclude name="Console/cake.php" />
<exclude name="Console/cake" />
<exclude name="./lib/Cake/Test" />
</fileset>

<!--
Expand All @@ -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" />
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
6 changes: 6 additions & 0 deletions lib/Cake/Console/Command/Task/ControllerTask.php
Expand Up @@ -110,6 +110,7 @@ public function all() {
$admin = $this->Project->getPrefix();
}

$controllersCreated = 0;
foreach ($this->__tables as $table) {
$model = $this->_modelName($table);
$controller = $this->_controllerName($model);
Expand All @@ -123,8 +124,13 @@ public function all() {
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.'));
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -305,7 +305,7 @@ public function afterFind(Model $Model, $results, $primary = false) {
}
} 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;
Expand Down
25 changes: 25 additions & 0 deletions lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
Expand Up @@ -354,6 +354,31 @@ public function testLocaleSingleAssociations() {
$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
*
Expand Down
57 changes: 56 additions & 1 deletion lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php
Expand Up @@ -65,7 +65,7 @@ class CakeTestFixtureTestFixture extends CakeTestFixture {
}

/**
* StringFieldsTestFixture class
* StringTestFixture class
*
* @package Cake.Test.Case.TestSuite
*/
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -482,6 +526,17 @@ public function testInsertStrings() {
$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
*
Expand Down
19 changes: 19 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -6315,6 +6315,25 @@ public function testDateTimeWithBogusData() {
$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
*
Expand Down
7 changes: 6 additions & 1 deletion lib/Cake/TestSuite/Fixture/CakeTestFixture.php
Expand Up @@ -265,6 +265,7 @@ public function drop($db) {
*
* @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)) {
Expand All @@ -277,7 +278,11 @@ public function insert($db) {
$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;
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Utility/CakeTime.php
Expand Up @@ -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
Expand All @@ -106,7 +106,7 @@ public function __set($name, $value) {
}

/**
* 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
Expand Down
3 changes: 1 addition & 2 deletions lib/Cake/Utility/Debugger.php
Expand Up @@ -79,8 +79,7 @@ class Debugger {
'traceLine' => '{:reference} - {:path}, line {:line}',
'trace' => "Trace:\n{:trace}\n",
'context' => "Context:\n{:context}\n",
),
'log' => array(),
)
);

/**
Expand Down
6 changes: 5 additions & 1 deletion lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -2846,7 +2846,11 @@ protected function _generateOptions($name, $options = array()) {
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'];
Expand Down

0 comments on commit 75dd2ff

Please sign in to comment.