Skip to content

Commit

Permalink
Use 5.1 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia Alshanetsky committed Feb 16, 2006
1 parent a790d6e commit 96843fe
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions server-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@
* various utility functions
*/

function save_to_file($filename,$text)
{
$fp = @fopen($filename,'w')
or die("Cannot open file '" . $filename . "' (save_to_file)");
fwrite($fp,$text);
fclose($fp);
}

function settings2array($settings, &$ini_settings)
{
foreach($settings as $setting) {
Expand Down Expand Up @@ -578,7 +570,7 @@ function runscript($script,$removeheaders=false,$cwd=NULL)
$tmp_file = "$cwd$pi";
$pi = substr($cwd,strlen($this->conf['TEST_BASE_PATH'])) . $pi;
$url = $this->conf['TEST_WEB_BASE_URL'] . $pi;
save_to_file($tmp_file,$script);
file_put_contents($tmp_file,$script);
$fd = fopen($url, "rb");
$out = '';
if ($fd) {
Expand Down Expand Up @@ -1285,7 +1277,7 @@ function run_test($file)
}

// We've satisfied the preconditions - run the test!
save_to_file($tmp_file,$section_text['FILE']);
file_put_contents($tmp_file,$section_text['FILE']);

$post = NULL;
$args = "";
Expand Down Expand Up @@ -1507,25 +1499,25 @@ function run_test($file)
// write .exp
if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'E') !== FALSE) {
$logname = ereg_replace('\.phpt$','.exp',$file);
save_to_file($logname,$wanted);
file_put_contents($logname,$wanted);
}

// write .out
if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'O') !== FALSE) {
$logname = ereg_replace('\.phpt$','.out',$file);
save_to_file($logname,$output);
file_put_contents($logname,$output);
}

// write .diff
if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'D') !== FALSE) {
$logname = ereg_replace('\.phpt$','.diff',$file);
save_to_file($logname,generate_diff($wanted,$output));
file_put_contents($logname,generate_diff($wanted,$output));
}

// write .log
if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'L') !== FALSE) {
$logname = ereg_replace('\.phpt$','.log',$file);
save_to_file($logname,
file_put_contents($logname,
"\n---- EXPECTED OUTPUT\n$wanted\n".
"---- ACTUAL OUTPUT\n$output\n".
"---- FAILED\n");
Expand Down

0 comments on commit 96843fe

Please sign in to comment.