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,26 @@
<?php
namespace Modules\Platform\tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Modules\Company\Models\Company;
use Modules\Platform\app\Models\LicenseKey;
use Tests\TestCase;
class LicenseKeyTest extends TestCase
{
use RefreshDatabase;
public function test_license_key_is_hashed_and_not_stored_plain(): void
{
$company = Company::create(['name' => 'Tenant A', 'slug' => 'tenant-a']);
$plainKey = LicenseKey::issueFor($company, 'Production licence', 'enterprise', 50);
$license = LicenseKey::firstOrFail();
$this->assertStringStartsWith('WMS-', $plainKey);
$this->assertNotSame($plainKey, $license->key_hash);
$this->assertSame(hash('sha256', $plainKey), $license->key_hash);
$this->assertTrue($company->fresh()->hasActiveLicense());
}
}
@@ -0,0 +1,50 @@
<?php
namespace Modules\Platform\tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Modules\Company\Models\Company;
use Tests\TestCase;
class PlatformAccessTest extends TestCase
{
use RefreshDatabase;
public function test_mpba_platform_admin_can_access_admin_dashboard_without_licence(): void
{
$company = Company::create([
'name' => 'MPBA Limited',
'slug' => 'mpba-limited',
'is_system_company' => true,
'status' => 'active',
]);
$user = User::factory()->create([
'company_id' => $company->id,
'email' => 'mark.gregory@mpba.co.uk',
'is_platform_admin' => true,
'is_company_admin' => true,
]);
$this->actingAs($user)
->get('/admin')
->assertOk()
->assertSee('Platform', false);
}
public function test_non_system_company_requires_license(): void
{
$company = Company::create([
'name' => 'Customer Limited',
'slug' => 'customer-limited',
'status' => 'active',
]);
$user = User::factory()->create(['company_id' => $company->id]);
$this->actingAs($user)
->get('/dashboard')
->assertStatus(402);
}
}