framework: Unexpected Error: Illuminate/Testing/Concerns/TestDatabases.php

Laravel Version: 8.25.0 Laravel Framework: 8.25.0

After composer update from laravel v8.24 to v8.25 it breaks and throws off things.

image

Error: syntax error, unexpected ')

Cause of the Issue:

 protected function switchToDatabase($database)
    {
        DB::purge();
 
        $default = config('database.default');
 
        config()->set(
            "database.connections.{$default}.database",
            $database,
        );
    }

Temp solution to Fix: Commented the switchToDatabase function.

 protected function switchToDatabase($database)
    {
       /* DB::purge();

        $default = config('database.default');

        config()->set(
            "database.connections.{$default}.database",
            $database,
        );*/
    }

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

Okay, found the issue. The request was a DELETE request and there was a reference to PHP7.2 for DELETE requests in the web.config file. Sorry! Thanks!

Could you please elaborate more about your solution?, what do you mean reference to PHP7.2 for DELETE requests in the web.config file.

UPDATE Nevermind, I found the issue, my apache wasn’t running php7.4 so I just removed the old version with sudo a2dismod php7.2, enabled the new one with sudo a2enmod php7.4 and finally restarted the apache service sudo service apache2 restart

just remove the commas before " ) "

if ($url) {
            config()->set(
                "database.connections.{$default}.url",
                preg_replace('/^(.*)(\/[\w-]*)(\??.*)$/', "$1/{$database}$3", $url)
            );
        } else {
            config()->set(
                "database.connections.{$default}.database",
                $database
            );
        }

Okay, found the issue. The request was a DELETE request and there was a reference to PHP7.2 for DELETE requests in the web.config file. Sorry! Thanks!

Hello there, it seems you’re using running the page on PHP lower than 7.3. Otherwise, you shouldn’t be able to see this error.