Files
pterodactyl-panel/tests/Integration/IntegrationTestCase.php
T

56 lines
1.8 KiB
PHP
Raw Normal View History

2018-03-04 16:30:16 -06:00
<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2018-03-04 16:30:16 -06:00
namespace Pterodactyl\Tests\Integration;
2021-01-23 12:09:16 -08:00
use Carbon\CarbonImmutable;
2022-10-14 10:59:20 -06:00
use Carbon\CarbonInterface;
2026-10-05 18:10:18 -04:00
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Filesystem\FilesystemManager;
use Illuminate\Support\Facades\Event;
use Pterodactyl\Events\ActivityLogged;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Services\Helpers\AssetHashService;
use Pterodactyl\Tests\Assertions\AssertsActivityLogged;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Tests\TestCase;
2021-01-23 12:09:16 -08:00
use Pterodactyl\Tests\Traits\Integration\CreatesTestModels;
2018-03-04 16:30:16 -06:00
use Pterodactyl\Transformers\Api\Application\BaseTransformer;
abstract class IntegrationTestCase extends TestCase
{
use AssertsActivityLogged;
2026-10-05 18:10:18 -04:00
use CreatesTestModels;
2020-06-27 10:35:02 -07:00
2022-05-29 17:07:34 -04:00
protected array $connectionsToTransact = ['mysql'];
2018-03-04 16:30:16 -06:00
2022-05-29 20:39:51 -04:00
protected $defaultHeaders = [
'Accept' => 'application/json',
];
2026-10-05 18:10:18 -04:00
protected function setUp(): void
{
parent::setUp();
Event::fake(ActivityLogged::class);
2026-10-05 18:10:18 -04:00
// The React shell reads the built Vite manifest; point the asset service at a
// committed fixture so view rendering does not depend on a frontend build.
$this->app->bind(AssetHashService::class, fn (Application $app): AssetHashService => new AssetHashService(
$app->make(FilesystemManager::class),
base_path('tests/Fixtures'),
));
}
2018-03-04 16:30:16 -06:00
/**
* Return an ISO-8601 formatted timestamp to use in the API response.
*/
2026-10-05 18:10:18 -04:00
protected function formatTimestamp(CarbonInterface|string $timestamp): string
2018-03-04 16:30:16 -06:00
{
2026-10-05 18:10:18 -04:00
$value = $timestamp instanceof CarbonInterface
? CarbonImmutable::instance($timestamp)
: CarbonImmutable::createFromFormat(CarbonInterface::DEFAULT_TO_STRING_FORMAT, $timestamp);
return $value->setTimezone(BaseTransformer::RESPONSE_TIMEZONE)->toAtomString();
2018-03-04 16:30:16 -06:00
}
}