0
0
mirror of https://github.com/PHPMailer/PHPMailer.git synced 2024-09-20 01:52:15 +02:00

Convert getFile function to simpler PHP5 version

Add a unit test for getFile
This commit is contained in:
Marcus Bointon 2008-11-20 22:43:07 +00:00
parent 88694da004
commit 51d601058c
2 changed files with 8 additions and 10 deletions

View File

@ -1935,18 +1935,10 @@ class PHPMailer {
*
* @access public
* @param string $filename Parameter File Name
* @return string (or boolean false if it fails to read for any reason)
*/
public function getFile($filename) {
$return = '';
if ($fp = fopen($filename, 'rb')) {
while (!feof($fp)) {
$return .= fread($fp, 1024);
}
fclose($fp);
return $return;
} else {
return false;
}
return @file_get_contents($filename);
}
/**

View File

@ -565,6 +565,12 @@ class phpmailerTest extends TestCase
$this->assert(false, 'No language files found!');
}
}
//Check that getFile works
function test_getFile() {
$a = $this->Mail->getFile('../class.phpmailer.php'); //Point at any non-empty file
$this->assert(($a !== false), 'GetFile failed to read a file.');
}
}
/**
* Create and run test instance.