fedi-feed-router/tests/TestCase.php

47 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2025-06-29 08:50:03 +02:00
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
2025-08-10 04:16:53 +02:00
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Http;
2025-08-10 04:16:53 +02:00
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();
// Prevent Vite manifest errors in tests (no npm build in CI)
$this->withoutVite();
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();
2025-08-10 04:16:53 +02:00
// Clear all facade instances to prevent interference
Facade::clearResolvedInstances();
2025-08-10 04:16:53 +02:00
// Ensure Mockery is properly closed to prevent facade interference
if (class_exists(Mockery::class)) {
Mockery::close();
}
2025-08-10 04:16:53 +02:00
parent::tearDown();
}
2025-06-29 08:50:03 +02:00
}