mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding fixture all command.
Fixing errors with maxlength and timestamp fields Adding return for ModelTask::listAll()
This commit is contained in:
parent
d3fe3d5959
commit
40ebdf8aac
3 changed files with 17 additions and 2 deletions
|
@ -91,6 +91,12 @@ class FixtureTask extends Shell {
|
||||||
if (isset($this->params['connection'])) {
|
if (isset($this->params['connection'])) {
|
||||||
$ds = $this->params['connection'];
|
$ds = $this->params['connection'];
|
||||||
}
|
}
|
||||||
|
$this->interactive = false;
|
||||||
|
$tables = $this->Model->listAll($ds, false);
|
||||||
|
foreach ($tables as $table) {
|
||||||
|
$model = $this->_modelName($table);
|
||||||
|
$this->bake($model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -246,10 +252,14 @@ class FixtureTask extends Shell {
|
||||||
case 'string';
|
case 'string';
|
||||||
$insert = "Lorem ipsum dolor sit amet";
|
$insert = "Lorem ipsum dolor sit amet";
|
||||||
if (!empty($fieldInfo['length'])) {
|
if (!empty($fieldInfo['length'])) {
|
||||||
$insert = substr($insert, 0, (int)$value['length'] - 2);
|
$insert = substr($insert, 0, (int)$fieldInfo['length'] - 2);
|
||||||
}
|
}
|
||||||
$insert = "'$insert'";
|
$insert = "'$insert'";
|
||||||
break;
|
break;
|
||||||
|
case 'timestamp':
|
||||||
|
$ts = time();
|
||||||
|
$insert = "'$ts'";
|
||||||
|
break;
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
$ts = date('Y-m-d H:i:s');
|
$ts = date('Y-m-d H:i:s');
|
||||||
$insert = "'$ts'";
|
$insert = "'$ts'";
|
||||||
|
|
|
@ -770,6 +770,7 @@ class ModelTask extends Shell {
|
||||||
$this->out($i + 1 . ". " . $this->_modelNames[$i]);
|
$this->out($i + 1 . ". " . $this->_modelNames[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $this->__tables;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Interact with the user to determine the table name of a particular model
|
* Interact with the user to determine the table name of a particular model
|
||||||
|
|
|
@ -74,6 +74,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
$this->Task =& new MockModelTask($this->Dispatcher);
|
$this->Task =& new MockModelTask($this->Dispatcher);
|
||||||
$this->Task->Dispatch = new $this->Dispatcher;
|
$this->Task->Dispatch = new $this->Dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tearDown method
|
* tearDown method
|
||||||
*
|
*
|
||||||
|
@ -84,6 +85,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
unset($this->Task, $this->Dispatcher);
|
unset($this->Task, $this->Dispatcher);
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that listAll scans the database connection and lists all the tables in it.s
|
* Test that listAll scans the database connection and lists all the tables in it.s
|
||||||
*
|
*
|
||||||
|
@ -93,7 +95,9 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
$this->Task->expectCallCount('out', 3);
|
$this->Task->expectCallCount('out', 3);
|
||||||
$this->Task->expectAt(1, 'out', array('1. Article'));
|
$this->Task->expectAt(1, 'out', array('1. Article'));
|
||||||
$this->Task->expectAt(2, 'out', array('2. Comment'));
|
$this->Task->expectAt(2, 'out', array('2. Comment'));
|
||||||
$this->Task->listAll('test_suite');
|
$result = $this->Task->listAll('test_suite');
|
||||||
|
$expected = array('articles', 'comments');
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue