2018-03-04 16:30:16 -06:00
|
|
|
<?php
|
|
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
namespace App\Tests\Integration;
|
2018-03-04 16:30:16 -06:00
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
use App\Events\ActivityLogged;
|
|
|
|
|
use App\Tests\Assertions\AssertsActivityLogged;
|
2025-09-24 13:34:19 +02:00
|
|
|
use App\Tests\TestCase;
|
2024-03-12 22:39:16 -04:00
|
|
|
use App\Tests\Traits\Integration\CreatesTestModels;
|
|
|
|
|
use App\Transformers\Api\Application\BaseTransformer;
|
2025-09-24 13:34:19 +02:00
|
|
|
use Carbon\CarbonImmutable;
|
|
|
|
|
use Carbon\CarbonInterface;
|
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTruncation;
|
2024-04-30 00:04:24 +02:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2025-09-24 13:34:19 +02:00
|
|
|
use Illuminate\Support\Facades\Event;
|
2018-03-04 16:30:16 -06:00
|
|
|
|
|
|
|
|
abstract class IntegrationTestCase extends TestCase
|
|
|
|
|
{
|
2022-06-18 14:21:20 -04:00
|
|
|
use AssertsActivityLogged;
|
2024-03-12 22:47:32 -04:00
|
|
|
use CreatesTestModels;
|
2025-01-30 16:39:17 -05:00
|
|
|
use DatabaseTruncation;
|
|
|
|
|
|
|
|
|
|
protected $seed = true;
|
2020-06-27 10:35:02 -07:00
|
|
|
|
2022-05-29 20:39:51 -04:00
|
|
|
protected $defaultHeaders = [
|
|
|
|
|
'Accept' => 'application/json',
|
|
|
|
|
];
|
|
|
|
|
|
2024-03-19 21:09:16 -04:00
|
|
|
protected function setUp(): void
|
2022-06-18 14:21:20 -04:00
|
|
|
{
|
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
Event::fake(ActivityLogged::class);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-04 16:30:16 -06:00
|
|
|
/**
|
|
|
|
|
* Return an ISO-8601 formatted timestamp to use in the API response.
|
|
|
|
|
*/
|
|
|
|
|
protected function formatTimestamp(string $timestamp): string
|
|
|
|
|
{
|
2022-10-14 10:59:20 -06:00
|
|
|
return CarbonImmutable::createFromFormat(CarbonInterface::DEFAULT_TO_STRING_FORMAT, $timestamp)
|
2018-03-04 16:30:16 -06:00
|
|
|
->setTimezone(BaseTransformer::RESPONSE_TIMEZONE)
|
2022-10-14 10:59:20 -06:00
|
|
|
->toAtomString();
|
2018-03-04 16:30:16 -06:00
|
|
|
}
|
2024-04-30 00:04:24 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The database connections that should have transactions.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
protected function connectionsToTransact()
|
|
|
|
|
{
|
|
|
|
|
return [DB::getDriverName()];
|
|
|
|
|
}
|
2018-03-04 16:30:16 -06:00
|
|
|
}
|