fix tests auth: department_id error
Tests & Lint & Deploy to Railway / build (2.6.6, 20.x, 8.3) (push) Successful in 4m25s Details

This commit is contained in:
aslan 2024-05-29 13:40:28 +03:00
parent 01c96b5d45
commit 474a2ae4e1
9 changed files with 37 additions and 2 deletions

View File

@ -38,6 +38,7 @@ class RegisteredUserController extends Controller
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'department_id' => null,
'password' => Hash::make($request->password),
]);

View File

@ -16,7 +16,7 @@ class UserFactory extends Factory
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'department_id' => 1,
'department_id' => null,
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];

View File

@ -12,7 +12,7 @@ return new class extends Migration
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->foreignId('department_id')->constrained('departments');
$table->foreignId('department_id')->nullable()->constrained('departments');
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\Auth;
use App\Models\Department;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
@ -10,6 +11,11 @@ class AuthenticationTest extends TestCase
{
use RefreshDatabase;
public function setUp(): void
{
parent::setUp();
Department::factory()->create();
}
public function testLoginScreenCanBeRendered(): void
{
$response = $this->get('/login');

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\Auth;
use App\Models\Department;
use App\Models\User;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Testing\RefreshDatabase;
@ -13,6 +14,12 @@ class EmailVerificationTest extends TestCase
{
use RefreshDatabase;
public function setUp(): void
{
parent::setUp();
Department::factory()->create();
}
public function testEmailVerificationScreenCanBeRendered(): void
{
$user = User::factory()->unverified()->create();

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\Auth;
use App\Models\Department;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
@ -10,6 +11,11 @@ class PasswordConfirmationTest extends TestCase
{
use RefreshDatabase;
public function setUp(): void
{
parent::setUp();
Department::factory()->create();
}
public function testConfirmPasswordScreenCanBeRendered(): void
{
$user = User::factory()->create();

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\Auth;
use App\Models\Department;
use App\Models\User;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\RefreshDatabase;
@ -12,6 +13,12 @@ class PasswordResetTest extends TestCase
{
use RefreshDatabase;
public function setUp(): void
{
parent::setUp();
Department::factory()->create();
}
public function testResetPasswordLinkScreenCanBeRendered(): void
{
$response = $this->get('/forgot-password');

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\Auth;
use App\Models\Department;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
@ -11,6 +12,12 @@ class PasswordUpdateTest extends TestCase
{
use RefreshDatabase;
public function setUp(): void
{
parent::setUp();
Department::factory()->create();
}
public function testPasswordCanBeUpdated(): void
{
$user = User::factory()->create();

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\Auth;
use App\Models\Department;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;