-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCase.php
More file actions
65 lines (53 loc) · 1.74 KB
/
TestCase.php
File metadata and controls
65 lines (53 loc) · 1.74 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
<?php
declare(strict_types=1);
namespace Tests;
use Closure;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Kirschbaum\Monitor\MonitorServiceProvider;
use Kirschbaum\Redactor\RedactorServiceProvider;
use Mockery\MockInterface;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase as BaseTestCase;
class TestCase extends BaseTestCase
{
use WithWorkbench;
protected function getPackageProviders($app): array
{
return [
MonitorServiceProvider::class,
RedactorServiceProvider::class,
];
}
protected function setUp(): void
{
parent::setUp();
Http::preventingStrayRequests();
}
/**
* Set up Log facade mocking to handle Laravel infrastructure calls without
* interfering with explicit test expectations for application logging.
*/
protected function setupLogMocking(): void
{
// Only mock the methods that Laravel's infrastructure may call in background
// during exception/deprecation handling, class loading, etc.
// These are NOT the methods we want to test explicitly in our application code
Log::shouldReceive('channel')
->andReturnSelf()
->byDefault();
// Laravel's HandleExceptions calls warning() for deprecation notices
Log::shouldReceive('warning')
->andReturnSelf()
->byDefault();
}
/**
* Force bind a mock into the container for app() calls with parameters.
*/
protected function mockBind(string $abstract, ?Closure $callback = null): MockInterface
{
$mock = $this->mock($abstract, $callback);
app()->offsetSet($abstract, $mock);
return $mock;
}
}