Private
Public Access
1
0
Files
MineSeeker/tests/Dto/ProfileChartDataDtoTest.php

90 lines
2.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\Dto;
use App\Dto\ProfileChartDataDto;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
/**
* Class ProfileChartDataDtoTest
*
* @package App\Tests\Dto
* @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.
*/
#[TestDox('Profile Chart Data Dto')]
class ProfileChartDataDtoTest extends TestCase
{
#[Test]
#[TestDox('Json serialize returns all properties')]
public function jsonSerializeReturnsAllProperties(): void
{
$months = ['Jan', 'Feb', 'Mar'];
$wins = [5, 8, 10];
$losses = [2, 3, 4];
$draws = [1, 0, 1];
$recentGames = [
['id' => 1, 'result' => 'win'],
['id' => 2, 'result' => 'loss'],
];
$dto = new ProfileChartDataDto(
months: $months,
wins: $wins,
losses: $losses,
draws: $draws,
pieWins: 23,
pieLosses: 9,
pieDraws: 2,
recentGames: $recentGames,
);
$json = $dto->jsonSerialize();
$this->assertSame($months, $json['months']);
$this->assertSame($wins, $json['wins']);
$this->assertSame($losses, $json['losses']);
$this->assertSame($draws, $json['draws']);
$this->assertSame(23, $json['pieWins']);
$this->assertSame(9, $json['pieLosses']);
$this->assertSame(2, $json['pieDraws']);
$this->assertSame($recentGames, $json['recentGames']);
}
#[Test]
#[TestDox('Constructor with empty arrays')]
public function constructorWithEmptyArrays(): void
{
$dto = new ProfileChartDataDto(
months: [],
wins: [],
losses: [],
draws: [],
pieWins: 0,
pieLosses: 0,
pieDraws: 0,
recentGames: [],
);
$json = $dto->jsonSerialize();
$this->assertSame([], $json['months']);
$this->assertSame([], $json['wins']);
$this->assertSame([], $json['recentGames']);
$this->assertSame(0, $json['pieWins']);
}
}