61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php declare(strict_types=1);
|
|
/**
|
|
* This file is part of the SplendidBear Websites' projects.
|
|
*
|
|
* Copyright (c) 2026 @ www.splendidbear.org
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace App\Tests\Factory;
|
|
|
|
use App\Entity\User;
|
|
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
|
|
|
|
/**
|
|
* Class UserFactory
|
|
*
|
|
* @package App\Tests\Factory
|
|
* @author Lang <https://www.splendidbear.org>
|
|
* @category Class
|
|
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html GNU Lesser General Public License
|
|
* @link www.splendidbear.org
|
|
* @since 2026. 04. 21.
|
|
*
|
|
* @extends PersistentProxyObjectFactory<User>
|
|
*/
|
|
class UserFactory extends PersistentProxyObjectFactory
|
|
{
|
|
protected function defaults(): array
|
|
{
|
|
return [
|
|
'username' => self::faker()->unique()->userName(),
|
|
'email' => self::faker()->unique()->safeEmail(),
|
|
'password' => 'hashedpassword',
|
|
'isVerified' => true,
|
|
'roles' => [],
|
|
];
|
|
}
|
|
|
|
public static function class(): string
|
|
{
|
|
return User::class;
|
|
}
|
|
|
|
public function withPassword(string $hashedPassword): self
|
|
{
|
|
return $this->with(['password' => $hashedPassword]);
|
|
}
|
|
|
|
public function unverified(): self
|
|
{
|
|
return $this->with(['isVerified' => false]);
|
|
}
|
|
|
|
public function withRoles(array $roles): self
|
|
{
|
|
return $this->with(['roles' => $roles]);
|
|
}
|
|
}
|