skip to Main Content

I’m a beginner in Laravel and still learning, when I wanted to do a fake file upload test I got an error

public function testUpload()
{
    $picture = UploadedFile::fake()->image('blabla.png');

    $this->post('/file/upload',[
        'picture' => $picture
    ])->assertSeeText("OK blabla.png");
}

Error: Call to undefined function
IlluminateHttpTestingimagecreatetruecolor()

in the learning video that I saw, a blabla.png file appeared in the folder storage

2

Answers


  1. Try using valid import

    https://laravel.com/docs/10.x/http-tests#testing-file-uploads

    use IlluminateHttpUploadedFile;
    
    Login or Signup to reply.
  2. I assume it’s about the PHP GD library not related to Laravel or the code. The code seems OK to me

    Install PHP GD Library and try

    sudo apt-get update
    sudo apt-get install php-gd
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search