Permalink
Browse files

DocBlox plugin updated to handle annotations

  • Loading branch information...
1 parent b8a7729 commit bb607ec01cdc725bd3570246dbbee830f768a139 @DavertMik DavertMik committed Feb 21, 2012
Showing with 21 additions and 4 deletions.
  1. +7 −2 plugins/DocBlox/Codeception/Listener.php
  2. +2 −2 src/Codeception/Codecept.php
  3. +12 −0 src/Codeception/TestCase/Cest.php
@@ -135,7 +135,7 @@ protected function getScenarioText($test, $class, $method)
}, $args);
- if (in_array($step->getAction(), array('executeTestedMethodOn'))) {
+ if (in_array($step->getAction(), array('executeTestedMethodOn', 'executeMethod'))) {
$stub = array_shift($args);
}
@@ -158,14 +158,19 @@ protected function getScenarioText($test, $class, $method)
continue;
}
+ if (in_array($step->getAction(), array('executeMethod'))) {
+ $text .= "I execute <span style=\"background: #ddd;\">$stub->$method($args)</span>\n";
+ continue;
+ }
+
if (in_array($step->getAction(), array('executeTestedMethodOn'))) {
$text .= "If I execute <span style=\"background: #ddd;\">$stub->$method($args)</span>\n";
continue;
}
if ($step->getName() == 'Comment') {
- $text .= "\nI ".$this->getStepAction($step)." $args\n";
+ $text .= "\n".ucfirst($step)." $args\n";
continue;
}
@@ -7,10 +7,10 @@
class Codecept
{
- const VERSION = "1.0.3";
+ const VERSION = "1.0.4";
/**
- * @var \Codeception\Runner
+ * @var \Codeception\PHPUnit\Runner
*/
protected $runner;
/**
@@ -63,6 +63,18 @@ public function getCoveredMethod()
if (!$this->getCoveredClass()) return null;
$r = new \ReflectionClass($this->getCoveredClass());
if ($r->hasMethod($this->testMethod)) return $this->testMethod;
+
+ // search by annotations
+ $rm = new \ReflectionMethod($this->testClass, $this->testMethod);
+ $doc = $rm->getDocComment();
+
+
+ if (preg_match('~@(covers|doc) (.*?)\*~si', $doc, $matches)) {
+ $method = trim($matches[2]);
+ if ($r->hasMethod($method)) return $method;
+ return null;
+ }
+
return null;
}

0 comments on commit bb607ec

Please sign in to comment.