added countries support expanded for ISO 3166 standard merged in new support

This commit is contained in:
Mark Gregory
2026-06-15 11:00:14 +01:00
parent 4099be7770
commit 96e0d60355
10 changed files with 187 additions and 65 deletions
@@ -14,6 +14,17 @@ class DocumentationModuleTest extends TestCase
{
use RefreshDatabase;
/**
* Add a CSRF token for projects that keep web middleware enabled during tests.
*
* @param array<string, mixed> $payload
* @return array<string, mixed>
*/
private function csrfPayload(array $payload): array
{
return array_merge(['_token' => 'test-token'], $payload);
}
/**
* The documentation dashboard renders for authenticated users.
*/
@@ -40,7 +51,7 @@ class DocumentationModuleTest extends TestCase
'is_active' => true,
]);
$response = $this->actingAs($user)->post(route('documentation.documents.store'), [
$response = $this->actingAs($user)->withSession(['_token' => 'test-token'])->post(route('documentation.documents.store'), $this->csrfPayload([
'documentation_category_id' => $category->id,
'title' => 'Goods In Process',
'slug' => 'goods-in-process',
@@ -50,7 +61,7 @@ class DocumentationModuleTest extends TestCase
'version' => '1.0.0',
'reference' => 'SOP-001',
'is_featured' => '1',
]);
]));
$response->assertRedirect();
$this->assertDatabaseHas('documentation_documents', [
@@ -72,7 +83,7 @@ class DocumentationModuleTest extends TestCase
$user = \App\Models\User::factory()->create();
$file = UploadedFile::fake()->createWithContent('goods-in.md', "# Goods In\n\n- Scan delivery note\n- Confirm quantities");
$response = $this->actingAs($user)->post(route('documentation.documents.store'), [
$response = $this->actingAs($user)->withSession(['_token' => 'test-token'])->post(route('documentation.documents.store'), $this->csrfPayload([
'title' => 'Goods In Markdown',
'slug' => 'goods-in-markdown',
'summary' => 'Markdown controlled document.',
@@ -80,7 +91,7 @@ class DocumentationModuleTest extends TestCase
'status' => DocumentationDocument::STATUS_PUBLISHED,
'version' => '1.0.0',
'attachment' => $file,
]);
]));
$response->assertRedirect();
@@ -102,7 +113,7 @@ class DocumentationModuleTest extends TestCase
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->post(route('documentation.documents.store'), [
$response = $this->actingAs($user)->withSession(['_token' => 'test-token'])->post(route('documentation.documents.store'), $this->csrfPayload([
'title' => 'Attachment Pack',
'slug' => 'attachment-pack',
'summary' => 'Document with supporting files.',
@@ -113,7 +124,7 @@ class DocumentationModuleTest extends TestCase
UploadedFile::fake()->createWithContent('setup.md', "```php\necho 'ok';\n```"),
UploadedFile::fake()->create('process.pdf', 64, 'application/pdf'),
],
]);
]));
$response->assertRedirect();
@@ -129,7 +140,8 @@ class DocumentationModuleTest extends TestCase
->assertOk();
$this->actingAs($user)
->delete(route('documentation.documents.attachments.destroy', [$document, $attachment]))
->withSession(['_token' => 'test-token'])
->delete(route('documentation.documents.attachments.destroy', [$document, $attachment]), ['_token' => 'test-token'])
->assertRedirect(route('documentation.documents.edit', $document));
$this->assertDatabaseMissing('documentation_attachments', ['id' => $attachment->id]);
@@ -158,14 +170,14 @@ class DocumentationModuleTest extends TestCase
{
$user = \App\Models\User::factory()->create();
$this->actingAs($user)->post(route('documentation.categories.store'), [
$this->actingAs($user)->withSession(['_token' => 'test-token'])->post(route('documentation.categories.store'), $this->csrfPayload([
'name' => 'Policies',
'slug' => 'policies',
'colour' => 'emerald',
'description' => 'Controlled business policies.',
'sort_order' => 1,
'is_active' => '1',
])->assertRedirect(route('documentation.categories.index'));
]))->assertRedirect(route('documentation.categories.index'));
$this->assertDatabaseHas('documentation_categories', [
'name' => 'Policies',