Files
KanbanGit/tests/Feature/Projects/ProjectCreationTest.php
T
Twyco 990e18e149
CI/CD / test_and_check_app (push) Successful in 5m9s
CI/CD / Publish immutable image (push) Skipped
CI/CD / test_and_check_app (pull_request) Canceled after 0s
CI/CD / Publish immutable image (pull_request) Canceled after 0s
feat(KAN-24): rebuild project creation flow
2026-09-10 19:47:34 +02:00

51 lines
2.1 KiB
PHP

<?php
namespace Tests\Feature\Projects;
use App\Models\ProjectTemplate;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Process\Process;
use Tests\TestCase;
class ProjectCreationTest extends TestCase
{
use RefreshDatabase;
#[DataProvider('missingSources')]
public function test_creation_requires_the_selected_source(string $mode, string $field): void
{
$user = User::factory()->admin()->create();
$this->actingAs($user)->from(route('projects.create'))
->post(route('projects.store'), ['creation_mode' => $mode, 'name' => 'New project', 'key' => 'NEW'])
->assertRedirect(route('projects.create'))->assertSessionHasErrors($field);
$this->assertDatabaseMissing('projects', ['key' => 'NEW']);
}
/** @return array<string, array{string, string}> */
public static function missingSources(): array
{
return ['duplicate' => ['duplicate', 'source_project_id'], 'template' => ['template', 'source_template_id']];
}
public function test_an_unpublished_template_cannot_be_used_to_create_a_project(): void
{
$user = User::factory()->admin()->create();
$template = ProjectTemplate::factory()->create(['is_published' => false]);
$this->actingAs($user)->post(route('projects.store'), [
'creation_mode' => 'template', 'source_template_id' => $template->id, 'name' => 'New project', 'key' => 'NEW',
])->assertSessionHasErrors('source_template_id');
$this->assertDatabaseMissing('projects', ['key' => 'NEW']);
}
public function test_creation_page_rendering_and_localization(): void
{
$process = new Process(['node', 'tests/Fixtures/project-creation.mjs'], base_path());
$process->setTimeout(60);
$process->run();
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
$this->assertStringContainsString('Project creation rendering checks passed.', $process->getOutput());
}
}