2025-06-29 08:50:03 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
2025-08-10 01:26:56 +02:00
|
|
|
use Illuminate\Support\Facades\Http;
|
2025-08-10 04:16:53 +02:00
|
|
|
use Illuminate\Support\Facades\Facade;
|
|
|
|
|
use Mockery;
|
2025-06-29 08:50:03 +02:00
|
|
|
|
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
|
|
|
{
|
2025-08-02 03:48:06 +02:00
|
|
|
use CreatesApplication;
|
2025-08-10 01:26:56 +02:00
|
|
|
|
|
|
|
|
protected function setUp(): void
|
|
|
|
|
{
|
|
|
|
|
parent::setUp();
|
2025-08-15 02:50:42 +02:00
|
|
|
|
|
|
|
|
// Clean up any existing Mockery instances before each test
|
|
|
|
|
if (class_exists(Mockery::class)) {
|
|
|
|
|
Mockery::close();
|
|
|
|
|
Mockery::globalHelpers();
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-10 01:26:56 +02:00
|
|
|
// Prevent any external HTTP requests during tests unless explicitly faked in a test
|
|
|
|
|
Http::preventStrayRequests();
|
|
|
|
|
}
|
2025-08-10 04:16:53 +02:00
|
|
|
|
|
|
|
|
protected function tearDown(): void
|
|
|
|
|
{
|
|
|
|
|
// Clear HTTP fakes between tests to prevent interference
|
|
|
|
|
Http::clearResolvedInstances();
|
|
|
|
|
|
|
|
|
|
// Clear all facade instances to prevent interference
|
|
|
|
|
Facade::clearResolvedInstances();
|
|
|
|
|
|
|
|
|
|
// Ensure Mockery is properly closed to prevent facade interference
|
|
|
|
|
if (class_exists(Mockery::class)) {
|
|
|
|
|
Mockery::close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parent::tearDown();
|
|
|
|
|
}
|
2025-06-29 08:50:03 +02:00
|
|
|
}
|