Closed CampsBay closed 7 years ago
It is currently trying to find the Exception
class within the Tests
namespace ('Declaration of class@anonymous::report(Tests\Exception $e)'). Tests\Exception
is of course not compatible with \Exception
.
Try importing Exception
(use Exception;
) or put a \
before the class name where it is used, I think that will solve the issue for you.
Thanks!
Added use Exception;
after namespace and it works
Thanks!
File now as follows
<?php
namespace Tests;
use Exception;
use App\Exceptions\Handler;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Contracts\Console\Kernel;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class BrowserKitTest extends BaseTestCase
{
/**
* The base URL of the application.
*
* @var string
*/
public $baseUrl = 'http://localhost';
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
protected function disableExceptionHandling()
{
$this->app->instance(ExceptionHandler::class, new class extends Handler {
public function __construct() {}
public function report(Exception $e) {}
public function render($request, Exception $e) {
throw $e;
}
});
}
}
Hi Adam
Have installed https://github.com/laravel/browser-kit-testing for Laravel 5.4 compatability as per the upgrade guide on the 5.4 release docs. My BrowserKitTest.php files is as follows with the disableExceptionHandling method included.
This is the error I get:
PHP Fatal error: Declaration of class@anonymous::report(Tests\Exception $e) must be compatible with Illuminate\Contracts\Debug\ExceptionHandler::report(Exception $e) in /Users/bm/Side/cellardoor/tests/BrowserKitTest.php on line 21
Should this work as before or should something else be changed
Thanks for your help