57 lines
2.1 KiB
PHP
57 lines
2.1 KiB
PHP
<?php
|
|
|
|
use App\Models\Operator;
|
|
use App\Services\Secrets\SecretVault;
|
|
use App\Support\OperatingMode;
|
|
use App\Support\Readiness;
|
|
use App\Support\Readiness\Check;
|
|
use App\Support\Settings;
|
|
|
|
/**
|
|
* Die Bereitschaftsprüfung berichtet, was fehlt — und sagt dazu, was
|
|
* kaputtgeht. Ein Feldname allein ist keine Auskunft: „vat_id fehlt" sagt
|
|
* nichts, „der Kunde bekommt keinen Beleg" sagt alles.
|
|
*/
|
|
function checkFor(string $key): ?Check
|
|
{
|
|
return collect(Readiness::all())->firstWhere('key', $key);
|
|
}
|
|
|
|
it('reports the stripe key of the active mode as missing', function () {
|
|
OperatingMode::set(OperatingMode::Test);
|
|
|
|
expect(checkFor('billing.stripe_secret')->satisfied)->toBeFalse();
|
|
expect(checkFor('billing.stripe_secret')->severity)->toBe(Check::SEVERITY_BLOCKING);
|
|
});
|
|
|
|
it('reports it as satisfied once the key of that mode is stored', function () {
|
|
OperatingMode::set(OperatingMode::Test);
|
|
app(SecretVault::class)->put('stripe.secret', 'sk_test_x', Operator::factory()->create(), OperatingMode::Test);
|
|
|
|
expect(checkFor('billing.stripe_secret')->satisfied)->toBeTrue();
|
|
});
|
|
|
|
it('does not accept a live key as proof while the test mode is active', function () {
|
|
// Sonst meldete die Seite Bereitschaft für einen Modus, in dem die Kasse
|
|
// sperrt — die Seite widerspräche der Sperre aus Task 5.
|
|
OperatingMode::set(OperatingMode::Test);
|
|
app(SecretVault::class)->put('stripe.secret', 'sk_live_x', Operator::factory()->create(), OperatingMode::Live);
|
|
|
|
expect(checkFor('billing.stripe_secret')->satisfied)->toBeFalse();
|
|
});
|
|
|
|
it('reports incomplete company details without repeating the list', function () {
|
|
Settings::forget('company.name');
|
|
|
|
expect(checkFor('billing.company_details')->satisfied)->toBeFalse();
|
|
});
|
|
|
|
it('names what breaks, not just what is missing', function () {
|
|
expect(checkFor('billing.company_details')->breaks)->not->toBe('');
|
|
});
|
|
|
|
it('says the installation is not ready while something blocking is open', function () {
|
|
expect(Readiness::isReady())->toBeFalse();
|
|
expect(Readiness::blocking())->not->toBeEmpty();
|
|
});
|