Files
KanbanGit/tests/Feature/Auth/RegistrationTest.php
Twyco 598f8631f9
linter / quality (pull_request) Successful in 1m28s
tests / ci (8.4) (pull_request) Successful in 1m53s
Add profile avatar uploads
2026-06-24 13:55:27 +02:00

53 lines
1.4 KiB
PHP

<?php
namespace Tests\Feature\Auth;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Storage;
use Laravel\Fortify\Features;
use Tests\TestCase;
class RegistrationTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->skipUnlessFortifyFeature(Features::registration());
}
public function test_registration_screen_can_be_rendered()
{
$response = $this->get(route('register'));
$response->assertOk();
}
public function test_new_users_can_register()
{
Storage::fake('public');
$response = $this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'password',
'password_confirmation' => 'password',
]);
$this->assertAuthenticated();
$response->assertRedirect(route('dashboard', absolute: false));
$user = User::query()->where('email', 'test@example.com')->firstOrFail();
$this->assertTrue($user->avatar_is_generated);
$this->assertNotNull($user->avatar_color);
$this->assertNotNull($user->avatar_path);
Storage::disk('public')->assertExists($user->avatar_path);
$this->assertStringContainsString('TU', Storage::disk('public')->get($user->avatar_path));
}
}