Browse Source

Improve test template so it always includes one method.

Having at least one test method in a generated file will prevent errors
from PHPUnit about empty test classes.

Refs #4892
Mark Story 11 years ago
parent
commit
974ca73283

+ 13 - 2
src/Template/Bake/default/classes/test.ctp

@@ -77,13 +77,24 @@ class <?= $className ?>Test extends TestCase {
 <?php endif; ?>
 <?php foreach ($methods as $method): ?>
 /**
- * test<?= Inflector::camelize($method) ?> method
+ * Test <?= $method ?> method
  *
  * @return void
  */
 	public function test<?= Inflector::camelize($method) ?>() {
-		$this->markTestIncomplete('test<?= Inflector::camelize($method) ?> not implemented.');
+		$this->markTestIncomplete('Not implemented yet.');
 	}
 
 <?php endforeach; ?>
+<?php if (empty($methods)): ?>
+/**
+ * Test initial setup
+ *
+ * @return void
+ */
+	public function testInitialization() {
+		$this->markTestIncomplete('Not implemented yet.');
+	}
+
+<?php endif; ?>
 }

+ 1 - 1
tests/TestCase/Shell/Task/TestTaskTest.php

@@ -444,7 +444,7 @@ class TestTaskTest extends TestCase {
 		$this->assertContains("\$this->Apple = new AppleComponent(\$registry)", $result);
 
 		$this->assertContains('function testStartup()', $result);
-		$this->assertContains('$this->markTestIncomplete(\'testStartup not implemented.\')', $result);
+		$this->assertContains('$this->markTestIncomplete(\'Not implemented yet.\')', $result);
 
 		$this->assertContains('function tearDown()', $result);
 		$this->assertContains('unset($this->Apple)', $result);