Skip to content

Commit

Permalink
Fix tests for test case filename.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 31, 2014
1 parent a4ee7b0 commit 1f1f647
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/Console/Command/Task/TestTask.php
Expand Up @@ -551,7 +551,7 @@ public function testCaseFileName($type, $className) {
$path .= $this->classTypes[$type] . DS;
}
list($namespace, $className) = namespaceSplit($this->getRealClassName($type, $className));
return str_replace('/', DS, $path) . Inflector::camelize($className) . 'Test.php';
return str_replace(['/', '\\'], DS, $path) . Inflector::camelize($className) . 'Test.php';
}

/**
Expand Down
54 changes: 18 additions & 36 deletions tests/TestCase/Console/Command/Task/TestTaskTest.php
Expand Up @@ -395,6 +395,15 @@ public function testBakeControllerTest() {
$this->assertContains("'app.post'", $result);
}

/**
* test baking controller test files
*
* @return void
*/
public function testBakePrefixControllerTest() {
$this->markTestIncomplete();
}

/**
* test baking component test files,
*
Expand Down Expand Up @@ -543,57 +552,31 @@ public function testMockClassGeneration() {
* @return void
*/
public function testBakeWithPlugin() {
$this->markTestIncomplete('Model tests need reworking.');
$this->Task->plugin = 'TestTest';
$this->Task->plugin = 'TestPlugin';

//fake plugin path
Plugin::load('TestTest', array('path' => APP . 'Plugin/TestTest/'));
$path = APP . 'Plugin/TestTest/Test/TestCase/View/Helper/FormHelperTest.php';
Plugin::load('TestPlugin');
$path = TEST_APP . 'Plugin/TestPlugin/Test/TestCase/View/Helper/FormHelperTest.php';
$this->Task->expects($this->once())->method('createFile')
->with($path, $this->anything());

$this->Task->bake('Helper', 'Form');
Plugin::unload();
}

/**
* test interactive with plugins lists from the plugin
* Provider for test case file names.
*
* @return void
* @return array
*/
public function testInteractiveWithPlugin() {
$this->markTestIncomplete();
$testApp = TEST_APP . 'Plugin/';
Plugin::load('TestPlugin');

$this->Task->plugin = 'TestPlugin';
$path = $testApp . 'TestPlugin/Test/TestCase/View/Helper/OtherHelperTest.php';
$this->Task->expects($this->any())
->method('in')
->will($this->onConsecutiveCalls(
5, //helper
1 //OtherHelper
));

$this->Task->expects($this->once())
->method('createFile')
->with($path, $this->anything());

$this->Task->stdout->expects($this->at(21))
->method('write')
->with('1. OtherHelperHelper');

$this->Task->execute();
}

public static function caseFileNameProvider() {
return array(
array('Model', 'Post', 'TestCase/Model/PostTest.php'),
array('Table', 'Posts', 'TestCase/Model/Table/PostsTableTest.php'),
array('Entity', 'Article', 'TestCase/Model/Entity/ArticleTest.php'),
array('Helper', 'Form', 'TestCase/View/Helper/FormHelperTest.php'),
array('Controller', 'Posts', 'TestCase/Controller/PostsControllerTest.php'),
array('Behavior', 'Tree', 'TestCase/Model/Behavior/TreeBehaviorTest.php'),
array('Component', 'Auth', 'TestCase/Controller/Component/AuthComponentTest.php'),
array('model', 'Post', 'TestCase/Model/PostTest.php'),
array('entity', 'Article', 'TestCase/Model/Entity/ArticleTest.php'),
array('table', 'Posts', 'TestCase/Model/Table/PostsTableTest.php'),
array('helper', 'Form', 'TestCase/View/Helper/FormHelperTest.php'),
array('controller', 'Posts', 'TestCase/Controller/PostsControllerTest.php'),
array('behavior', 'Tree', 'TestCase/Model/Behavior/TreeBehaviorTest.php'),
Expand All @@ -608,7 +591,6 @@ public static function caseFileNameProvider() {
* @return void
*/
public function testTestCaseFileName($type, $class, $expected) {
$this->markTestIncomplete();
$this->Task->path = DS . 'my/path/tests/';

$result = $this->Task->testCaseFileName($type, $class);
Expand Down

0 comments on commit 1f1f647

Please sign in to comment.