Files
ticketbeast/tests/TestCase.php

52 lines
1.2 KiB
PHP

<?php
namespace Tests;
use Exception;
use App\Exceptions\Handler;
use PHPUnit\Framework\Assert;
use Illuminate\Foundation\Testing\TestResponse;
use Illuminate\Contracts\Debug\ExceptionHandler;
abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
{
use CreatesApplication;
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
protected function setUp()
{
parent::setUp();
TestResponse::macro('data', function ($key) {
return $this->original->getData()[$key];
});
TestResponse::macro('assertViewIs', function ($name) {
Assert::assertEquals($name, $this->original->name());
});
}
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;
}
});
}
protected function from($url)
{
session()->setPreviousUrl(url($url));
return $this;
}
}