phpunit.xml 似乎不起作用
我试图让这个测试
require_once 'PHPUnit/Framework.php';
require_once('../config/config.php');
require_once('../classes/division.class.php');
class DivisionTest extends PHPUnit_Framework_TestCase
{
public function Divisiontest()
{
$division = new division();
try{
$division->createDivisionDetails();
}catch (CustomException $e) {
return;
}
$this->fail('An expected exception has not been raised.');
}
}
在这个命令
phpunit --configuration=phpunit.xml division.test.php
上运行,但不断收到错误消息
PHP Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 13
Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 13
PHP Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 26
Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 26
PHP Warning: require_once(/people_scope/config/standard.inc.php): failed to open stream: No such file or directory in /home/workspace/people_scope/config/config.php on line 46
Warning: require_once(/people_scope/config/standard.inc.php): failed to open stream: No such file or directory in /home/workspace/people_scope/config/config.php on line 46
PHP Fatal error: require_once(): Failed opening required '/people_scope/config/standard.inc.php' (include_path='/usr/bin:.:/usr/share/php:/usr/share/pear:/people_scope/assets/PEAR/:/people_scope/classes/base/') in /home/workspace/people_scope/config/config.php on line 46
Fatal error: require_once(): Failed opening required '/people_scope/config/standard.inc.php' (include_path='/usr/bin:.:/usr/share/php:/usr/share/pear:/people_scope/assets/PEAR/:/people_scope/classes/base/') in /home/workspace/people_scope/config/config.php on line 46
我正在使用 phpunit.xml 尝试设置 $_SERVER['HTTP_HOST' ] 但似乎它根本不起作用
<?xml version="1.0" encoding="utf-8" ?>
<phpunit>
<php>
<server name="HTTP_HOST" value="DEV"/>
</php>
</phpunit>
我读过的所有内容似乎都说这应该起作用
I have bee trying to get this test to run
require_once 'PHPUnit/Framework.php';
require_once('../config/config.php');
require_once('../classes/division.class.php');
class DivisionTest extends PHPUnit_Framework_TestCase
{
public function Divisiontest()
{
$division = new division();
try{
$division->createDivisionDetails();
}catch (CustomException $e) {
return;
}
$this->fail('An expected exception has not been raised.');
}
}
on this Command
phpunit --configuration=phpunit.xml division.test.php
but keep geting the error message
PHP Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 13
Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 13
PHP Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 26
Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 26
PHP Warning: require_once(/people_scope/config/standard.inc.php): failed to open stream: No such file or directory in /home/workspace/people_scope/config/config.php on line 46
Warning: require_once(/people_scope/config/standard.inc.php): failed to open stream: No such file or directory in /home/workspace/people_scope/config/config.php on line 46
PHP Fatal error: require_once(): Failed opening required '/people_scope/config/standard.inc.php' (include_path='/usr/bin:.:/usr/share/php:/usr/share/pear:/people_scope/assets/PEAR/:/people_scope/classes/base/') in /home/workspace/people_scope/config/config.php on line 46
Fatal error: require_once(): Failed opening required '/people_scope/config/standard.inc.php' (include_path='/usr/bin:.:/usr/share/php:/usr/share/pear:/people_scope/assets/PEAR/:/people_scope/classes/base/') in /home/workspace/people_scope/config/config.php on line 46
I am using a phpunit.xml to try to set the $_SERVER['HTTP_HOST'] but seem like it is not working at all
<?xml version="1.0" encoding="utf-8" ?>
<phpunit>
<php>
<server name="HTTP_HOST" value="DEV"/>
</php>
</phpunit>
Everything I have read seem to say this should work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,xml 看起来很好。两个建议:
我将函数名称更改为
testDivision()
,以便 phpunit 将其作为真正的测试(代码得到执行,因为它的名称类似于类(又名 php 4 样式构造函数),但那就是不是真正的最佳)如果这不能解决您的问题:当您
在声明之前
添加它时它会起作用吗?只是为了确保错误是 xml 文件未被读取并且没有隐藏在其他地方
The xml looks fine as far as i can see it. Two suggestions:
i'd change the function name to
testDivision()
so phpunit picks it up as a real test (the code gets execution because its named like the class (a.k.a. php 4 style constructor) but thats not really optimal)If that doesn't fix your problem: Does it work when you put
before the
statement ? Just to make sure the error is that the xml file isn't read and doesn't hide somewhere else