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
|
* @access public
|
||||||
* @param string $filename Parameter File Name
|
* @param string $filename Parameter File Name
|
||||||
|
* @return string (or boolean false if it fails to read for any reason)
|
||||||
*/
|
*/
|
||||||
public function getFile($filename) {
|
public function getFile($filename) {
|
||||||
$return = '';
|
return @file_get_contents($filename);
|
||||||
if ($fp = fopen($filename, 'rb')) {
|
|
||||||
while (!feof($fp)) {
|
|
||||||
$return .= fread($fp, 1024);
|
|
||||||
}
|
|
||||||
fclose($fp);
|
|
||||||
return $return;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -565,6 +565,12 @@ class phpmailerTest extends TestCase
|
||||||
$this->assert(false, 'No language files found!');
|
$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.
|
* Create and run test instance.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue