Skip to content

Commit

Permalink
test to fix for DS issues on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Apr 3, 2014
1 parent 82ffacc commit 5525c02
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 73 deletions.
2 changes: 1 addition & 1 deletion src/Console/Command/Task/FixtureTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FixtureTask extends BakeTask {
*/
public function __construct(ConsoleOutput $stdout = null, ConsoleOutput $stderr = null, ConsoleInput $stdin = null) {
parent::__construct($stdout, $stderr, $stdin);
$this->path = ROOT . '/Test/Fixture/';
$this->path = ROOT . DS . 'Test' . DS . 'Fixture' . DS;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Console/Command/Task/ModelTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ModelTask extends BakeTask {
* @return void
*/
public function initialize() {
$this->path = APP . '/Model/';
$this->path = APP . 'Model' . DS;
}

/**
Expand Down Expand Up @@ -538,7 +538,7 @@ public function bakeEntity($model, $data = []) {
$out = $this->Template->generate('classes', 'entity');

$path = $this->getPath();
$filename = $path . 'Entity/' . $name . '.php';
$filename = $path . 'Entity' . DS . $name . '.php';
$this->out("\n" . __d('cake_console', 'Baking entity class for %s...', $name), 1, Shell::QUIET);
$this->createFile($filename, $out);
return $out;
Expand Down Expand Up @@ -581,7 +581,7 @@ public function bakeTable($model, $data = []) {
$out = $this->Template->generate('classes', 'table');

$path = $this->getPath();
$filename = $path . 'Table/' . $name . 'Table.php';
$filename = $path . 'Table' . DS . $name . 'Table.php';
$this->out("\n" . __d('cake_console', 'Baking table class for %s...', $name), 1, Shell::QUIET);
$this->createFile($filename, $out);
TableRegistry::clear();
Expand Down
6 changes: 3 additions & 3 deletions src/Console/Command/Task/PluginTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PluginTask extends Shell {
*/
public function initialize() {
$this->path = current(App::path('Plugin'));
$this->bootstrap = APP . 'Config/bootstrap.php';
$this->bootstrap = APP . 'Config' . DS . 'bootstrap.php';
}

/**
Expand Down Expand Up @@ -156,7 +156,7 @@ public function bake($plugin) {
$out .= "use App\\Controller\\AppController;\n\n";
$out .= "class {$plugin}AppController extends AppController {\n\n";
$out .= "}\n";
$this->createFile($this->path . $plugin . DS . 'Controller/' . $controllerFileName, $out);
$this->createFile($this->path . $plugin . DS . 'Controller' . DS . $controllerFileName, $out);

$this->_modifyBootstrap($plugin);
$this->_generatePhpunitXml($plugin, $this->path);
Expand Down Expand Up @@ -218,7 +218,7 @@ protected function _generateTestBootstrap($plugin, $path) {
]);
$this->out( __d('cake_console', 'Generating Test/bootstrap.php file...'));
$out = $this->Template->generate('test', 'bootstrap');
$file = $path . $plugin . '/Test/bootstrap.php';
$file = $path . $plugin . DS . 'Test' . DS . 'bootstrap.php';
$this->createFile($file, $out);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Console/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ protected function _checkUnitTest() {
public function shortPath($file) {
$shortPath = str_replace(ROOT, null, $file);
$shortPath = str_replace('..' . DS, '', $shortPath);
return str_replace(DS . DS, DS, $shortPath);
$shortPath = str_replace(DS, '/', $shortPath);
return str_replace('//', DS, $shortPath);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Console/Command/Task/ControllerTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function testBakeActions() {
public function testBakePrefixed() {
$this->Task->params['prefix'] = 'Admin';

$filename = '/my/path/Admin/BakeArticlesController.php';
$filename = str_replace('/', DS, '/my/path/Admin/BakeArticlesController.php');
$this->Task->expects($this->at(1))
->method('createFile')
->with($filename, $this->anything());
Expand Down
5 changes: 3 additions & 2 deletions tests/TestCase/Console/Command/Task/FixtureTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testConstruct() {
$in = $this->getMock('Cake\Console\ConsoleInput', array(), array(), '', false);

$Task = new FixtureTask($out, $out, $in);
$this->assertEquals(ROOT . '/Test/Fixture/', $Task->path);
$this->assertEquals(ROOT . DS . 'Test' . DS . 'Fixture' . DS, $Task->path);
}

/**
Expand Down Expand Up @@ -396,9 +396,10 @@ public function testGenerateFixtureFile() {
*/
public function testGeneratePluginFixtureFile() {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->path = str_replace('/', DS, '/my/path/');
$this->Task->plugin = 'TestPlugin';
$filename = TEST_APP . 'Plugin/TestPlugin/Test/Fixture/ArticleFixture.php';
$filename = str_replace('/', DS, $filename);

Plugin::load('TestPlugin');
$this->Task->expects($this->at(0))->method('createFile')
Expand Down
55 changes: 28 additions & 27 deletions tests/TestCase/Console/Command/Task/ModelTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ public function testBakeTableValidation() {
}

/**
* test baking
* test baking
*
* @return void
*/
Expand Down Expand Up @@ -687,8 +687,9 @@ public function testBakeTableWithPlugin() {
$this->Task->plugin = 'ControllerTest';

// fake plugin path
Plugin::load('ControllerTest', array('path' => APP . 'Plugin/ControllerTest/'));
Plugin::load('ControllerTest', array('path' => APP . 'Plugin' . DS . 'ControllerTest' . DS));
$path = APP . 'Plugin/ControllerTest/Model/Table/BakeArticlesTable.php';
$path = str_replace('/', DS, $path);
$this->Task->expects($this->once())->method('createFile')
->with($path, $this->logicalAnd(
$this->stringContains('namespace ControllerTest\\Model\\Table;'),
Expand All @@ -709,8 +710,8 @@ public function testBakeEntityWithPlugin() {
$this->Task->plugin = 'ControllerTest';

// fake plugin path
Plugin::load('ControllerTest', array('path' => APP . 'Plugin/ControllerTest/'));
$path = APP . 'Plugin/ControllerTest/Model/Entity/BakeArticle.php';
Plugin::load('ControllerTest', array('path' => APP . 'Plugin' . DS . 'ControllerTest' . DS));
$path = APP . 'Plugin' . DS . 'ControllerTest' . DS . 'Model' . DS . 'Entity' . DS . 'BakeArticle.php';
$this->Task->expects($this->once())->method('createFile')
->with($path, $this->logicalAnd(
$this->stringContains('namespace ControllerTest\\Model\\Entity;'),
Expand Down Expand Up @@ -746,15 +747,15 @@ public function testExecuteNoArgs() {
*/
public function testExecuteWithNamedModel() {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->path = str_replace('/', DS, '/my/path/');
$this->Task->args = ['BakeArticles'];

$tableFile = '/my/path/Table/BakeArticlesTable.php';
$tableFile = str_replace('/', DS, '/my/path/Table/BakeArticlesTable.php');
$this->Task->expects($this->at(0))
->method('createFile')
->with($tableFile, $this->stringContains('class BakeArticlesTable extends Table'));

$entityFile = '/my/path/Entity/BakeArticle.php';
$entityFile = str_replace('/', DS, '/my/path/Entity/BakeArticle.php');
$this->Task->expects($this->at(1))
->method('createFile')
->with($entityFile, $this->stringContains('class BakeArticle extends Entity'));
Expand All @@ -781,10 +782,10 @@ public static function nameVariations() {
*/
public function testExecuteWithNamedModelVariations($name) {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->path = str_replace('/', DS, '/my/path/');

$this->Task->args = array($name);
$filename = '/my/path/Table/BakeArticlesTable.php';
$filename = str_replace('/', DS, '/my/path/Table/BakeArticlesTable.php');

$this->Task->expects($this->at(0))
->method('createFile')
Expand All @@ -804,60 +805,60 @@ public function testExecuteIntoAll() {
}

$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->path = str_replace('/', DS, '/my/path/');
$this->Task->args = ['all'];

$this->Task->Fixture->expects($this->exactly($count))
->method('bake');
$this->Task->Test->expects($this->exactly($count))
->method('bake');

$filename = '/my/path/Table/BakeArticlesTable.php';
$filename = str_replace('/', DS, '/my/path/Table/BakeArticlesTable.php');
$this->Task->expects($this->at(0))
->method('createFile')
->with($filename, $this->stringContains('class BakeArticlesTable extends'));

$filename = '/my/path/Entity/BakeArticle.php';
$filename = str_replace('/', DS, '/my/path/Entity/BakeArticle.php');
$this->Task->expects($this->at(1))
->method('createFile')
->with($filename, $this->stringContains('class BakeArticle extends'));

$filename = '/my/path/Table/BakeArticlesBakeTagsTable.php';
$filename = str_replace('/', DS, '/my/path/Table/BakeArticlesBakeTagsTable.php');
$this->Task->expects($this->at(2))
->method('createFile')
->with($filename, $this->stringContains('class BakeArticlesBakeTagsTable extends'));

$filename = '/my/path/Entity/BakeArticlesBakeTag.php';
$filename = str_replace('/', DS, '/my/path/Entity/BakeArticlesBakeTag.php');
$this->Task->expects($this->at(3))
->method('createFile')
->with($filename, $this->stringContains('class BakeArticlesBakeTag extends'));

$filename = '/my/path/Table/BakeCommentsTable.php';
$filename = str_replace('/', DS, '/my/path/Table/BakeCommentsTable.php');
$this->Task->expects($this->at(4))
->method('createFile')
->with($filename, $this->stringContains('class BakeCommentsTable extends'));

$filename = '/my/path/Entity/BakeComment.php';
$filename = str_replace('/', DS, '/my/path/Entity/BakeComment.php');
$this->Task->expects($this->at(5))
->method('createFile')
->with($filename, $this->stringContains('class BakeComment extends'));

$filename = '/my/path/Table/BakeTagsTable.php';
$filename = str_replace('/', DS, '/my/path/Table/BakeTagsTable.php');
$this->Task->expects($this->at(6))
->method('createFile')
->with($filename, $this->stringContains('class BakeTagsTable extends'));

$filename = '/my/path/Entity/BakeTag.php';
$filename = str_replace('/', DS, '/my/path/Entity/BakeTag.php');
$this->Task->expects($this->at(7))
->method('createFile')
->with($filename, $this->stringContains('class BakeTag extends'));

$filename = '/my/path/Table/CategoryThreadsTable.php';
$filename = str_replace('/', DS, '/my/path/Table/CategoryThreadsTable.php');
$this->Task->expects($this->at(8))
->method('createFile')
->with($filename, $this->stringContains('class CategoryThreadsTable extends'));

$filename = '/my/path/Entity/CategoryThread.php';
$filename = str_replace('/', DS, '/my/path/Entity/CategoryThread.php');
$this->Task->expects($this->at(9))
->method('createFile')
->with($filename, $this->stringContains('class CategoryThread extends'));
Expand All @@ -877,7 +878,7 @@ public function testSkipTablesAndAll() {
}

$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->path = str_replace('/', DS, '/my/path/');
$this->Task->args = ['all'];
$this->Task->skipTables = ['bake_tags'];

Expand All @@ -886,32 +887,32 @@ public function testSkipTablesAndAll() {
$this->Task->Test->expects($this->exactly(7))
->method('bake');

$filename = '/my/path/Entity/BakeArticle.php';
$filename = str_replace('/', DS, '/my/path/Entity/BakeArticle.php');
$this->Task->expects($this->at(1))
->method('createFile')
->with($filename);

$filename = '/my/path/Entity/BakeArticlesBakeTag.php';
$filename = str_replace('/', DS, '/my/path/Entity/BakeArticlesBakeTag.php');
$this->Task->expects($this->at(3))
->method('createFile')
->with($filename);

$filename = '/my/path/Entity/BakeComment.php';
$filename = str_replace('/', DS, '/my/path/Entity/BakeComment.php');
$this->Task->expects($this->at(5))
->method('createFile')
->with($filename);

$filename = '/my/path/Entity/CategoryThread.php';
$filename = str_replace('/', DS, '/my/path/Entity/CategoryThread.php');
$this->Task->expects($this->at(7))
->method('createFile')
->with($filename);

$filename = '/my/path/Entity/CounterCacheUser.php';
$filename = str_replace('/', DS, '/my/path/Entity/CounterCacheUser.php');
$this->Task->expects($this->at(9))
->method('createFile')
->with($filename);

$filename = '/my/path/Entity/NumberTree.php';
$filename = str_replace('/', DS, '/my/path/Entity/NumberTree.php');
$this->Task->expects($this->at(11))
->method('createFile')
->with($filename);
Expand Down
20 changes: 10 additions & 10 deletions tests/TestCase/Console/Command/Task/PluginTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function setUp() {
);
$this->Task->Template = new TemplateTask($this->out, $this->out, $this->in);

$this->Task->path = TMP . 'tests/';
$this->Task->bootstrap = TMP . 'tests/bootstrap.php';
$this->Task->path = TMP . 'tests' . DS;
$this->Task->bootstrap = TMP . 'tests' . DS . 'bootstrap.php';

if (!is_dir($this->Task->path)) {
mkdir($this->Task->path);
Expand Down Expand Up @@ -75,7 +75,7 @@ public function testBakeFoldersAndFiles() {

$path = $this->Task->path . 'BakeTestPlugin';

$file = $path . '/Controller/BakeTestPluginAppController.php';
$file = $path . DS . 'Controller' . DS . 'BakeTestPluginAppController.php';
$this->Task->expects($this->at(1))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

Expand Down Expand Up @@ -123,16 +123,16 @@ public function testExecuteWithNoArgs() {
->will($this->returnValue('y'));

$path = $this->Task->path . 'TestPlugin';
$file = $path . '/Controller/TestPluginAppController.php';
$file = $path . DS . 'Controller' . DS . 'TestPluginAppController.php';

$this->Task->expects($this->at(2))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

$file = $path . '/phpunit.xml';
$file = $path . DS . 'phpunit.xml';
$this->Task->expects($this->at(3))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

$file = $path . '/Test/bootstrap.php';
$file = $path . DS . 'Test' . DS . 'bootstrap.php';
$this->Task->expects($this->at(4))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

Expand All @@ -153,15 +153,15 @@ public function testExecuteWithOneArg() {
->will($this->returnValue('y'));

$path = $this->Task->path . 'BakeTestPlugin';
$file = $path . DS . 'Controller/BakeTestPluginAppController.php';
$file = $path . DS . 'Controller' . DS . 'BakeTestPluginAppController.php';
$this->Task->expects($this->at(1))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

$file = $path . '/phpunit.xml';
$file = $path . DS . 'phpunit.xml';
$this->Task->expects($this->at(2))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

$file = $path . '/Test/bootstrap.php';
$file = $path . DS. 'Test' . DS . 'bootstrap.php';
$this->Task->expects($this->at(3))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

Expand All @@ -188,7 +188,7 @@ public function testFindPathNonExistant() {
array('in', 'out', 'err', 'createFile', '_stop'),
array($this->out, $this->out, $this->in)
);
$this->Task->path = TMP . 'tests/';
$this->Task->path = TMP . 'tests' . DS;

// Make sure the added path is filtered out.
$this->Task->expects($this->exactly($last))
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Console/Command/Task/TemplateTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public function tearDown() {
* @return void
*/
public function testFindingInstalledThemesForBake() {
$consoleLibs = CAKE . 'Console/';
$consoleLibs = CAKE . 'Console' . DS;
$this->Task->initialize();
$this->assertEquals($this->Task->templatePaths['default'], $consoleLibs . 'Templates/default/');
$this->assertPathEquals($this->Task->templatePaths['default'], $consoleLibs . 'Templates/default/');
}

/**
Expand Down
Loading

0 comments on commit 5525c02

Please sign in to comment.