From 662abd6419f844696205f2d5e99913d4a3fb8dc3 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sun, 10 Apr 2011 20:56:06 -0430 Subject: [PATCH] Refactoring FixtureTask so it generates correct file names --- lib/Cake/Console/Command/Task/FixtureTask.php | 6 +++--- .../Console/Command/Task/FixtureTaskTest.php | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index 788e08574..daf3e412d 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -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; } /** @@ -249,7 +249,7 @@ class FixtureTask extends BakeTask { $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); @@ -268,7 +268,7 @@ class FixtureTask extends BakeTask { 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; } diff --git a/lib/Cake/tests/Case/Console/Command/Task/FixtureTaskTest.php b/lib/Cake/tests/Case/Console/Command/Task/FixtureTaskTest.php index 1fd607f85..a22631d99 100644 --- a/lib/Cake/tests/Case/Console/Command/Task/FixtureTaskTest.php +++ b/lib/Cake/tests/Case/Console/Command/Task/FixtureTaskTest.php @@ -83,7 +83,7 @@ class FixtureTaskTest extends CakeTestCase { $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); } /** @@ -174,7 +174,7 @@ class FixtureTaskTest extends CakeTestCase { $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/')); @@ -204,7 +204,7 @@ class FixtureTaskTest extends CakeTestCase { $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/')); @@ -223,11 +223,11 @@ class FixtureTaskTest extends CakeTestCase { $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/')); @@ -248,11 +248,11 @@ class FixtureTaskTest extends CakeTestCase { $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'); @@ -275,7 +275,7 @@ class FixtureTaskTest extends CakeTestCase { ->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/')); @@ -340,7 +340,7 @@ class FixtureTaskTest extends CakeTestCase { 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/')); @@ -362,7 +362,7 @@ class FixtureTaskTest extends CakeTestCase { $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/'));