Browse Source

Fix path related failures in bake tasks.

mark_story 12 years ago
parent
commit
c6dc245f23

+ 1 - 1
src/Console/Command/Task/BakeTask.php

@@ -71,7 +71,7 @@ class BakeTask extends Shell {
 		if (isset($this->plugin)) {
 			$path = $this->_pluginPath($this->plugin) . $this->pathFragment;
 		}
-		return $path;
+		return str_replace('/', DS, $path);
 	}
 
 /**

+ 1 - 1
src/Console/Command/Task/FixtureTask.php

@@ -47,7 +47,7 @@ class FixtureTask extends BakeTask {
 		if (isset($this->plugin)) {
 			$path = $this->_pluginPath($this->plugin) . $dir;
 		}
-		return $path;
+		return str_replace('/', DS, $path);
 	}
 
 /**

+ 4 - 4
tests/TestCase/Console/Command/Task/ControllerTaskTest.php

@@ -171,7 +171,7 @@ class ControllerTaskTest extends TestCase {
 		$this->Task->expects($this->at(1))
 			->method('createFile')
 			->with(
-				$filename,
+				$this->_normalizePath($filename),
 				$this->stringContains('class BakeArticlesController')
 			);
 		$result = $this->Task->bake('BakeArticles');
@@ -220,7 +220,7 @@ class ControllerTaskTest extends TestCase {
 		$this->Task->expects($this->at(1))
 			->method('createFile')
 			->with(
-				$path,
+				$this->_normalizePath($path),
 				$this->stringContains('BakeArticlesController extends AppController')
 			)->will($this->returnValue(true));
 
@@ -307,7 +307,7 @@ class ControllerTaskTest extends TestCase {
 		$this->Task->Test->expects($this->atLeastOnce())
 			->method('bake');
 
-		$filename = APP . 'Controller/BakeArticlesController.php';
+		$filename = $this->_normalizePath(APP . 'Controller/BakeArticlesController.php');
 		$this->Task->expects($this->at(1))
 			->method('createFile')
 			->with($filename, $this->logicalAnd(
@@ -339,7 +339,7 @@ class ControllerTaskTest extends TestCase {
 	public function testExecuteWithControllerNameVariations($name) {
 		$this->Task->connection = 'test';
 
-		$filename = APP . 'Controller/BakeArticlesController.php';
+		$filename = $this->_normalizePath(APP . 'Controller/BakeArticlesController.php');
 		$this->Task->expects($this->once())
 			->method('createFile')
 			->with($filename, $this->stringContains('public function index()'));

+ 10 - 10
tests/TestCase/Console/Command/Task/FixtureTaskTest.php

@@ -180,7 +180,7 @@ class FixtureTaskTest extends TestCase {
 	public function testExecuteWithTableOption() {
 		$this->Task->connection = 'test';
 		$this->Task->params = ['table' => 'comments'];
-		$filename = ROOT . '/Test/Fixture/ArticleFixture.php';
+		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/ArticleFixture.php');
 
 		$this->Task->expects($this->at(0))
 			->method('createFile')
@@ -196,7 +196,7 @@ class FixtureTaskTest extends TestCase {
  */
 	public function testExecuteWithNamedModel() {
 		$this->Task->connection = 'test';
-		$filename = ROOT . '/Test/Fixture/ArticleFixture.php';
+		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/ArticleFixture.php');
 
 		$this->Task->expects($this->at(0))
 			->method('createFile')
@@ -216,12 +216,12 @@ class FixtureTaskTest extends TestCase {
 			->method('listAll')
 			->will($this->returnValue(array('articles', 'comments')));
 
-		$filename = ROOT . '/Test/Fixture/ArticleFixture.php';
+		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/ArticleFixture.php');
 		$this->Task->expects($this->at(0))
 			->method('createFile')
 			->with($filename, $this->stringContains('class ArticleFixture'));
 
-		$filename = ROOT . '/Test/Fixture/CommentFixture.php';
+		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/CommentFixture.php');
 		$this->Task->expects($this->at(1))
 			->method('createFile')
 			->with($filename, $this->stringContains('class CommentFixture'));
@@ -241,12 +241,12 @@ class FixtureTaskTest extends TestCase {
 		$this->Task->Model->expects($this->any())->method('listAll')
 			->will($this->returnValue(array('Articles', 'comments')));
 
-		$filename = ROOT . '/Test/Fixture/ArticleFixture.php';
+		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/ArticleFixture.php');
 		$this->Task->expects($this->at(0))
 			->method('createFile')
 			->with($filename, $this->stringContains("'title' => 'Third Article'"));
 
-		$filename = ROOT . '/Test/Fixture/CommentFixture.php';
+		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/CommentFixture.php');
 		$this->Task->expects($this->at(1))
 			->method('createFile')
 			->with($filename, $this->stringContains("'comment' => 'First Comment for First Article'"));
@@ -267,11 +267,11 @@ class FixtureTaskTest extends TestCase {
 		$this->Task->Model->expects($this->any())->method('listAll')
 			->will($this->returnValue(array('Articles', 'comments')));
 
-		$filename = ROOT . '/Test/Fixture/ArticleFixture.php';
+		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/ArticleFixture.php');
 		$this->Task->expects($this->at(0))->method('createFile')
 			->with($filename, $this->stringContains("public \$import = ['model' => 'Articles'"));
 
-		$filename = ROOT . '/Test/Fixture/CommentFixture.php';
+		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/CommentFixture.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');
@@ -291,7 +291,7 @@ class FixtureTaskTest extends TestCase {
 			->method('listAll')
 			->will($this->returnValue(['articles', 'comments']));
 
-		$filename = ROOT . '/Test/Fixture/ArticleFixture.php';
+		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/ArticleFixture.php');
 		$this->Task->expects($this->never())
 			->method('createFile');
 
@@ -357,7 +357,7 @@ class FixtureTaskTest extends TestCase {
  */
 	public function testGenerateFixtureFile() {
 		$this->Task->connection = 'test';
-		$filename = ROOT . '/Test/Fixture/ArticleFixture.php';
+		$filename = $this->_normalizePath(ROOT . '/Test/Fixture/ArticleFixture.php');
 
 		$this->Task->expects($this->at(0))
 			->method('createFile')

+ 2 - 2
tests/TestCase/Console/Command/Task/ModelTaskTest.php

@@ -692,8 +692,7 @@ class ModelTaskTest extends TestCase {
 
 		// fake plugin path
 		Plugin::load('ControllerTest', array('path' => APP . 'Plugin' . DS . 'ControllerTest' . DS));
-		$path = APP . 'Plugin/ControllerTest/Model/Table/BakeArticlesTable.php';
-		$path = str_replace('/', DS, $path);
+		$path = $this->_normalizePath(APP . 'Plugin/ControllerTest/Model/Table/BakeArticlesTable.php');
 		$this->Task->expects($this->once())->method('createFile')
 			->with($path, $this->logicalAnd(
 				$this->stringContains('namespace ControllerTest\\Model\\Table;'),
@@ -716,6 +715,7 @@ class ModelTaskTest extends TestCase {
 		// fake plugin path
 		Plugin::load('ControllerTest', array('path' => APP . 'Plugin' . DS . 'ControllerTest' . DS));
 		$path = APP . 'Plugin' . DS . 'ControllerTest' . DS . 'Model' . DS . 'Entity' . DS . 'BakeArticle.php';
+		$path = $this->_normalizePath($path);
 		$this->Task->expects($this->once())->method('createFile')
 			->with($path, $this->logicalAnd(
 				$this->stringContains('namespace ControllerTest\\Model\\Entity;'),

+ 3 - 3
tests/TestCase/Console/Command/Task/SimpleBakeTaskTest.php

@@ -70,7 +70,7 @@ class SimpleBakeTaskTest extends TestCase {
 		$this->Task->expects($this->once())
 			->method('createFile')
 			->with(
-				APP . 'Model/Behavior/ExampleBehavior.php',
+				$this->_normalizePath(APP . 'Model/Behavior/ExampleBehavior.php'),
 				$this->stringContains('class ExampleBehavior extends Behavior')
 			);
 		$this->Task->Test->expects($this->once())
@@ -91,7 +91,7 @@ class SimpleBakeTaskTest extends TestCase {
 		$this->Task->expects($this->once())
 			->method('createFile')
 			->with(
-				APP . 'Model/Behavior/ExampleBehavior.php',
+				$this->_normalizePath(APP . 'Model/Behavior/ExampleBehavior.php'),
 				$this->stringContains('class ExampleBehavior extends Behavior')
 			);
 
@@ -143,7 +143,7 @@ class SimpleBakeTaskTest extends TestCase {
 		$this->Task->expects($this->once())
 			->method('createFile')
 			->with(
-				$path . 'Model/Behavior/ExampleBehavior.php',
+				$this->_normalizePath($path . 'Model/Behavior/ExampleBehavior.php'),
 				$this->stringContains('class ExampleBehavior extends Behavior')
 			);
 

+ 2 - 2
tests/bootstrap.php

@@ -79,8 +79,8 @@ Configure::write('App', [
 	'jsBaseUrl' => 'js/',
 	'cssBaseUrl' => 'css/',
 	'paths' => [
-		'plugins' => [TEST_APP . 'Plugin/'],
-		'templates' => [APP . 'Template/']
+		'plugins' => [TEST_APP . 'Plugin' . DS],
+		'templates' => [APP . 'Template' . DS]
 	]
 ]);