配置PHPUnit与phpt
我累坏了。首先,我的代码是: 文件sample000.phpt 我假设这就是测试在使用PHPUnit运行时失败的原因:配置PHPUnit与phpt,phpunit,phpt,Phpunit,Phpt,我累坏了。首先,我的代码是: 文件sample000.phpt 我假设这就是测试在使用PHPUnit运行时失败的原因: 在“C:\php\php.exe”之前,输入的是falsch geschrieben order\n note nicht gefunden werden. 翻译:“C:\php\php.exe”命令拼写错误或找不到。我的php可执行文件安装在D:/xampp/php 我尝试在XML配置文件中为PHPUnit(PHPUnit.XML)设置include路径,并尝试将includ
在“C:\php\php.exe”之前,输入的是falsch geschrieben order\n note nicht gefunden werden.
翻译:“C:\php\php.exe”命令拼写错误或找不到。我的php可执行文件安装在
D:/xampp/php
我尝试在XML配置文件中为PHPUnit(PHPUnit.XML
)设置include路径,并尝试将include路径作为选项传递给类PHPUnit\u Extensions\u PhptTestCase
有谁能告诉我如何配置PHPUnit以便找到php可执行文件吗?PHPUnit中捆绑了PHPT支持。你能试试这个吗 phpunit.xml:
<phpunit>
<testsuites>
<testsuite name="PHPT tests">
<directory suffix=".phpt">phpt-tests</directory>
</testsuite>
</testsuites>
</phpunit>
在阅读了大量源文件并搜索了web之后,我找到了找不到php可执行文件的原因 PEAR使用一些环境变量作为路径和其他一些东西。这些变量存储在windows注册表中。我的注册表搞砸了,所以我必须更新路径
我下载(用于较旧的php版本)并运行它。这将创建一个文件
PEAR\u ENV.reg
。将注册表项导入windows注册表后,一切正常。我给你奖金只是为了帮助你。这是一个非常特殊的问题(windows,doh!),很难解决。可能是重复的
<?php
require_once 'PHPUnit/Extensions/PhptTestCase.php';
class PhptTestCase extends PHPUnit_Extensions_PhptTestCase
{
public $result;
public function __construct( $file ) {
$options = array( 'include_path' => 'D:\\xampp\\php' );
parent::__construct( $file, $options );
}
}
<?php
class PhptTest extends PHPUnit_Framework_TestCase
{
public $object;
public function setUp() {}
public function tearDown() {}
public function testAll() {
require_once 'phptTestCase.php';
$file = __DIR__ . '/phpt-tests/sample000.phpt';
$phpt = new PhptTestCase( $file );
$result = $phpt->run();
$this->assertTrue( $result->wasSuccessful() );
var_dump( $result->failures() );
}
}
array(1) {
[0] =>
class PHPUnit_Framework_TestFailure#441 (2) {
protected $failedTest =>
class PhptTestCase#434 (3) {
public $result =>
NULL
protected $filename =>
string(84) "D:\\htdocs\\[...]\\phpt/phpt-tests/sample000.phpt"
protected $options =>
array(1) {
...
}
}
protected $thrownException =>
class PHPUnit_Framework_ComparisonFailure#440 (12) {
protected $expected =>
string(12) "Hello World!"
protected $actual =>
string(94) "Der Befehl "C:\\php\\php.exe" ist entweder falsch geschrieben oder\nkonnte nicht gefunden werden."
<-- snip -->
protected $file =>
string(53) "D:\\xampp\\php\\pear\\PHPUnit\\Extensions\\PhptTestCase.php"
protected $line =>
int(209)
private $trace =>
array(17) {
...
}
private $previous =>
NULL
}
}
}
<phpunit>
<testsuites>
<testsuite name="PHPT tests">
<directory suffix=".phpt">phpt-tests</directory>
</testsuite>
</testsuites>
</phpunit>
$ phpunit
PHPUnit 3.7.8 by Sebastian Bergmann.
Configuration read from phpunit.xml
.
Time: 0 seconds, Memory: 3.25Mb
OK (1 test, 1 assertion)