Skip to content

Commit

Permalink
Convert getFile function to simpler PHP5 version
Browse files Browse the repository at this point in the history
Add a unit test for getFile
  • Loading branch information
Synchro committed Nov 20, 2008
1 parent 88694da commit 51d6010
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 2 additions & 10 deletions class.phpmailer.php
Expand Up @@ -1935,18 +1935,10 @@ public function set ( $name, $value = '' ) {
*
* @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);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions test/phpmailer_test.php
Expand Up @@ -565,6 +565,12 @@ function test_Translations() {
$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.
Expand Down

0 comments on commit 51d6010

Please sign in to comment.