new: pkg: add test cases to back-end w/ real database connection in it #10
This commit is contained in:
51
tests/Factory/GamerFactory.php
Normal file
51
tests/Factory/GamerFactory.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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\Gamer;
|
||||
use DateTime;
|
||||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
|
||||
|
||||
/**
|
||||
* Class GamerFactory
|
||||
*
|
||||
* @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<Gamer>
|
||||
*/
|
||||
class GamerFactory extends PersistentProxyObjectFactory
|
||||
{
|
||||
protected function defaults(): array
|
||||
{
|
||||
return [
|
||||
'userName' => self::faker()->userName(),
|
||||
'ip' => self::faker()->ipv4(),
|
||||
'country' => self::faker()->countryCode(),
|
||||
'userAgent' => self::faker()->userAgent(),
|
||||
'connTimestamp' => new DateTime(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function class(): string
|
||||
{
|
||||
return Gamer::class;
|
||||
}
|
||||
|
||||
public function anonymous(): self
|
||||
{
|
||||
return $this->with(['userName' => sprintf('Guest_%d', self::faker()->randomNumber(5))]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user