Skip to content

Commit

Permalink
Fix & mark Console/ tests incomplete.
Browse files Browse the repository at this point in the history
Fix a few of the console/ tests, mark the remaining ones as incomplete.
The incomplete tests rely on old the now removed model class.
  • Loading branch information
markstory committed Dec 17, 2013
1 parent db1f1a1 commit c337981
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
24 changes: 16 additions & 8 deletions Cake/Console/Command/Task/ModelTask.php
Expand Up @@ -19,7 +19,7 @@
use Cake\Console\Shell;
use Cake\Core\App;
use Cake\Database\ConnectionManager;
use Cake\Model\Model;
use Cake\ORM\TableRegistry;
use Cake\Utility\ClassRegistry;
use Cake\Utility\Inflector;

Expand Down Expand Up @@ -146,8 +146,14 @@ protected function _getModelObject($className, $table = null) {
if (!$table) {
$table = Inflector::tableize($className);
}
$object = new Model(['name' => $className, 'table' => $table, 'ds' => $this->connection]);
$fields = $object->schema(true);
throw new \Exception('Baking models does not work currently.');

$object = TableRegistry::get($className, [
'name' => $className,
'table' => $table,
'ds' => $this->connection
]);
$fields = $object->schema();
foreach ($fields as $name => $field) {
if (isset($field['key']) && $field['key'] === 'primary') {
$object->primaryKey = $name;
Expand Down Expand Up @@ -201,6 +207,8 @@ protected function _interactive() {
if (empty($this->connection)) {
$this->connection = $this->DbConfig->getConfig();
}
throw new \Exception('Baking models does not work yet.');

$currentModelName = $this->getName();
$useTable = $this->getTable($currentModelName);
$db = ConnectionManager::getDataSource($this->connection);
Expand Down Expand Up @@ -591,7 +599,7 @@ public function doActsAs($model) {
* @param array $associations Array of in progress associations
* @return array Associations with belongsTo added in.
*/
public function findBelongsTo(Model $model, $associations) {
public function findBelongsTo($model, $associations) {
$fieldNames = array_keys($model->schema(true));
foreach ($fieldNames as $fieldName) {
$offset = strpos($fieldName, '_id');
Expand Down Expand Up @@ -620,7 +628,7 @@ public function findBelongsTo(Model $model, $associations) {
* @param array $associations Array of in progress associations
* @return array Associations with hasOne and hasMany added in.
*/
public function findHasOneAndMany(Model $model, $associations) {
public function findHasOneAndMany($model, $associations) {
$foreignKey = $this->_modelKey($model->name);
foreach ($this->_tables as $otherTable) {
$tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable);
Expand Down Expand Up @@ -663,7 +671,7 @@ public function findHasOneAndMany(Model $model, $associations) {
* @param array $associations Array of in-progress associations
* @return array Associations with hasAndBelongsToMany added in.
*/
public function findHasAndBelongsToMany(Model $model, $associations) {
public function findHasAndBelongsToMany($model, $associations) {
$foreignKey = $this->_modelKey($model->name);
foreach ($this->_tables as $otherTable) {
$tableName = null;
Expand Down Expand Up @@ -696,7 +704,7 @@ public function findHasAndBelongsToMany(Model $model, $associations) {
* @param array $associations Array of associations to be confirmed.
* @return array Array of confirmed associations
*/
public function confirmAssociations(Model $model, $associations) {
public function confirmAssociations($model, $associations) {
foreach ($associations as $type => $settings) {
if (!empty($associations[$type])) {
foreach ($associations[$type] as $i => $assoc) {
Expand All @@ -722,7 +730,7 @@ public function confirmAssociations(Model $model, $associations) {
* @param array $associations Array of associations.
* @return array Array of associations.
*/
public function doMoreAssociations(Model $model, $associations) {
public function doMoreAssociations($model, $associations) {
$prompt = __d('cake_console', 'Would you like to define some additional model associations?');
$wannaDoMoreAssoc = $this->in($prompt, ['y', 'n'], 'n');
$possibleKeys = $this->_generatePossibleKeys();
Expand Down
1 change: 1 addition & 0 deletions Cake/Test/TestCase/Console/Command/BakeShellTest.php
Expand Up @@ -65,6 +65,7 @@ public function tearDown() {
* @return void
*/
public function testAllWithModelName() {
$this->markTestIncomplete('Baking with models is not working right now.');
$dispatcher =& $this->Dispatcher;

$this->Shell->Model = $this->getMock(
Expand Down
Expand Up @@ -94,7 +94,7 @@ public function testMain() {
$expected = "/\[.*TestPluginTwo.*\] example, welcome/";
$this->assertRegExp($expected, $output);

$expected = "/\[.*CORE.*\] acl, bake, i18n, server, test, upgrade/";
$expected = "/\[.*CORE.*\] bake, i18n, server, test, upgrade/";
$this->assertRegExp($expected, $output);

$expected = "/\[.*app.*\] sample/";
Expand Down
2 changes: 1 addition & 1 deletion Cake/Test/TestCase/Console/Command/CompletionShellTest.php
Expand Up @@ -112,7 +112,7 @@ public function testCommands() {
$this->Shell->runCommand('commands', array());
$output = $this->Shell->stdout->output;

$expected = "TestPlugin.example TestPluginTwo.example TestPluginTwo.welcome acl bake i18n server test upgrade sample\n";
$expected = "TestPlugin.example TestPluginTwo.example TestPluginTwo.welcome bake i18n server test upgrade sample\n";
$this->assertEquals($expected, $output);
}

Expand Down
3 changes: 3 additions & 0 deletions Cake/Test/TestCase/Console/Command/Task/ExtractTaskTest.php
Expand Up @@ -292,6 +292,7 @@ public function testExtractPlugin() {
$this->Task->params['output'] = $this->path . DS;
$this->Task->params['plugin'] = 'TestPlugin';

$this->markTestIncomplete('Extracting validation messages from plugin models is not working.');
$this->Task->execute();
$result = file_get_contents($this->path . DS . 'default.pot');
$this->assertNotRegExp('#Pages#', $result);
Expand All @@ -306,6 +307,7 @@ public function testExtractPlugin() {
* @return void
*/
public function testExtractModelValidation() {
$this->markTestIncomplete('Extracting validation messages is not working right now.');
Configure::write('App.namespace', 'TestApp');
Plugin::load('TestPlugin');

Expand Down Expand Up @@ -353,6 +355,7 @@ public function testExtractModelValidation() {
* @return void
*/
public function testExtractModelValidationInPlugin() {
$this->markTestIncomplete('Extracting validation messages is not working right now.');
Configure::write('App.namespace', 'TestApp');
Plugin::load('TestPlugin');
$this->out = $this->getMock('Cake\Console\ConsoleOutput', array(), array(), '', false);
Expand Down
4 changes: 2 additions & 2 deletions Cake/Test/TestCase/Console/Command/Task/TestTaskTest.php
Expand Up @@ -32,7 +32,7 @@
* Test Article model
*
*/
class TestTaskArticles extends Table {
class TestTaskArticlesTable extends Table {

/**
* Table name to use
Expand Down Expand Up @@ -243,7 +243,7 @@ public function testFilePathGenerationModelRepeated() {
* @return void
*/
public function testMethodIntrospection() {
$result = $this->Task->getTestableMethods(__NAMESPACE__ . '\TestTaskArticle');
$result = $this->Task->getTestableMethods(__NAMESPACE__ . '\TestTaskArticlesTable');
$expected = array('dosomething', 'dosomethingelse');
$this->assertEquals($expected, array_map('strtolower', $result));
}
Expand Down

0 comments on commit c337981

Please sign in to comment.