I'm totally stucked. At first my code:
File sample000.phpt
--TEST--
Basic test
--DESCRIPTION--
Lowlevel basic test
--FILE--
<?php
echo 'Hello World!';
?>
--EXPECT--
Hello World!
File PhptTestCase.php
<?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 );
}
}
File phptTest.php
<?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() );
}
}
Running pear run-tests sample000.phpt
from the command line work fine. Running phpunit PhptTest.php
will always fail.
After some research I dumped the result with var_dump( $result->failures() );
and see that the php executable couldn't be found:
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
}
}
}
I assume this is the line why the test fails when it runs with PHPUnit:
Der Befehl "C:\php\php.exe" ist entweder falsch geschrieben oder\nkonnte nicht gefunden werden.
translated: The "C: \ php \ php.exe" command is either misspelled or could not be found. My php executable is installes in D:/xampp/php
I try to setup the include path in XML configuration file for PHPUnit (phpunit.xml
) and also try to pass the include path as option to the class PHPUnit_Extensions_PhptTestCase
.
Can anybody tell me how to configure PHPUnit so it can find the php executable?