【发布时间】:2019-06-18 16:52:21
【问题描述】:
每当我尝试包含文件时,PHPUnit 都会给我一条错误消息。例如下面的代码给了我错误:
<?php
include_once "PHPUnit/Autoload.php";
require_once "controller/ProductController.php";
class SecurityTests extends PHPUnit_Framework_TestCase
{
public function testSmth() {
$this->assertTrue(1==1);
}
}
?>
但如果我删除第四行 (require_once "controller/ProductController.php";),它运行良好。
我得到的错误是:
Warning: require_once(PHPUnit/Framework/Error.php): failed to open stream: No such file or directory in E:\wamp\bin\php\php5.4.3\pear\PHPUnit\Util\ErrorHandler.php on line 48
编辑: 我在 php.ini 文件中的 include_path 是:
include_path = ".;E:\wamp\bin\php\php5.4.3\pear\;E:\wamp\www\renting\"
有什么奇怪的:
<?php
echo get_include_path(); **// Will echo .;E:\wamp\bin\php\php5.4.3\pear\;E:\wamp\www\renting\**
require_once 'PHPUnit/Autoload.php';
require_once 'controller/AccountController.php';
echo get_include_path(); **// Will echo E:/wamp/www/renting/**
还有:
<?php
require_once 'controller/AccountController.php';
echo get_include_path(); **// Will echo E:/wamp/www/renting/**
require_once 'PHPUnit/Autoload.php';
echo get_include_path(); **// Will not even echo.**
这对我来说很奇怪。
有什么想法吗?
【问题讨论】:
-
你的目录结构是什么样的,你从哪里运行测试?
-
我正在使用 PhpStorm 运行测试,但是如果我使用命令行从测试文件夹运行它,我会得到相同的结果。
-
如果我删除包含的文件,我不会收到任何错误,测试运行正常。
标签: phpunit