Skip to content
Permalink
Browse files

allow string content on fake file creation

  • Loading branch information
taylorotwell committed Nov 19, 2019
1 parent f2a67ed commit 181db51595d546cbd24b3fac0cb276255e147286
Showing with 10 additions and 4 deletions.
  1. +1 −1 src/Illuminate/Http/Testing/File.php
  2. +9 −3 src/Illuminate/Http/Testing/FileFactory.php
@@ -49,7 +49,7 @@ public function __construct($name, $tempFile)
* Create a new fake file.
*
* @param string $name
* @param int $kilobytes
* @param string|int $kilobytes
* @return \Illuminate\Http\Testing\File
*/
public static function create($name, $kilobytes = 0)
@@ -10,13 +10,19 @@ class FileFactory
* Create a new fake file.
*
* @param string $name
* @param int $kilobytes
* @param string|int $kilobytes
* @return \Illuminate\Http\Testing\File
*/
public function create($name, $kilobytes = 0)
{
return tap(new File($name, tmpfile()), function ($file) use ($kilobytes) {
$file->sizeToReport = $kilobytes * 1024;
$tmp = tmpfile();
if (is_string($kilobytes)) {
file_put_contents($tmp, $kilobytes);
}
return tap(new File($name, $tmp), function ($file) use ($kilobytes) {
$file->sizeToReport = is_string($kilobytes) ? fstat($tmp)['size'] : ($kilobytes * 1024);
});
}

0 comments on commit 181db51

Please sign in to comment.
You can’t perform that action at this time.