Skip to content
Permalink
Browse files

[6.x] Allow to create fake file with content

  • Loading branch information
shadoWalker89 committed Nov 18, 2019
1 parent 899b8c3 commit 2cc6fa33732118cc71c74209b02382b989689b63
Showing with 29 additions and 0 deletions.
  1. +12 −0 src/Illuminate/Http/Testing/File.php
  2. +17 −0 src/Illuminate/Http/Testing/FileFactory.php
@@ -57,6 +57,18 @@ public static function create($name, $kilobytes = 0)
return (new FileFactory)->create($name, $kilobytes);
}
/**
* Create a new fake file with content.
*
* @param string $name
* @param string $content
* @return \Illuminate\Http\Testing\File
*/
public static function createWithContent($name, $content)
{
return (new FileFactory)->createWithContent($name, $content);
}
/**
* Create a new fake image.
*
@@ -20,6 +20,23 @@ public function create($name, $kilobytes = 0)
});
}
/**
* Create a new fake file with content.
*
* @param string $name
* @param string $content
* @return \Illuminate\Http\Testing\File
*/
public function createWithContent($name, $content)
{
$tmpfile = tmpfile();
fwrite($tmpfile, $content);
return tap(new File($name, $tmpfile), function ($file) use ($tmpfile) {
$file->sizeToReport = fstat($tmpfile)['size'];
});
}
/**
* Create a new fake image.
*

0 comments on commit 2cc6fa3

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