Skip to content

Commit

Permalink
Added BC property strBadge (strTeamBadge) to Entry/Standing entity
Browse files Browse the repository at this point in the history
  • Loading branch information
nkl-kst committed Jul 2, 2024
1 parent 7bc5842 commit 19248f4
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/Entity/Table/Standing.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@
namespace NklKst\TheSportsDb\Entity\Table;

use DateTime;
use NklKst\TheSportsDb\Entity\BcPropertiesTrait;

/**
* @property ?string $strTeamBadge
*/
class Standing
{
use BcPropertiesTrait;

private const BC_PROPERTIES = [
'strTeamBadge' => 'strBadge',
];

public int $idStanding;
public int $intRank;
public int $idTeam;
public string $strTeam;
public ?string $strTeamBadge;
public ?string $strBadge;
public int $idLeague;
public string $strLeague;
public string $strSeason;
Expand Down
7 changes: 6 additions & 1 deletion test/unit/BC/BcTestUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ public static function checkBcProperty(object $entity, string $bcProperty): void

// TODO: How to check if PHP Deprecation has been raised (https://github.com/sebastianbergmann/phpunit/issues/5062#issuecomment-1420379762)?
$docComment = (new ReflectionClass($entity))->getDocComment() ?: 'no comment';
$reflClass = (new ReflectionClass($entity));
if ($parentReflClass = $reflClass->getParentClass()) {
$reflClass = $parentReflClass;
}

$docComment = $reflClass->getDocComment() ?: 'no comment';
TestCase::assertMatchesRegularExpression(
sprintf('/@property .* \$%s/', $bcProperty),
$docComment,
Expand Down
55 changes: 55 additions & 0 deletions test/unit/BC/StandingBcTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace NklKst\TheSportsDb\BC;

use Exception;
use JsonMapper;
use NklKst\TheSportsDb\Entity\Table\Entry;
use NklKst\TheSportsDb\Serializer\Table\EntrySerializer;
use PHPUnit\Framework\TestCase;

/**
* @coversNothing
*/
class StandingBcTest extends TestCase
{
private Entry $entry;

/**
* @throws Exception
*/
protected function setUp(): void
{
$entrySerializer = new EntrySerializer(new JsonMapper());

$tableJson = <<<'JSON'
{
"table": [
{
"strBadge": "strTeamBadge"
}
]
}
JSON;

$this->entry = $entrySerializer->serialize($tableJson)[0];
}

/**
* @return array<string[]>
*/
public static function provideBcProperties(): array
{
return [
['strTeamBadge'],
];
}

/**
* @dataProvider provideBcProperties
*/
public function testBcProperties(string $bcProperty): void
{
BcTestUtils::checkBcProperty($this->entry, $bcProperty);
}
}

0 comments on commit 19248f4

Please sign in to comment.