0

i write test like this

$response = $this->actingAs(\App\Models\User::first())
    ->post(route('profile-menu.update', $profile), [
        'image' => UploadedFile::fake()->image('avatar.jpg', 900, 500)->size(100),
        'profile' => [
            'en' => [
                'title' => 'test',
                'description' => 'test'
            ],
            'id' => [
                'title' => 'test',
                'description' => 'test'
            ]
        ]
    ]);

print_r($response->decodeResponseJson());
$response->assertStatus(302);

and i import the requirement in top of my controller

namespace App\Http\Controllers\Admin;

use File;
use Image;
use Storage;

i already register the Intervention service provider and write alias for it.

the test result is

1) Tests\Feature\MyTest::testUpdateProfileDetail
Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Image::make()
/opt/atlassian/pipelines/agent/build/app/Http/Controllers/Admin/ProfileMenuController.php:72

i can't figure it out how is Image::make() not recognized by phpunit, is there any problem with my script or its a bug from pipelining service?

Vico
  • 108
  • 2
  • 14
  • use Intervention\Image\Facades\Image; include it – Sachin Aghera Oct 27 '18 at 04:31
  • i already make it as alias in config, it should work right? if i do it outside the test environment / my local computer, its working, but then it throw 500 error said that Image::make() is undefined. i think something wrong with the environment – Vico Oct 28 '18 at 13:23

1 Answers1

0

I was having the same issue in Laravel 5.7 working on Ubuntu 18.0.4 with a virtual host settings, please type hint 'use Intervention \Image\Facades\Image' instead of 'use Intervention \Image\Image'

  • Someone already suggested this to the OP. I would suggest you go through the comments on the question before writing an answer – ammportal Jul 13 '19 at 14:25