Browse Source

Refactoring FixtureTask so it generates correct file names

Jose Lorenzo Rodriguez 15 years ago
parent
commit
662abd6419

+ 3 - 3
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;
 	}

+ 10 - 10
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/'));