Initial commit

This commit is contained in:
Zdeněk Burda
2026-01-09 21:26:40 +01:00
parent e83aec6dca
commit 41e3ce6f25
404 changed files with 61250 additions and 28 deletions

View File

@@ -0,0 +1,74 @@
<?php
namespace Tests\Feature\Catalog;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class BandControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_bands(): void
{
$band = $this->createBand();
$response = $this->getJson('/api/bands');
$response->assertStatus(200)
->assertJsonFragment(['id' => $band->id]);
}
public function test_show_returns_band(): void
{
$band = $this->createBand();
$response = $this->getJson("/api/bands/{$band->id}");
$response->assertStatus(200)
->assertJsonFragment(['id' => $band->id]);
}
public function test_admin_can_create_update_and_delete_band(): void
{
$this->actingAsAdmin();
$createResponse = $this->postJson('/api/bands', [
'name' => '144 MHz',
'order' => 1,
'edi_band_begin' => 144000000,
'edi_band_end' => 146000000,
'has_power_category' => true,
]);
$createResponse->assertStatus(201);
$bandId = $createResponse->json('id');
$updateResponse = $this->putJson("/api/bands/{$bandId}", [
'name' => '144 MHz (upd)',
'order' => 2,
'edi_band_begin' => 144000000,
'edi_band_end' => 146000000,
'has_power_category' => false,
]);
$updateResponse->assertStatus(200)
->assertJsonFragment(['id' => $bandId]);
$this->deleteJson("/api/bands/{$bandId}")
->assertStatus(204);
}
public function test_non_admin_cannot_create_band(): void
{
$this->actingAsUser();
$this->postJson('/api/bands', [
'name' => '144 MHz',
'order' => 1,
'edi_band_begin' => 144000000,
'edi_band_end' => 146000000,
'has_power_category' => true,
])->assertStatus(403);
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace Tests\Feature\Catalog;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class CategoryControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_categories(): void
{
$category = $this->createCategory();
$response = $this->getJson('/api/categories');
$response->assertStatus(200)
->assertJsonFragment(['id' => $category->id]);
}
public function test_show_returns_category(): void
{
$category = $this->createCategory();
$response = $this->getJson("/api/categories/{$category->id}");
$response->assertStatus(200)
->assertJsonFragment(['id' => $category->id]);
}
public function test_admin_can_create_update_and_delete_category(): void
{
$this->actingAsAdmin();
$createResponse = $this->postJson('/api/categories', [
'name' => 'CAT-A',
'order' => 1,
]);
$createResponse->assertStatus(201);
$categoryId = $createResponse->json('id');
$updateResponse = $this->putJson("/api/categories/{$categoryId}", [
'name' => 'CAT-B',
'order' => 2,
]);
$updateResponse->assertStatus(200)
->assertJsonFragment(['id' => $categoryId]);
$this->deleteJson("/api/categories/{$categoryId}")
->assertStatus(204);
}
public function test_non_admin_cannot_create_category(): void
{
$this->actingAsUser();
$this->postJson('/api/categories', [
'name' => 'CAT-A',
'order' => 1,
])->assertStatus(403);
}
}

View File

@@ -0,0 +1,100 @@
<?php
namespace Tests\Feature\Catalog;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ContestParameterControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_contest_parameters(): void
{
$item = $this->createContestParameter();
$response = $this->getJson('/api/contest-parameters');
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_show_returns_contest_parameter(): void
{
$item = $this->createContestParameter();
$response = $this->getJson("/api/contest-parameters/{$item->id}");
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_admin_can_create_update_and_delete_contest_parameter(): void
{
$this->actingAsAdmin();
$contest = $this->createContest();
$createResponse = $this->postJson('/api/contest-parameters', [
'contest_id' => $contest->id,
'log_type' => 'STANDARD',
'ignore_slash_part' => true,
'ignore_third_part' => true,
'letters_in_rst' => true,
'discard_qso_rec_diff_call' => true,
'discard_qso_sent_diff_call' => false,
'discard_qso_rec_diff_rst' => true,
'discard_qso_sent_diff_rst' => false,
'discard_qso_rec_diff_code' => true,
'discard_qso_sent_diff_code' => false,
'unique_qso' => true,
'time_tolerance' => 600,
]);
$createResponse->assertStatus(201);
$itemId = $createResponse->json('id');
$updateResponse = $this->putJson("/api/contest-parameters/{$itemId}", [
'contest_id' => $contest->id,
'log_type' => 'CHECK',
'ignore_slash_part' => false,
'ignore_third_part' => true,
'letters_in_rst' => false,
'discard_qso_rec_diff_call' => true,
'discard_qso_sent_diff_call' => false,
'discard_qso_rec_diff_rst' => true,
'discard_qso_sent_diff_rst' => false,
'discard_qso_rec_diff_code' => true,
'discard_qso_sent_diff_code' => false,
'unique_qso' => false,
'time_tolerance' => 300,
]);
$updateResponse->assertStatus(200)
->assertJsonFragment(['id' => $itemId]);
$this->deleteJson("/api/contest-parameters/{$itemId}")
->assertStatus(204);
}
public function test_non_admin_cannot_create_contest_parameter(): void
{
$this->actingAsUser();
$contest = $this->createContest();
$this->postJson('/api/contest-parameters', [
'contest_id' => $contest->id,
'log_type' => 'STANDARD',
'ignore_slash_part' => true,
'ignore_third_part' => true,
'letters_in_rst' => true,
'discard_qso_rec_diff_call' => true,
'discard_qso_sent_diff_call' => false,
'discard_qso_rec_diff_rst' => true,
'discard_qso_sent_diff_rst' => false,
'discard_qso_rec_diff_code' => true,
'discard_qso_sent_diff_code' => false,
'unique_qso' => true,
'time_tolerance' => 600,
])->assertStatus(403);
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace Tests\Feature\Catalog;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class CountryWwlControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_country_wwl_records(): void
{
$item = $this->createCountryWwl();
$response = $this->getJson('/api/countries-wwl');
$response->assertStatus(200)
->assertJsonFragment([
'country_name' => $item->country_name,
'wwl' => $item->wwl,
]);
}
public function test_admin_can_create_country_wwl(): void
{
$this->actingAsAdmin();
$createResponse = $this->postJson('/api/countries-wwl', [
'country_name' => 'Test Country',
'wwl' => 'AA00',
]);
$createResponse->assertStatus(201);
}
public function test_non_admin_cannot_create_country_wwl(): void
{
$this->actingAsUser();
$this->postJson('/api/countries-wwl', [
'country_name' => 'Test Country',
'wwl' => 'AA00',
])->assertStatus(403);
}
}

View File

@@ -0,0 +1,94 @@
<?php
namespace Tests\Feature\Catalog;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class CtyControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_cty_records(): void
{
$item = $this->createCty();
$response = $this->getJson('/api/cty');
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_show_returns_cty_record(): void
{
$item = $this->createCty();
$response = $this->getJson("/api/cty/{$item->id}");
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_admin_can_create_update_and_delete_cty_record(): void
{
$this->actingAsAdmin();
$createResponse = $this->postJson('/api/cty', [
'country_name' => 'Test Country',
'dxcc' => 999,
'cq_zone' => 10,
'itu_zone' => 20,
'continent' => 'EU',
'latitude' => 10.0,
'longitude' => 20.0,
'time_offset' => 1.0,
'prefix' => 'TST',
'prefix_norm' => 'TST',
'precise' => true,
'source' => 'test',
]);
$createResponse->assertStatus(201);
$itemId = $createResponse->json('id');
$updateResponse = $this->putJson("/api/cty/{$itemId}", [
'country_name' => 'Test Country 2',
'dxcc' => 999,
'cq_zone' => 10,
'itu_zone' => 20,
'continent' => 'EU',
'latitude' => 10.0,
'longitude' => 20.0,
'time_offset' => 1.0,
'prefix' => 'TST2',
'prefix_norm' => 'TST2',
'precise' => false,
'source' => 'test',
]);
$updateResponse->assertStatus(200)
->assertJsonFragment(['id' => $itemId]);
$this->deleteJson("/api/cty/{$itemId}")
->assertStatus(204);
}
public function test_non_admin_cannot_create_cty_record(): void
{
$this->actingAsUser();
$this->postJson('/api/cty', [
'country_name' => 'Test Country',
'dxcc' => 999,
'cq_zone' => 10,
'itu_zone' => 20,
'continent' => 'EU',
'latitude' => 10.0,
'longitude' => 20.0,
'time_offset' => 1.0,
'prefix' => 'TST',
'precise' => true,
'source' => 'test',
])->assertStatus(403);
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace Tests\Feature\Catalog;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class EdiBandControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_edi_bands(): void
{
$item = $this->createEdiBand();
$response = $this->getJson('/api/edi-bands');
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_show_returns_edi_band(): void
{
$item = $this->createEdiBand();
$response = $this->getJson("/api/edi-bands/{$item->id}");
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_admin_can_create_update_and_delete_edi_band(): void
{
$this->actingAsAdmin();
$createResponse = $this->postJson('/api/edi-bands', [
'value' => 'EDI-144',
]);
$createResponse->assertStatus(201);
$itemId = $createResponse->json('id');
$updateResponse = $this->putJson("/api/edi-bands/{$itemId}", [
'value' => 'EDI-432',
]);
$updateResponse->assertStatus(200)
->assertJsonFragment(['id' => $itemId]);
$this->deleteJson("/api/edi-bands/{$itemId}")
->assertStatus(204);
}
public function test_non_admin_cannot_create_edi_band(): void
{
$this->actingAsUser();
$this->postJson('/api/edi-bands', [
'value' => 'EDI-144',
])->assertStatus(403);
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace Tests\Feature\Catalog;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class EdiCategoryControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_edi_categories(): void
{
$item = $this->createEdiCategory();
$response = $this->getJson('/api/edi-categories');
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_show_returns_edi_category(): void
{
$item = $this->createEdiCategory();
$response = $this->getJson("/api/edi-categories/{$item->id}");
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_admin_can_create_update_and_delete_edi_category(): void
{
$this->actingAsAdmin();
$createResponse = $this->postJson('/api/edi-categories', [
'value' => 'EDI-CAT-A',
]);
$createResponse->assertStatus(201);
$itemId = $createResponse->json('id');
$updateResponse = $this->putJson("/api/edi-categories/{$itemId}", [
'value' => 'EDI-CAT-B',
]);
$updateResponse->assertStatus(200)
->assertJsonFragment(['id' => $itemId]);
$this->deleteJson("/api/edi-categories/{$itemId}")
->assertStatus(204);
}
public function test_non_admin_cannot_create_edi_category(): void
{
$this->actingAsUser();
$this->postJson('/api/edi-categories', [
'value' => 'EDI-CAT-A',
])->assertStatus(403);
}
}

View File

@@ -0,0 +1,76 @@
<?php
namespace Tests\Feature\Catalog;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class EvaluationRuleSetControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_rule_sets(): void
{
$item = $this->createRuleSet();
$response = $this->getJson('/api/evaluation-rule-sets');
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_show_returns_rule_set(): void
{
$item = $this->createRuleSet();
$response = $this->getJson("/api/evaluation-rule-sets/{$item->id}");
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_admin_can_create_update_and_delete_rule_set(): void
{
$this->actingAsAdmin();
$createResponse = $this->postJson('/api/evaluation-rule-sets', [
'name' => 'Test ruleset',
'code' => 'TEST_RULES',
'scoring_mode' => 'DISTANCE',
'multiplier_type' => 'WWL',
'dup_qso_policy' => 'ZERO_POINTS',
'nil_qso_policy' => 'ZERO_POINTS',
'busted_call_policy' => 'ZERO_POINTS',
'busted_exchange_policy' => 'ZERO_POINTS',
]);
$createResponse->assertStatus(201);
$itemId = $createResponse->json('id');
$updateResponse = $this->putJson("/api/evaluation-rule-sets/{$itemId}", [
'name' => 'Updated ruleset',
]);
$updateResponse->assertStatus(200)
->assertJsonFragment(['id' => $itemId]);
$this->deleteJson("/api/evaluation-rule-sets/{$itemId}")
->assertStatus(204);
}
public function test_non_admin_cannot_create_rule_set(): void
{
$this->actingAsUser();
$this->postJson('/api/evaluation-rule-sets', [
'name' => 'Test ruleset',
'code' => 'TEST_RULES',
'scoring_mode' => 'DISTANCE',
'multiplier_type' => 'WWL',
'dup_qso_policy' => 'ZERO_POINTS',
'nil_qso_policy' => 'ZERO_POINTS',
'busted_call_policy' => 'ZERO_POINTS',
'busted_exchange_policy' => 'ZERO_POINTS',
])->assertStatus(403);
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace Tests\Feature\Catalog;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class PowerCategoryControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_power_categories(): void
{
$item = $this->createPowerCategory();
$response = $this->getJson('/api/power-categories');
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_show_returns_power_category(): void
{
$item = $this->createPowerCategory();
$response = $this->getJson("/api/power-categories/{$item->id}");
$response->assertStatus(200)
->assertJsonFragment(['id' => $item->id]);
}
public function test_admin_can_create_update_and_delete_power_category(): void
{
$this->actingAsAdmin();
$createResponse = $this->postJson('/api/power-categories', [
'name' => 'PWR-A',
'order' => 1,
'power_level' => 100,
]);
$createResponse->assertStatus(201);
$itemId = $createResponse->json('id');
$updateResponse = $this->putJson("/api/power-categories/{$itemId}", [
'name' => 'PWR-B',
'order' => 2,
'power_level' => 200,
]);
$updateResponse->assertStatus(200)
->assertJsonFragment(['id' => $itemId]);
$this->deleteJson("/api/power-categories/{$itemId}")
->assertStatus(204);
}
public function test_non_admin_cannot_create_power_category(): void
{
$this->actingAsUser();
$this->postJson('/api/power-categories', [
'name' => 'PWR-A',
'order' => 1,
'power_level' => 100,
])->assertStatus(403);
}
}