ソースを参照

update bakeTask

Anthony GRASSIOT 11 年 前
コミット
1d9dd2adc6

+ 1 - 1
src/Core/ConventionsTrait.php

@@ -40,7 +40,7 @@ trait ConventionsTrait {
  * @return string Singular model key
  */
 	protected function _fixtureName($name) {
-		return Inflector::underscore(Inflector::singularize($name));
+		return Inflector::underscore($name);
 	}
 
 /**

+ 1 - 1
src/Shell/Task/FixtureTask.php

@@ -194,7 +194,7 @@ class FixtureTask extends BakeTask {
  */
 	public function generateFixtureFile($model, array $otherVars) {
 		$defaults = [
-			'name' => Inflector::singularize($model),
+			'name' => $model,
 			'table' => null,
 			'schema' => null,
 			'records' => null,

+ 20 - 20
tests/TestCase/Shell/Task/FixtureTaskTest.php

@@ -101,7 +101,7 @@ class FixtureTaskTest extends TestCase {
 
 		$this->assertContains('namespace App\Test\Fixture;', $result);
 		$this->assertContains('use Cake\TestSuite\Fixture\TestFixture;', $result);
-		$this->assertContains('class ArticleFixture extends TestFixture', $result);
+		$this->assertContains('class ArticlesFixture extends TestFixture', $result);
 		$this->assertContains('public $records', $result);
 		$this->assertContains('public $import', $result);
 		$this->assertContains("'title' => 'First Article'", $result, 'Missing import data %s');
@@ -144,7 +144,7 @@ class FixtureTaskTest extends TestCase {
 	public function testMainWithTableOption() {
 		$this->Task->connection = 'test';
 		$this->Task->params = ['table' => 'comments'];
-		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticleFixture.php');
+		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticlesFixture.php');
 
 		$this->Task->expects($this->at(0))
 			->method('createFile')
@@ -160,13 +160,13 @@ class FixtureTaskTest extends TestCase {
  */
 	public function testMainWithPluginModel() {
 		$this->Task->connection = 'test';
-		$filename = $this->_normalizePath(TEST_APP . 'Plugin/TestPlugin/tests/Fixture/ArticleFixture.php');
+		$filename = $this->_normalizePath(TEST_APP . 'Plugin/TestPlugin/tests/Fixture/ArticlesFixture.php');
 
 		Plugin::load('TestPlugin');
 
 		$this->Task->expects($this->at(0))
 			->method('createFile')
-			->with($filename, $this->stringContains('class ArticleFixture'));
+			->with($filename, $this->stringContains('class ArticlesFixture'));
 
 		$this->Task->main('TestPlugin.Article');
 	}
@@ -182,15 +182,15 @@ class FixtureTaskTest extends TestCase {
 			->method('listAll')
 			->will($this->returnValue(array('articles', 'comments')));
 
-		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticleFixture.php');
+		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticlesFixture.php');
 		$this->Task->expects($this->at(0))
 			->method('createFile')
-			->with($filename, $this->stringContains('class ArticleFixture'));
+			->with($filename, $this->stringContains('class ArticlesFixture'));
 
-		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/CommentFixture.php');
+		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/CommentsFixture.php');
 		$this->Task->expects($this->at(1))
 			->method('createFile')
-			->with($filename, $this->stringContains('class CommentFixture'));
+			->with($filename, $this->stringContains('class CommentsFixture'));
 
 		$this->Task->all();
 	}
@@ -207,12 +207,12 @@ class FixtureTaskTest extends TestCase {
 		$this->Task->Model->expects($this->any())->method('listAll')
 			->will($this->returnValue(array('Articles', 'comments')));
 
-		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticleFixture.php');
+		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticlesFixture.php');
 		$this->Task->expects($this->at(0))
 			->method('createFile')
 			->with($filename, $this->stringContains("'title' => 'Third Article'"));
 
-		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/CommentFixture.php');
+		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/CommentsFixture.php');
 		$this->Task->expects($this->at(1))
 			->method('createFile')
 			->with($filename, $this->stringContains("'comment' => 'First Comment for First Article'"));
@@ -233,11 +233,11 @@ class FixtureTaskTest extends TestCase {
 		$this->Task->Model->expects($this->any())->method('listAll')
 			->will($this->returnValue(array('Articles', 'comments')));
 
-		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticleFixture.php');
+		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticlesFixture.php');
 		$this->Task->expects($this->at(0))->method('createFile')
 			->with($filename, $this->stringContains("public \$import = ['model' => 'Articles'"));
 
-		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/CommentFixture.php');
+		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/CommentsFixture.php');
 		$this->Task->expects($this->at(1))->method('createFile')
 			->with($filename, $this->stringContains("public \$import = ['model' => 'Comments'"));
 		$this->Task->expects($this->exactly(2))->method('createFile');
@@ -257,7 +257,7 @@ class FixtureTaskTest extends TestCase {
 			->method('listAll')
 			->will($this->returnValue(['articles', 'comments']));
 
-		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticleFixture.php');
+		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticlesFixture.php');
 		$this->Task->expects($this->never())
 			->method('createFile');
 
@@ -275,7 +275,7 @@ class FixtureTaskTest extends TestCase {
 		$this->Task->expects($this->at(0))
 			->method('createFile')
 			->with($this->anything(), $this->logicalAnd(
-				$this->stringContains('class ArticleFixture extends TestFixture'),
+				$this->stringContains('class ArticlesFixture extends TestFixture'),
 				$this->stringContains('public $fields'),
 				$this->stringContains('public $records'),
 				$this->logicalNot($this->stringContains('public $import'))
@@ -347,13 +347,13 @@ class FixtureTaskTest extends TestCase {
  */
 	public function testGenerateFixtureFile() {
 		$this->Task->connection = 'test';
-		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticleFixture.php');
+		$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticlesFixture.php');
 
 		$this->Task->expects($this->at(0))
 			->method('createFile')
-			->with($filename, $this->stringContains('ArticleFixture'));
+			->with($filename, $this->stringContains('ArticlesFixture'));
 
-		$result = $this->Task->generateFixtureFile('Article', []);
+		$result = $this->Task->generateFixtureFile('Articles', []);
 		$this->assertContains('<?php', $result);
 		$this->assertContains('namespace App\Test\Fixture;', $result);
 	}
@@ -366,13 +366,13 @@ class FixtureTaskTest extends TestCase {
 	public function testGeneratePluginFixtureFile() {
 		$this->Task->connection = 'test';
 		$this->Task->plugin = 'TestPlugin';
-		$filename = $this->_normalizePath(TEST_APP . 'Plugin/TestPlugin/tests/Fixture/ArticleFixture.php');
+		$filename = $this->_normalizePath(TEST_APP . 'Plugin/TestPlugin/tests/Fixture/ArticlesFixture.php');
 
 		Plugin::load('TestPlugin');
 		$this->Task->expects($this->at(0))->method('createFile')
-			->with($filename, $this->stringContains('class Article'));
+			->with($filename, $this->stringContains('class Articles'));
 
-		$result = $this->Task->generateFixtureFile('Article', []);
+		$result = $this->Task->generateFixtureFile('Articles', []);
 		$this->assertContains('<?php', $result);
 		$this->assertContains('namespace TestPlugin\Test\Fixture;', $result);
 	}

+ 7 - 7
tests/TestCase/TestSuite/FixtureManagerTest.php

@@ -41,12 +41,12 @@ class FixtureManagerTest extends TestCase {
  */
 	public function testFixturizeCore() {
 		$test = $this->getMock('Cake\TestSuite\TestCase');
-		$test->fixtures = ['core.article'];
+		$test->fixtures = ['core.articles'];
 		$this->manager->fixturize($test);
 		$fixtures = $this->manager->loaded();
 		$this->assertCount(1, $fixtures);
-		$this->assertArrayHasKey('core.article', $fixtures);
-		$this->assertInstanceOf('Cake\Test\Fixture\ArticleFixture', $fixtures['core.article']);
+		$this->assertArrayHasKey('core.articles', $fixtures);
+		$this->assertInstanceOf('Cake\Test\Fixture\ArticlesFixture', $fixtures['core.articles']);
 	}
 
 /**
@@ -58,14 +58,14 @@ class FixtureManagerTest extends TestCase {
 		Plugin::load('TestPlugin');
 
 		$test = $this->getMock('Cake\TestSuite\TestCase');
-		$test->fixtures = ['plugin.test_plugin.article'];
+		$test->fixtures = ['plugin.test_plugin.articles'];
 		$this->manager->fixturize($test);
 		$fixtures = $this->manager->loaded();
 		$this->assertCount(1, $fixtures);
-		$this->assertArrayHasKey('plugin.test_plugin.article', $fixtures);
+		$this->assertArrayHasKey('plugin.test_plugin.articles', $fixtures);
 		$this->assertInstanceOf(
-			'TestPlugin\Test\Fixture\ArticleFixture',
-			$fixtures['plugin.test_plugin.article']
+			'TestPlugin\Test\Fixture\ArticlesFixture',
+			$fixtures['plugin.test_plugin.articles']
 		);
 	}