Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Add named constructor helpers directly to Testing/File #18180

Merged
merged 2 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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