Permalink
Browse files

Do not depend on docblock extension.

  • Loading branch information...
1 parent 1a21c9b commit 673813e481c04adf1fc3426147dab9b69de7084a @sebastianbergmann committed Sep 26, 2006
Showing with 65 additions and 80 deletions.
  1. +65 −77 PHPUnit/Util/Skeleton.php
  2. +0 −3 package.xml
View
@@ -152,95 +152,83 @@ public function generate($verbose = FALSE)
$method->isUserDefined() &&
$method->isPublic() &&
$method->getDeclaringClass()->getName() == $this->className) {
- $testTagFound = FALSE;
+ $testTagFound = FALSE;
+
+ if (preg_match_all('/@test(.*)$/Um', $method->getDocComment(), $annotations)) {
+ foreach ($annotations[1] as $annotation) {
+ if (preg_match('/\((.*)\) (.*) (.*)/', $annotation, $matches)) {
+ switch ($matches[2]) {
+ case '==': {
+ $assertion = 'Equals';
+ }
+ break;
- if (extension_loaded('docblock')) {
- $tokens = docblock_tokenize($method->getDocComment());
- $inTestTag = FALSE;
+ case '!=': {
+ $assertion = 'NotEquals';
+ }
+ break;
- foreach ($tokens as $token) {
- if ($inTestTag == FALSE &&
- $token[0] == DOCBLOCK_TAG &&
- $token[1] == '@test') {
- $inTestTag = TRUE;
- }
+ case '===': {
+ $assertion = 'Same';
+ }
+ break;
- else if ($inTestTag == TRUE && $token[0] == DOCBLOCK_TEXT) {
- if (preg_match('/\((.*)\) (.*) (.*)/', $token[1], $matches)) {
- switch ($matches[2]) {
- case '==': {
- $assertion = 'Equals';
- }
- break;
-
- case '!=': {
- $assertion = 'NotEquals';
- }
- break;
-
- case '===': {
- $assertion = 'Same';
- }
- break;
-
- case '!==': {
- $assertion = 'NotSame';
- }
- break;
-
- default: {
- throw new RuntimeException;
- }
+ case '!==': {
+ $assertion = 'NotSame';
}
+ break;
- $methodTemplate = new PHPUnit_Util_Template(
- sprintf(
- '%s%sSkeleton%sTestMethod.php',
+ default: {
+ throw new RuntimeException;
+ }
+ }
- dirname(__FILE__),
- DIRECTORY_SEPARATOR,
- DIRECTORY_SEPARATOR
- )
- );
+ $methodTemplate = new PHPUnit_Util_Template(
+ sprintf(
+ '%s%sSkeleton%sTestMethod.php',
- $origMethodName = $method->getName();
- $methodName = ucfirst($origMethodName);
+ dirname(__FILE__),
+ DIRECTORY_SEPARATOR,
+ DIRECTORY_SEPARATOR
+ )
+ );
- if (isset($this->methodNameCounter[$methodName])) {
- $this->methodNameCounter[$methodName]++;
- } else {
- $this->methodNameCounter[$methodName] = 1;
- }
+ $origMethodName = $method->getName();
+ $methodName = ucfirst($origMethodName);
- if ($this->methodNameCounter[$methodName] > 1) {
- $methodName .= $this->methodNameCounter[$methodName];
- }
+ if (isset($this->methodNameCounter[$methodName])) {
+ $this->methodNameCounter[$methodName]++;
+ } else {
+ $this->methodNameCounter[$methodName] = 1;
+ }
- $methodTemplate->setVar(
- array(
- 'annotation',
- 'arguments',
- 'assertion',
- 'class',
- 'expected',
- 'origMethodName',
- 'methodName'
- ),
- array(
- trim($token[1]),
- $matches[1],
- $assertion,
- $this->className,
- $matches[3],
- $origMethodName,
- $methodName
- )
- );
-
- $methods .= $methodTemplate->render();
+ if ($this->methodNameCounter[$methodName] > 1) {
+ $methodName .= $this->methodNameCounter[$methodName];
}
- $inTestTag = FALSE;
+ $methodTemplate->setVar(
+ array(
+ 'annotation',
+ 'arguments',
+ 'assertion',
+ 'class',
+ 'expected',
+ 'origMethodName',
+ 'methodName'
+ ),
+ array(
+ trim($token[1]),
+ $matches[1],
+ $assertion,
+ $this->className,
+ $matches[3],
+ $origMethodName,
+ $methodName
+ )
+ );
+
+ $methods .= $methodTemplate->render();
+
$testTagFound = TRUE;
}
}
View
@@ -776,9 +776,6 @@
<channel>pear.php.net</channel>
</package>
<extension>
- <name>docblock</name>
- </extension>
- <extension>
<name>xdebug</name>
<min>2.0.0beta6</min>
</extension>

0 comments on commit 673813e

Please sign in to comment.