Level 34
same problem, any updates?
Hi, im trying to test image uploading and cropping after upload. Manual testing everything is fine.
I get this error Intervention\Image\Exception\NotReadableException' with message 'Unable to read image from file (/Users/ho/.....
My test
/** @test */
public function a_user_can_create_a_new_category()
{
$user = factory(App\User::class)->create();
$this->actingAs($user)
->visit('admin/categories/create')
->type('Category Name','name')
->attach('storage/dummy/image.jpg','photo')
->press('submit__category')
->seePageIs('admin/categories');
$this->seeInDatabase('categories', ['name' => 'Category Name','slug' => 'category-name']);
}
My store function
public function store(Request $request)
{
$destination = 'uploads/categories/';
$file = $request->file('photo');
$fileName = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$name = md5( $fileName . time() ) . '.' . $extension;
Image::make($file)->fit(200, 200)->save($destination . $name);
$category = Category::create($request->all());
$category->update(['photo' => $destination . $name]);
return redirect('admin/categories');
}
Result/error when running my test
1) CategoriesTest::a_user_can_create_a_new_category
A request to [http://localhost/admin/categories] failed. Received status code [500].
/Users/ho/Code/projects/www.belimo.dk/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:168
/Users/ho/Code/projects/www.belimo.dk/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:64
/Users/ho/Code/projects/www.belimo.dk/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:86
/Users/ho/Code/projects/www.belimo.dk/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:693
/Users/ho/Code/projects/www.belimo.dk/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:680
/Users/ho/Code/projects/www.belimo.dk/www/tests/acceptance/CategoriesTest.php:42
/Users/ho/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:149
/Users/ho/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:100
Caused by
exception 'Intervention\Image\Exception\NotReadableException' with message 'Unable to read image from file (/Users/ho/Code/projects/www.belimo.dk/www).' in /Users/ho/Code/projects/www.belimo.dk/www/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php:20
Stack trace:
#0 /Users/ho/Code/projects/www.belimo.dk/www/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php(281): Intervention\Image\Gd\Decoder->initFromPath('/Users/ho/Code/...')
Die and dump image on manual test
UploadedFile {#30 ▼
-test: false
-originalName: "square.jpg"
-mimeType: "image/jpeg"
-size: 3325658
-error: 0
path: "/Applications/MAMP/tmp/php"
filename: "php0aR0hi"
basename: "php0aR0hi"
pathname: "/Applications/MAMP/tmp/php/php0aR0hi"
extension: ""
realPath: "/Applications/MAMP/tmp/php/php0aR0hi"
aTime: 2016-02-15 14:56:10
mTime: 2016-02-15 14:56:10
cTime: 2016-02-15 14:56:10
inode: 21461578
size: 3325658
perms: 0100600
owner: 347402188
group: 80
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
}
Die and dump image when running automatic tests
..Symfony\Component\HttpFoundation\File\UploadedFile {#1108
-test: true
-originalName: "image.jpg"
-mimeType: "application/octet-stream"
-size: 0
-error: 4
path: ""
filename: ""
basename: ""
pathname: ""
extension: ""
realPath: "/Users/ho/Code/projects/www.belimo.dk/www"
aTime: 1970-01-01 00:00:00
mTime: 1970-01-01 00:00:00
cTime: 1970-01-01 00:00:00
inode: false
size: false
perms: 00
owner: false
group: false
type: false
writable: false
readable: false
executable: false
file: false
dir: false
link: false
}
Please or to participate in this conversation.