109 lines
2.9 KiB
PHP
109 lines
2.9 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\PlayedGame;
|
|
use DateTime;
|
|
use Symfony\Component\Uid\Uuid;
|
|
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
|
|
|
|
/**
|
|
* Class PlayedGameFactory
|
|
*
|
|
* @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<PlayedGame>
|
|
*/
|
|
class PlayedGameFactory extends PersistentProxyObjectFactory
|
|
{
|
|
protected function defaults(): array
|
|
{
|
|
return [
|
|
'uuid' => Uuid::v4(),
|
|
'gameAssoc' => self::faker()->uuid(),
|
|
'redPoints' => self::faker()->numberBetween(0, 51),
|
|
'bluePoints' => self::faker()->numberBetween(0, 51),
|
|
'redExplodedBomb' => false,
|
|
'blueExplodedBomb' => false,
|
|
'resign' => null,
|
|
'redBonusPoints' => self::faker()->randomFloat(2, 0, 100),
|
|
'blueBonusPoints' => self::faker()->randomFloat(2, 0, 100),
|
|
'redBonusStats' => null,
|
|
'blueBonusStats' => null,
|
|
'created' => new DateTime(),
|
|
'updated' => new DateTime(),
|
|
];
|
|
}
|
|
|
|
public static function class(): string
|
|
{
|
|
return PlayedGame::class;
|
|
}
|
|
|
|
public function withRegisteredPlayers(): self
|
|
{
|
|
return $this->with([
|
|
'red' => UserFactory::new(),
|
|
'blue' => UserFactory::new(),
|
|
]);
|
|
}
|
|
|
|
public function withAnonymousPlayers(): self
|
|
{
|
|
return $this->with([
|
|
'redAnon' => GamerFactory::new(),
|
|
'blueAnon' => GamerFactory::new(),
|
|
]);
|
|
}
|
|
|
|
public function withMixedPlayers(): self
|
|
{
|
|
return $this->with([
|
|
'red' => UserFactory::new(),
|
|
'blueAnon' => GamerFactory::new(),
|
|
]);
|
|
}
|
|
|
|
public function finished(): self
|
|
{
|
|
return $this->with([
|
|
'redPoints' => 26,
|
|
'bluePoints' => 25,
|
|
]);
|
|
}
|
|
|
|
public function redWins(): self
|
|
{
|
|
return $this->with([
|
|
'redPoints' => 26,
|
|
'bluePoints' => self::faker()->numberBetween(0, 25),
|
|
]);
|
|
}
|
|
|
|
public function blueWins(): self
|
|
{
|
|
return $this->with([
|
|
'redPoints' => self::faker()->numberBetween(0, 25),
|
|
'bluePoints' => 26,
|
|
]);
|
|
}
|
|
|
|
public function resigned(string $player): self
|
|
{
|
|
return $this->with(['resign' => $player]);
|
|
}
|
|
}
|