31 lines
1.6 KiB
PHP
31 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Services\ApprovedAdministrativeBoundaries;
|
|
use Tests\TestCase;
|
|
|
|
/** Runs in the normal delivery unit suite, without database or external services. */
|
|
final class ApprovedAdministrativeBoundariesTest extends TestCase
|
|
{
|
|
public function test_public_scope_keeps_the_accepted_identity_and_refuses_changed_or_new_internal_shapes(): void
|
|
{
|
|
$approved = new ApprovedAdministrativeBoundaries;
|
|
$items = $approved->snapshots();
|
|
$this->assertCount(408, $items);
|
|
$item = reset($items);
|
|
$this->assertTrue($approved->allows($item['id'], $item['territory_id'], $item['geometry_sha256'], $item['properties_sha256']));
|
|
$this->assertFalse($approved->allows('00000000-0000-0000-0000-000000000000', $item['territory_id'], $item['geometry_sha256'], $item['properties_sha256']));
|
|
$this->assertFalse($approved->allows($item['id'], '00000000-0000-0000-0000-000000000000', $item['geometry_sha256'], $item['properties_sha256']));
|
|
$this->assertFalse($approved->allows($item['id'], $item['territory_id'], str_repeat('0', 64), $item['properties_sha256']));
|
|
$this->assertFalse($approved->allows($item['id'], $item['territory_id'], $item['geometry_sha256'], str_repeat('0', 64)));
|
|
}
|
|
|
|
public function test_the_public_scope_keeps_the_accepted_edition_and_unique_territories(): void
|
|
{
|
|
$items = (new ApprovedAdministrativeBoundaries)->snapshots();
|
|
$this->assertCount(408, array_unique(array_column($items, 'territory_id')));
|
|
$this->assertSame(['2019-06-07'], array_values(array_unique(array_column($items, 'source_version'))));
|
|
}
|
|
}
|