Repository navigation
Expand file tree
/
Copy pathTestCase.php
More file actions
76 lines (64 loc) · 1.93 KB
/
Copy pathTestCase.php
File metadata and controls
76 lines (64 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/*
* This file is part of the Antvel Shop package.
*
* (c) Gustavo Ocanto <gustavoocanto@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tests;
use App\Exceptions\Handler;
use Illuminate\Support\Facades\Storage;
use Illuminate\Foundation\Testing\TestResponse;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
protected function setUp()
{
parent::setUp();
$this->app->make('config')->set('filesystems.default', 'testing');
$this->registerMacros();
}
/**
* Disables the Laravel exception handling.
*
* @author @adamwathan <https://gist.github.com/adamwathan/125847c7e3f16b88fa33a9f8b42333da>
* @return void
*/
protected function disableExceptionHandling()
{
$this->oldExceptionHandler = $this->app->make(ExceptionHandler::class);
$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;
}
});
}
/**
* Enables the Laravel exception handling.
*
* @author @adamwathan <https://gist.github.com/adamwathan/125847c7e3f16b88fa33a9f8b42333da>
* @return void
*/
protected function withExceptionHandling()
{
$this->app->instance(ExceptionHandler::class, $this->oldExceptionHandler);
return $this;
}
/**
* Register the tests suit macros.
*
* @return void
*/
protected function registerMacros()
{
TestResponse::macro('data', function ($key) {
return $this->original->getData()[$key];
});
}
}