mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Fixing '0' default values in fixture generation, fixes #4295
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6519 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
c1ea4dff88
commit
82f4427b8b
4 changed files with 17 additions and 7 deletions
|
@ -41,7 +41,7 @@ class NumberTree extends CakeTestModel {
|
|||
|
||||
function __initialize($levelLimit = 3, $childLimit = 3, $currentLevel = null, $parent_id = null, $prefix = '1', $hierachial = true) {
|
||||
if (!$parent_id) {
|
||||
$this->deleteAll('1 = 1');
|
||||
$this->deleteAll(true);
|
||||
$this->save(array($this->name => array('name' => '1. Root')));
|
||||
$this->__initialize($levelLimit, $childLimit, 1, $this->id, '1', $hierachial);
|
||||
$this->create(array());
|
||||
|
|
|
@ -2881,10 +2881,19 @@ class ModelTest extends CakeTestCase {
|
|||
|
||||
$this->model->save(array('title' => 'Test record'));
|
||||
$result = $this->model->findByTitle('Test record');
|
||||
$this->assertEqual(array_keys($result['Uuid']), array('id', 'title', 'created', 'updated'));
|
||||
$this->assertEqual(array_keys($result['Uuid']), array('id', 'title', 'count', 'created', 'updated'));
|
||||
$this->assertEqual(strlen($result['Uuid']['id']), 36);
|
||||
}
|
||||
|
||||
function testZeroDefaultFieldValue() {
|
||||
$this->loadFixtures('Uuid');
|
||||
$this->model =& new Uuid();
|
||||
|
||||
$this->model->create() && $this->model->save();
|
||||
$result = $this->model->findById($this->model->id);
|
||||
$this->assertIdentical($result['Uuid']['count'], '0');
|
||||
}
|
||||
|
||||
function testAfterFindAssociation() {
|
||||
|
||||
}
|
||||
|
|
9
cake/tests/fixtures/uuid_fixture.php
vendored
9
cake/tests/fixtures/uuid_fixture.php
vendored
|
@ -37,14 +37,15 @@ class UuidFixture extends CakeTestFixture {
|
|||
var $fields = array(
|
||||
'id' => array('type' => 'string', 'length' => 36, 'key' => 'primary'),
|
||||
'title' => 'string',
|
||||
'count' => array('type' => 'integer', 'default' => 0),
|
||||
'created' => 'datetime',
|
||||
'updated' => 'datetime'
|
||||
);
|
||||
var $records = array(
|
||||
array('id' => '47c36f9c-bc00-4d17-9626-4e183ca6822b', 'title' => 'Unique record 1', 'created' => '2008-03-13 01:16:23', 'updated' => '2008-03-13 01:18:31'),
|
||||
array('id' => '47c36f9c-f2b0-43f5-b3f7-4e183ca6822b', 'title' => 'Unique record 2', 'created' => '2008-03-13 01:18:24', 'updated' => '2008-03-13 01:20:32'),
|
||||
array('id' => '47c36f9c-0ffc-4084-9b03-4e183ca6822b', 'title' => 'Unique record 3', 'created' => '2008-03-13 01:20:25', 'updated' => '2008-03-13 01:22:33'),
|
||||
array('id' => '47c36f9c-2578-4c2e-aeab-4e183ca6822b', 'title' => 'Unique record 4', 'created' => '2008-03-13 01:22:26', 'updated' => '2008-03-13 01:24:34'),
|
||||
array('id' => '47c36f9c-bc00-4d17-9626-4e183ca6822b', 'title' => 'Unique record 1', 'count' => 2, 'created' => '2008-03-13 01:16:23', 'updated' => '2008-03-13 01:18:31'),
|
||||
array('id' => '47c36f9c-f2b0-43f5-b3f7-4e183ca6822b', 'title' => 'Unique record 2', 'count' => 4, 'created' => '2008-03-13 01:18:24', 'updated' => '2008-03-13 01:20:32'),
|
||||
array('id' => '47c36f9c-0ffc-4084-9b03-4e183ca6822b', 'title' => 'Unique record 3', 'count' => 5, 'created' => '2008-03-13 01:20:25', 'updated' => '2008-03-13 01:22:33'),
|
||||
array('id' => '47c36f9c-2578-4c2e-aeab-4e183ca6822b', 'title' => 'Unique record 4', 'count' => 3, 'created' => '2008-03-13 01:22:26', 'updated' => '2008-03-13 01:24:34'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ class CakeTestFixture extends Object {
|
|||
}
|
||||
if (isset($this->fields)) {
|
||||
foreach ($this->fields as $index => $field) {
|
||||
if (empty($field['default'])) {
|
||||
if (isset($field['default']) && empty($field['default']) && $field['default'] !== 0) {
|
||||
unset($this->fields[$index]['default']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue