Added tests with titles

This commit is contained in:
Jeroen De Meerleer 2023-01-14 16:08:44 +01:00
parent 3532386aef
commit bef365665e
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
7 changed files with 27 additions and 9 deletions

Binary file not shown.

View File

@ -494,7 +494,7 @@ class Pairtwo6 implements ReaderInterface
break;
case 0:
default:
$title = Title::NONE;
$title = NULL;
break;
}
$player->Title = $title;

View File

@ -164,7 +164,7 @@ class Swar4 implements ReaderInterface
case TournamentSystem::CLOSED:
case TournamentSystem::SWISS:
default:
$firstElement = new Tiebreak(Tiebreak::POINTS);
$firstElement = Tiebreak::POINTS;
}
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
@ -382,7 +382,7 @@ class Swar4 implements ReaderInterface
$tiebreak = Tiebreak::BLACK_WIN;
break;
}
$tiebreaks[] = new Tiebreak($tiebreak);
$tiebreaks[] = $tiebreak;
}
$this->Tournament->Tiebreaks = $tiebreaks;
@ -439,7 +439,7 @@ class Swar4 implements ReaderInterface
$gender = Gender::NEUTRAL;
break;
}
$player->Gender = new Gender($gender);
$player->Gender = $gender;
$player->Nation = $this->readData('String', $swshandle);
$player->setId('Nation', $this->readData('Int', $swshandle));
@ -480,10 +480,10 @@ class Swar4 implements ReaderInterface
break;
case 0:
default:
$title = Title::NONE;
$title = NULL;
break;
}
$player->Title = new Title($title);
$player->Title = $title;
$player->setId('Club', $this->readData('Int', $swshandle));
$player->ClubName = $this->readData('String', $swshandle);
@ -562,7 +562,7 @@ class Swar4 implements ReaderInterface
if (array_search($this->Tournament->Pairing[ $ptn ][ 'table' ], [16383, 8191]) !== false) {
$result = Result::ABSENT;
}
$pairing->Result = new Result($result);
$pairing->Result = $result;
switch ($this->Tournament->Pairing[ $ptn ][ 'color' ]) {
case 4294967295:
@ -576,7 +576,7 @@ class Swar4 implements ReaderInterface
$color = Color::NONE;
break;
}
$pairing->Color = new Color($color);
$pairing->Color = $color;
$pairing->Board = $this->Tournament->Pairing[ $ptn ][ 'table' ];
$ptn++;

View File

@ -500,7 +500,7 @@ class Swar5 implements ReaderInterface
break;
case 0:
default:
$title = Title::NONE;
$title = NULL;
break;
}
$player->Title = $title;

View File

@ -41,4 +41,9 @@ class Pairtwo6Test extends TestCase
{
$this->assertCount(7, $this->testobject->Tournament->Rounds);
}
public function testPlayerHas7Pairings(): void
{
$this->assertCount(7, $this->testobject->Tournament->Players[0]->Pairings);
}
}

View File

@ -3,6 +3,8 @@
namespace Blackbirdchess\Tests\Service\Import\Readers;
use Blackbirdchess\Service\Import\Readers\Swar5;
use Blackbirdchess\Service\Results\Enums\Title;
use Blackbirdchess\Service\Results\Player;
use PHPUnit\Framework\TestCase;
class Swar5Test extends TestCase
@ -41,4 +43,15 @@ class Swar5Test extends TestCase
{
$this->assertCount(7, $this->testobject->Tournament->Rounds);
}
public function testPlayerHas7Pairings(): void
{
$this->assertCount(7, $this->testobject->Tournament->Players[0]->Pairings);
}
public function testPlayerHasTitle(): void
{
$player1 = Player::PlayersByName('Player 1', $this->testobject->Tournament)[0];
$this->assertInstanceOf(Title::class, $player1->Title);
}
}