26 lines
1.0 KiB
PHP
26 lines
1.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Models\Project;
|
||
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||
|
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
|
||
|
|
// NOTE: \Tests\TestCase auto-binds via tests/Pest.php (->in('Feature')); explicit
|
||
|
|
// uses(\Tests\TestCase::class) conflicts ("already uses the test case").
|
||
|
|
// DatabaseTransactions — изоляция; also ensures DB connection is bootstrapped.
|
||
|
|
uses(DatabaseTransactions::class);
|
||
|
|
|
||
|
|
it('projects table has archived_at column nullable timestamp', function () {
|
||
|
|
expect(Schema::hasColumn('projects', 'archived_at'))->toBeTrue();
|
||
|
|
$type = Schema::getColumnType('projects', 'archived_at');
|
||
|
|
// PostgreSQL TIMESTAMPTZ → Doctrine/Laravel reports 'timestamptz' (not 'timestamp').
|
||
|
|
expect($type)->toBe('timestamptz');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('Project model has archived_at in fillable and casts it to datetime', function () {
|
||
|
|
$project = new Project;
|
||
|
|
expect(in_array('archived_at', $project->getFillable(), true))->toBeTrue();
|
||
|
|
expect($project->getCasts()['archived_at'] ?? null)->toBe('datetime');
|
||
|
|
});
|