Permalink
Browse files

Handle test suite names correctly that are not the name of a test cas…

…e class.
  • Loading branch information...
1 parent 74fd829 commit 13e035a7b4fcad07fa87a55f62adf71be52709cf @sebastianbergmann committed Sep 26, 2006
Showing with 17 additions and 15 deletions.
  1. +17 −15 PHPUnit/Util/Log/XML.php
View
@@ -242,26 +242,28 @@ public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
$testSuite = $this->document->createElement('testsuite');
$testSuite->setAttribute('name', $suite->getName());
- try {
- $class = new ReflectionClass($suite->getName());
- $docComment = $class->getDocComment();
-
- if (preg_match('/@category[\s]+([\.\w]+)/', $docComment, $matches)) {
- $testSuite->setAttribute('category', $matches[1]);
- }
-
- if (preg_match('/@package[\s]+([\.\w]+)/', $docComment, $matches)) {
- $testSuite->setAttribute('package', $matches[1]);
+ if (class_exists($suite->getName(), FALSE)) {
+ try {
+ $class = new ReflectionClass($suite->getName());
+ $docComment = $class->getDocComment();
+
+ if (preg_match('/@category[\s]+([\.\w]+)/', $docComment, $matches)) {
+ $testSuite->setAttribute('category', $matches[1]);
+ }
+
+ if (preg_match('/@package[\s]+([\.\w]+)/', $docComment, $matches)) {
+ $testSuite->setAttribute('package', $matches[1]);
+ }
+
+ if (preg_match('/@subpackage[\s]+([\.\w]+)/', $docComment, $matches)) {
+ $testSuite->setAttribute('subpackage', $matches[1]);
+ }
}
- if (preg_match('/@subpackage[\s]+([\.\w]+)/', $docComment, $matches)) {
- $testSuite->setAttribute('subpackage', $matches[1]);
+ catch (ReflectionException $e) {
}
}
- catch (ReflectionException $e) {
- }
-
if ($this->testSuiteLevel > 0) {
$this->testSuites[$this->testSuiteLevel]->appendChild($testSuite);
} else {

0 comments on commit 13e035a

Please sign in to comment.