Browse Source

Fix and add tests for fixtures param.

mark_story 12 years ago
parent
commit
e7412062a7

+ 1 - 16
src/Console/Command/Task/TestTask.php

@@ -204,7 +204,7 @@ class TestTask extends BakeTask {
 
 		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);
@@ -347,21 +347,6 @@ class TestTask extends BakeTask {
 	}
 
 /**
- * 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
  *

+ 20 - 0
tests/TestCase/Console/Command/Task/TestTaskTest.php

@@ -304,6 +304,26 @@ class TestTaskTest extends TestCase {
 	}
 
 /**
+ * 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.
  *
  * @return void