Skip to content

Commit

Permalink
Refactoring FixtureTask so it generates correct file names
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Apr 11, 2011
1 parent d561460 commit 662abd6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/Cake/Console/Command/Task/FixtureTask.php
Expand Up @@ -57,7 +57,7 @@ class FixtureTask extends BakeTask {
*/
public function __construct($stdout = null, $stderr = null, $stdin = null) {
parent::__construct($stdout, $stderr, $stdin);
$this->path = APP . 'tests' . DS . 'fixtures' . DS;
$this->path = APP . 'tests' . DS . 'Fixture' . DS;
}

/**
Expand Down Expand Up @@ -249,7 +249,7 @@ public function generateFixtureFile($model, $otherVars) {
$vars = array_merge($defaults, $otherVars);

$path = $this->getPath();
$filename = Inflector::underscore($model) . '_fixture.php';
$filename = Inflector::camelize($model) . 'Fixture.php';

$this->Template->set('model', $model);
$this->Template->set($vars);
Expand All @@ -268,7 +268,7 @@ public function generateFixtureFile($model, $otherVars) {
public function getPath() {
$path = $this->path;
if (isset($this->plugin)) {
$path = $this->_pluginPath($this->plugin) . 'tests' . DS . 'fixtures' . DS;
$path = $this->_pluginPath($this->plugin) . 'tests' . DS . 'Fixture' . DS;
}
return $path;
}
Expand Down
20 changes: 10 additions & 10 deletions lib/Cake/tests/Case/Console/Command/Task/FixtureTaskTest.php
Expand Up @@ -83,7 +83,7 @@ public function testConstruct() {
$in = $this->getMock('ConsoleInput', array(), array(), '', false);

$Task = new FixtureTask($out, $out, $in);
$this->assertEqual($Task->path, APP . 'tests' . DS . 'fixtures' . DS);
$this->assertEqual($Task->path, APP . 'tests' . DS . 'Fixture' . DS);
}

/**
Expand Down Expand Up @@ -174,7 +174,7 @@ public function testExecuteWithNamedModel() {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('article');
$filename = '/my/path/article_fixture.php';
$filename = '/my/path/ArticleFixture.php';

$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticleFixture/'));
Expand Down Expand Up @@ -204,7 +204,7 @@ public function testExecuteWithNamedModelVariations($modelName) {
$this->Task->path = '/my/path/';

$this->Task->args = array($modelName);
$filename = '/my/path/article_fixture.php';
$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->once())->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticleFixture/'));

Expand All @@ -223,11 +223,11 @@ public function testExecuteIntoAll() {
$this->Task->Model->expects($this->any())->method('listAll')
->will($this->returnValue(array('articles', 'comments')));

$filename = '/my/path/article_fixture.php';
$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticleFixture/'));

$filename = '/my/path/comment_fixture.php';
$filename = '/my/path/CommentFixture.php';
$this->Task->expects($this->at(1))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CommentFixture/'));

Expand All @@ -248,11 +248,11 @@ public function testAllWithCountAndRecordsFlags() {
$this->Task->Model->expects($this->any())->method('listAll')
->will($this->returnValue(array('articles', 'comments')));

$filename = '/my/path/article_fixture.php';
$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/title\' => \'Third Article\'/'));

$filename = '/my/path/comment_fixture.php';
$filename = '/my/path/CommentFixture.php';
$this->Task->expects($this->at(1))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/comment\' => \'First Comment for First Article/'));
$this->Task->expects($this->exactly(2))->method('createFile');
Expand All @@ -275,7 +275,7 @@ public function testExecuteInteractive() {
->with('Article')
->will($this->returnValue('articles'));

$filename = '/my/path/article_fixture.php';
$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->once())->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticleFixture/'));

Expand Down Expand Up @@ -340,7 +340,7 @@ public function testRecordGenerationForBinaryAndFloat() {
public function testGenerateFixtureFile() {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$filename = '/my/path/article_fixture.php';
$filename = '/my/path/ArticleFixture.php';

$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/ArticleFixture/'));
Expand All @@ -362,7 +362,7 @@ public function testGeneratePluginFixtureFile() {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->plugin = 'TestFixture';
$filename = APP . 'plugins' . DS . 'test_fixture' . DS . 'tests' . DS . 'fixtures' . DS . 'article_fixture.php';
$filename = APP . 'plugins' . DS . 'test_fixture' . DS . 'tests' . DS . 'Fixture' . DS . 'ArticleFixture.php';

$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/Article/'));
Expand Down

0 comments on commit 662abd6

Please sign in to comment.