This commit is contained in:
Matt Young 2024-06-30 22:59:33 -05:00
parent 3acc478143
commit d12f2f2336
3 changed files with 53 additions and 10 deletions

View File

@ -27,6 +27,7 @@ class InvoiceDataServiceProvider extends ServiceProvider
*/
public function boot(): void
{
if (auditionSetting('fee_structure')) {
$this->app->singleton(InvoiceDataService::class, function ($app) {
return match (auditionSetting('fee_structure')) {
'oneFeePerEntry' => new InvoiceOneFeePerEntry($app->make(EntryService::class)),
@ -35,4 +36,5 @@ class InvoiceDataServiceProvider extends ServiceProvider
};
});
}
}
}

View File

@ -23,7 +23,11 @@ class UserFactory extends Factory
*/
public function definition(): array
{
$judingPrefPossibilities = ['woodwinds','flute','clarinet','saxophones', 'low clarinets','oboe','bassoon','double reeds','brass','low brass','trumpet','trombone','horn','tuba','euphonium','percussion'];
$judingPrefPossibilities = [
'woodwinds', 'flute', 'clarinet', 'saxophones', 'low clarinets', 'oboe', 'bassoon', 'double reeds', 'brass',
'low brass', 'trumpet', 'trombone', 'horn', 'tuba', 'euphonium', 'percussion',
];
return [
'first_name' => fake()->firstName(),
'last_name' => fake()->lastName(),
@ -46,4 +50,18 @@ class UserFactory extends Factory
'email_verified_at' => null,
]);
}
public function admin(): static
{
return $this->state(fn (array $attributes) => [
'is_admin' => 1,
]);
}
public function tab(): static
{
return $this->state(fn (array $attributes) => [
'is_tab' => 1,
]);
}
}

View File

@ -1,5 +1,6 @@
<?php
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use function Pest\Laravel\get;
@ -16,7 +17,7 @@ it('shows appropriate screens when not logged in', function () {
]);
});
it('shows a registration page', function () {
it('shows a registration page only if not logged in', function () {
// Act & Assert
get('/register')
->assertStatus(200)
@ -24,13 +25,35 @@ it('shows a registration page', function () {
'Registration Code',
'Email address',
]);
$user = User::factory()->create();
$this->actingAs($user);
get('/register')
->assertStatus(302)
->assertRedirect(route('dashboard'));
});
it('shows a login page', function () {
it('shows a login page only if not logged in', function () {
get('/login')
->assertStatus(200)
->assertSeeText([
'Log In',
'Click here to register',
]);
$user = User::factory()->create();
$this->actingAs($user);
get('/register')
->assertStatus(302)
->assertRedirect(route('dashboard'));
});
it('shows dashboard only if logged in', function () {
get(route('dashboard'))
->assertStatus(302)
->assertRedirect(route('home'));
$user = User::factory()->create();
$this->actingAs($user);
get(route('dashboard'))
->assertStatus(200)
->assertSeeText('My School')
->assertSeeText('Dashboard');
});