Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #48.

  • Loading branch information...
commit 14eacbd19aebb4b4ed08315b9e3f2a6b054b60ea 1 parent 2c3843d
Sebastian Bergmann authored
Showing with 24 additions and 11 deletions.
  1. +24 −11 PHPUnit/Util/Skeleton.php
35 PHPUnit/Util/Skeleton.php
View
@@ -97,37 +97,50 @@ class PHPUnit_Util_Skeleton
*/
public function __construct($className, $classSourceFile = '')
{
- if (file_exists($className . '.php')) {
+ $this->className = $className;
+ $this->testSourceFile = $className . 'Test.php';
+
+ if (empty($classSourceFile) && is_file($className . '.php')) {
$this->classSourceFile = $className . '.php';
- $this->testSourceFile = $className . 'Test.php';
}
- else if (file_exists(str_replace('_', '/', $className) . '.php')) {
+ else if (empty($classSourceFile) &&
+ is_file(str_replace('_', '/', $className) . '.php')) {
$this->classSourceFile = str_replace('_', '/', $className) . '.php';
$this->testSourceFile = str_replace('_', '/', $className) . 'Test.php';
}
- else {
+ else if (empty($classSourceFile)) {
+ throw new RuntimeException(
+ sprintf(
+ 'Neither "%s.php" nor "%s.php" could be opened.',
+ $className,
+ str_replace('_', '/', $className)
+ )
+ );
+ }
+
+ else if (!is_file($classSourceFile)) {
throw new RuntimeException(
sprintf(
- 'Could not open %s.',
+ '"%s" could not be opened.',
$classSourceFile
)
);
+ } else {
+ $this->classSourceFile = $classSourceFile;
}
- @include_once $this->classSourceFile;
+ include_once $this->classSourceFile;
- if (class_exists($className, FALSE)) {
- $this->className = $className;
- } else {
+ if (!class_exists($className)) {
throw new RuntimeException(
sprintf(
- 'Could not find class "%s" in %s.',
+ 'Could not find class "%s" in "%s".',
$className,
- $this->classSourceFile
+ realpath($this->classSourceFile)
)
);
}
Please sign in to comment.
Something went wrong with that request. Please try again.