36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Models;
|
|
|
|
use App\Models\User;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class UserTest extends TestCase
|
|
{
|
|
public function test_model_metadata_is_converted(): void
|
|
{
|
|
$model = new User();
|
|
|
|
$this->assertSame('users', $model->getTable());
|
|
$this->assertSame('id', $model->getKeyName());
|
|
$this->assertSame(true, $model->timestamps);
|
|
$this->assertSame(["school_id", "firstname", "lastname", "gender", "cellphone", "email", "address_street", "apt", "city", "state", "zip", "accept_school_policy", "is_verified", "status", "is_suspended", "failed_attempts", "password", "created_at", "updated_at", "token", "account_id", "user_type", "semester", "school_year", "rfid_tag", "last_failed_at"], $model->getFillable());
|
|
}
|
|
|
|
public function test_model_class_loads(): void
|
|
{
|
|
$this->assertInstanceOf(User::class, new User());
|
|
}
|
|
|
|
public function test_password_mutator_preserves_pbkdf2_hashes(): void
|
|
{
|
|
$hash = pbkdf2_hash('secret-password');
|
|
|
|
$model = new User();
|
|
$model->password = $hash;
|
|
|
|
$this->assertSame($hash, $model->getAttributes()['password']);
|
|
$this->assertTrue(verify_stored_password('secret-password', $model->getAttributes()['password']));
|
|
}
|
|
}
|