Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #3.

  • Loading branch information...
commit d860b14ebfba7e0b6f6435e7fa575653380fedd0 1 parent 14eacbd
Sebastian Bergmann authored
Showing with 21 additions and 8 deletions.
  1. +20 −5 PHPUnit/Util/Skeleton.php
  2. +1 −3 PHPUnit/Util/Skeleton/TestClass.php
25 PHPUnit/Util/Skeleton.php
View
@@ -100,7 +100,11 @@ public function __construct($className, $classSourceFile = '')
$this->className = $className;
$this->testSourceFile = $className . 'Test.php';
- if (empty($classSourceFile) && is_file($className . '.php')) {
+ if (class_exists($className)) {
+ $this->classSourceFile = '<internal>';
+ }
+
+ else if (empty($classSourceFile) && is_file($className . '.php')) {
$this->classSourceFile = $className . '.php';
}
@@ -132,7 +136,9 @@ public function __construct($className, $classSourceFile = '')
$this->classSourceFile = $classSourceFile;
}
- include_once $this->classSourceFile;
+ if ($this->classSourceFile != '<internal>') {
+ include_once $this->classSourceFile;
+ }
if (!class_exists($className)) {
throw new RuntimeException(
@@ -162,7 +168,6 @@ public function generate($verbose = FALSE)
foreach ($class->getMethods() as $method) {
if (!$method->isConstructor() &&
!$method->isAbstract() &&
- $method->isUserDefined() &&
$method->isPublic() &&
$method->getDeclaringClass()->getName() == $this->className) {
$testTagFound = FALSE;
@@ -278,17 +283,27 @@ public function generate($verbose = FALSE)
)
);
+ if ($this->classSourceFile != '<internal>') {
+ $requireClassFile = sprintf(
+ "\n\nrequire_once '%s';",
+
+ $this->classSourceFile
+ );
+ } else {
+ $requireClassFile = '';
+ }
+
$classTemplate->setVar(
array(
'className',
- 'classFile',
+ 'requireClassFile',
'methods',
'date',
'time'
),
array(
$this->className,
- $this->classSourceFile,
+ $requireClassFile,
!empty($methods) ? $methods : $incompleteMethods,
date('Y-m-d'),
date('H:i:s')
4 PHPUnit/Util/Skeleton/TestClass.php
View
@@ -5,9 +5,7 @@
}
require_once "PHPUnit/Framework/TestCase.php";
-require_once "PHPUnit/Framework/TestSuite.php";
-
-require_once "{classFile}";
+require_once "PHPUnit/Framework/TestSuite.php";{requireClassFile}
/**
* Test class for {className}.
Please sign in to comment.
Something went wrong with that request. Please try again.