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:
parent
88694da004
commit
51d601058c
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user