Skip to content

Commit

Permalink
Unskip more tests and fix issues in filenames.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 18, 2014
1 parent 8f72aec commit c26df78
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/Console/Command/Task/ModelTask.php
Expand Up @@ -504,7 +504,7 @@ public function bakeEntity($model, $data = []) {
if (!empty($this->params['no-entity'])) {
return;
}
$name = $model->alias();
$name = Inflector::singularize($model->alias());

$ns = Configure::read('App.namespace');
$pluginPath = '';
Expand All @@ -514,7 +514,7 @@ public function bakeEntity($model, $data = []) {
}

$data += [
'name' => Inflector::singularize($name),
'name' => $name,
'namespace' => $ns,
'plugin' => $this->plugin,
'pluginPath' => $pluginPath,
Expand Down Expand Up @@ -568,7 +568,7 @@ public function bakeTable($model, $data = []) {
$out = $this->Template->generate('classes', 'table');

$path = $this->getPath();
$filename = $path . 'Table/' . $name . '.php';
$filename = $path . 'Table/' . $name . 'Table.php';
$this->out("\n" . __d('cake_console', 'Baking table class for %s...', $name), 1, Shell::QUIET);
$this->createFile($filename, $out);
TableRegistry::clear();
Expand Down
40 changes: 30 additions & 10 deletions tests/TestCase/Console/Command/Task/ModelTaskTest.php
Expand Up @@ -570,28 +570,48 @@ public function testBakeEntityFields() {
$this->assertContains("protected \$_accessible = ['title', 'body', 'published']", $result);
}

/**
* test bake() with a -plugin param
*
* @return void
*/
public function testBakeTableWithPlugin() {
$this->Task->plugin = 'ControllerTest';

// fake plugin path
Plugin::load('ControllerTest', array('path' => APP . 'Plugin/ControllerTest/'));
$path = APP . 'Plugin/ControllerTest/Model/Table/BakeArticlesTable.php';
$this->Task->expects($this->once())->method('createFile')
->with($path, $this->logicalAnd(
$this->stringContains('namespace ControllerTest\\Model\\Table;'),
$this->stringContains('use Cake\\ORM\\Table;'),
$this->stringContains('class BakeArticlesTable extends Table {')
));

$model = TableRegistry::get('BakeArticles');
$this->Task->bakeTable($model);
}

/**
* test bake() with a -plugin param
*
* @return void
*/
public function testBakeWithPlugin() {
$this->markTestIncomplete('Not done here yet');
public function testBakeEntityWithPlugin() {
$this->Task->plugin = 'ControllerTest';

//fake plugin path
// fake plugin path
Plugin::load('ControllerTest', array('path' => APP . 'Plugin/ControllerTest/'));
$path = APP . 'Plugin/ControllerTest/Model/BakeArticle.php';
$path = APP . 'Plugin/ControllerTest/Model/Entity/BakeArticle.php';
$this->Task->expects($this->once())->method('createFile')
->with($path, $this->stringContains('BakeArticle extends ControllerTestAppModel'));

$result = $this->Task->bake('BakeArticle', array(), array());
$this->assertContains("App::uses('ControllerTestAppModel', 'ControllerTest.Model');", $result);
->with($path, $this->logicalAnd(
$this->stringContains('namespace ControllerTest\\Model\\Entity;'),
$this->stringContains('use Cake\\ORM\\Entity;'),
$this->stringContains('class BakeArticle extends Entity {')
));

$this->assertEquals(count(ClassRegistry::keys()), 0);
$this->assertEquals(count(ClassRegistry::mapKeys()), 0);
$model = TableRegistry::get('BakeArticles');
$this->Task->bakeEntity($model);
}

/**
Expand Down

0 comments on commit c26df78

Please sign in to comment.