fedi-feed-router/tests/TestCase.php

43 lines
1.1 KiB
PHP

<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Facade;
use Mockery;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
protected function setUp(): void
{
parent::setUp();
// Clean up any existing Mockery instances before each test
if (class_exists(Mockery::class)) {
Mockery::close();
Mockery::globalHelpers();
}
// Prevent any external HTTP requests during tests unless explicitly faked in a test
Http::preventStrayRequests();
}
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();
}
}