Skip to content

Commit

Permalink
Fix and add tests for fixtures param.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 31, 2014
1 parent 459eb92 commit e741206
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
17 changes: 1 addition & 16 deletions src/Console/Command/Task/TestTask.php
Expand Up @@ -204,7 +204,7 @@ public function bake($type, $className) {

if (!empty($this->params['fixtures'])) {
$fixtures = array_map('trim', explode(',', $this->params['fixtures']));
$this->_fixtures = $fixtures;
$this->_fixtures = array_filter($fixtures);
} elseif ($this->typeCanDetectFixtures($type) && class_exists($fullClassName)) {
$this->out(__d('cake_console', 'Bake is detecting possible fixtures...'));
$testSubject = $this->buildTestSubject($type, $fullClassName);
Expand Down Expand Up @@ -346,21 +346,6 @@ public function mapType($type) {
return $this->classTypes[$type];
}

/**
* Get the base class and package name for a given type.
*
* @param string $type The type the class having a test
* generated for is in.
* @return array Array of (class, type)
* @throws \Cake\Error\Exception on invalid types.
*/
public function getBaseType($type) {
if (empty($this->baseTypes[$type])) {
throw new Error\Exception('Invalid type name');
}
return $this->baseTypes[$type];
}

/**
* Get methods declared in the class given.
* No parent methods will be returned
Expand Down
20 changes: 20 additions & 0 deletions tests/TestCase/Console/Command/Task/TestTaskTest.php
Expand Up @@ -303,6 +303,26 @@ public function testGetRealClassnamePlugin() {
$this->assertEquals($expected, $result);
}

/**
* Test baking a test for a concrete model with fixtures arg
*
* @return void
*/
public function testBakeFixturesParam() {
$this->Task->expects($this->once())
->method('createFile')
->will($this->returnValue(true));

$this->Task->params['fixtures'] = 'app.post, app.comments , app.user ,';
$result = $this->Task->bake('Table', 'Articles');

$this->assertContains('public $fixtures = [', $result);
$this->assertContains('app.post', $result);
$this->assertContains('app.comments', $result);
$this->assertContains('app.user', $result);
$this->assertNotContains("''", $result);
}

/**
* Test baking a test for a concrete model.
*
Expand Down

0 comments on commit e741206

Please sign in to comment.