Files
hado/core/tests/Feature/SourceCreateCommandTest.php
2026-09-04 06:58:03 -03:00

30 lines
790 B
PHP

<?php
namespace Tests\Feature;
use App\Models\Source;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class SourceCreateCommandTest extends TestCase
{
use RefreshDatabase;
public function test_creates_source_and_prints_token_once(): void
{
$this->artisan('hado:source:create', ['name' => 'docs'])
->expectsOutputToContain('Token: hado_')
->assertSuccessful();
$source = Source::where('name', 'docs')->sole();
$this->assertSame(64, strlen($source->token_hash));
}
public function test_refuses_duplicate_name(): void
{
Source::create(['name' => 'docs', 'token_hash' => hash('sha256', 'x')]);
$this->artisan('hado:source:create', ['name' => 'docs'])->assertFailed();
}
}