Skip to content

Commit

Permalink
[5.4] Add named constructor helpers directly to Testing/File (#18180)
Browse files Browse the repository at this point in the history
* Add named constructor helpers directly to Testing/File

* Fix some doc blocks
  • Loading branch information
adamwathan authored and taylorotwell committed Mar 2, 2017
1 parent 713a2b6 commit f87f4fa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/Illuminate/Http/Testing/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ public function __construct($name, $tempFile)
);
}

/**
* Create a new fake file.
*
* @param string $name
* @param int $kilobytes
* @return \Illuminate\Http\Testing\File
*/
public static function create($name, $kilobytes = 0)
{
return (new FileFactory)->create($name, $kilobytes);
}

/**
* Create a new fake image.
*
* @param string $name
* @param int $width
* @param int $height
* @return \Illuminate\Http\Testing\File
*/
public static function image($name, $width = 10, $height = 10)
{
return (new FileFactory)->image($name, $width, $height);
}

/**
* Set the "size" of the file in kilobytes.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Http/Testing/FileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class FileFactory
* @param int $kilobytes
* @return \Illuminate\Http\Testing\File
*/
public function create($name, $kilobytes)
public function create($name, $kilobytes = 0)
{
return tap(new File($name, tmpfile()), function ($file) use ($kilobytes) {
$file->sizeToReport = $kilobytes * 1024;
Expand All @@ -22,7 +22,7 @@ public function create($name, $kilobytes)
* Create a new fake image.
*
* @param string $name
* @param int $height
* @param int $width
* @param int $height
* @return \Illuminate\Http\Testing\File
*/
Expand Down

0 comments on commit f87f4fa

Please sign in to comment.