Repo rebuild

This commit is contained in:
Mark Gregory
2026-09-15 12:33:28 +01:00
commit be28c4feec
5629 changed files with 317074 additions and 0 deletions
@@ -0,0 +1,38 @@
<?php
namespace Modules\Countries\Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Route;
use Modules\Countries\Database\Seeders\IsoCountriesSeeder;
use Modules\Countries\Models\Country;
use Tests\TestCase;
class CountriesModuleTest extends TestCase
{
use RefreshDatabase;
public function test_countries_module_reference_pages_are_registered(): void
{
$this->assertTrue(Route::has('countries.currencies.index'));
$this->assertTrue(Route::has('countries.languages.index'));
$this->assertTrue(Route::has('countries.scripts.index'));
$this->assertTrue(Route::has('countries.locodes.index'));
}
/** @test */
public function it_seeds_iso_countries(): void
{
$this->seed(IsoCountriesSeeder::class);
$this->assertDatabaseHas('countries', ['alpha2' => 'GB', 'alpha3' => 'GBR', 'numeric' => '826']);
}
/** @test */
public function it_can_update_country_support_settings(): void
{
$this->seed(IsoCountriesSeeder::class);
$country = Country::query()->where('alpha2', 'GB')->firstOrFail();
$country->update(['display_name' => 'United Kingdom', 'is_active' => false, 'sort_order' => 1]);
$this->assertDatabaseHas('countries', ['alpha2' => 'GB', 'display_name' => 'United Kingdom', 'is_active' => false, 'sort_order' => 1]);
}
}
@@ -0,0 +1,77 @@
<?php
namespace Modules\Countries\Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Modules\Countries\Database\Seeders\CountriesDatabaseSeeder;
use Modules\Countries\Rules\ValidIso3166CountryCode;
use Modules\Countries\Rules\ValidIso3166SubdivisionCode;
use Tests\TestCase;
class Iso3166SupportTest extends TestCase
{
use RefreshDatabase;
public function test_it_seeds_iso_3166_country_and_subdivision_reference_data(): void
{
$this->seed(CountriesDatabaseSeeder::class);
$this->assertDatabaseHas('countries', [
'alpha2' => 'GB',
'alpha3' => 'GBR',
'numeric' => '826',
'iso_status' => 'official',
]);
$this->assertDatabaseHas('country_subdivisions', [
'country_alpha2' => 'GB',
'code' => 'GB-ENG',
'name' => 'England',
]);
}
public function test_it_resolves_country_by_any_iso_3166_1_code(): void
{
$this->seed(CountriesDatabaseSeeder::class);
$this->getJson('/api/countries/resolve/GBR')
->assertOk()
->assertJsonPath('data.alpha2', 'GB');
$this->getJson('/api/countries/resolve/826')
->assertOk()
->assertJsonPath('data.alpha3', 'GBR');
}
public function test_it_lists_iso_3166_2_subdivisions_for_country(): void
{
$this->seed(CountriesDatabaseSeeder::class);
$this->getJson('/api/countries/GB/subdivisions')
->assertOk()
->assertJsonFragment(['code' => 'GB-ENG'])
->assertJsonFragment(['code' => 'GB-SCT']);
}
public function test_validation_rules_support_country_and_subdivision_codes(): void
{
$this->seed(CountriesDatabaseSeeder::class);
$countryRule = new ValidIso3166CountryCode(activeOnly: true, format: 'any');
$subdivisionRule = new ValidIso3166SubdivisionCode(activeOnly: true);
$countryFailed = false;
$subdivisionFailed = false;
$countryRule->validate('country', 'GBR', function () use (&$countryFailed): void {
$countryFailed = true;
});
$subdivisionRule->validate('subdivision', 'GB-ENG', function () use (&$subdivisionFailed): void {
$subdivisionFailed = true;
});
$this->assertFalse($countryFailed);
$this->assertFalse($subdivisionFailed);
}
}