Compare commits
2 Commits
bef365665e
...
b6c9be66cb
Author | SHA1 | Date | |
---|---|---|---|
b6c9be66cb | |||
c1db2253ce |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -494,7 +494,7 @@ class Pairtwo6 implements ReaderInterface
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
$title = Title::NONE;
|
||||
$title = NULL;
|
||||
break;
|
||||
}
|
||||
$player->Title = $title;
|
||||
|
@ -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++;
|
||||
|
@ -500,7 +500,7 @@ class Swar5 implements ReaderInterface
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
$title = Title::NONE;
|
||||
$title = NULL;
|
||||
break;
|
||||
}
|
||||
$player->Title = $title;
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace Blackbirdchess\Tests\Service\Import\Readers;
|
||||
|
||||
use Blackbirdchess\Service\Import\Readers\Pairtwo6;
|
||||
use Blackbirdchess\Service\Results\Enums\Title;
|
||||
use Blackbirdchess\Service\Results\Player;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Pairtwo6Test extends TestCase
|
||||
@ -12,7 +14,15 @@ class Pairtwo6Test extends TestCase
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->testfile = getcwd() . $this->testfile;
|
||||
$root = NULL;
|
||||
$directory = dirname(__FILE__);
|
||||
do {
|
||||
$directory = dirname($directory);
|
||||
$composer = $directory . '/composer.json';
|
||||
if(file_exists($composer)) $root = $directory;
|
||||
} while(is_null($root) && $directory != '/');
|
||||
|
||||
$this->testfile = $root . $this->testfile;
|
||||
$this->testobject = new Pairtwo6();
|
||||
$this->testobject->read($this->testfile);
|
||||
}
|
||||
@ -41,4 +51,21 @@ class Pairtwo6Test 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
|
||||
{
|
||||
$player = Player::PlayersByName('Player 1', $this->testobject->Tournament)[0];
|
||||
$this->assertInstanceOf(Title::class, $player->Title);
|
||||
}
|
||||
|
||||
public function testPlayerHasNoTitle(): void
|
||||
{
|
||||
$player = Player::PlayersByName('Player 3', $this->testobject->Tournament)[0];
|
||||
$this->assertNull($player->Title);
|
||||
}
|
||||
}
|
||||
|
@ -3,18 +3,28 @@
|
||||
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
|
||||
{
|
||||
private string $swarfile = '/res/Swar5-testfile.swar';
|
||||
private string $testfile = '/res/Swar5-testfile.swar';
|
||||
private Swar5 $testobject;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->swarfile = getcwd() . $this->swarfile;
|
||||
$root = NULL;
|
||||
$directory = dirname(__FILE__);
|
||||
do {
|
||||
$directory = dirname($directory);
|
||||
$composer = $directory . '/composer.json';
|
||||
if(file_exists($composer)) $root = $directory;
|
||||
} while(is_null($root) && $directory != '/');
|
||||
|
||||
$this->testfile = $directory . $this->testfile;
|
||||
$this->testobject = new Swar5();
|
||||
$this->testobject->read($this->swarfile);
|
||||
$this->testobject->read($this->testfile);
|
||||
}
|
||||
|
||||
public function testReadTournamentName(): void
|
||||
@ -41,4 +51,21 @@ 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
|
||||
{
|
||||
$player = Player::PlayersByName('Player 1', $this->testobject->Tournament)[0];
|
||||
$this->assertInstanceOf(Title::class, $player->Title);
|
||||
}
|
||||
|
||||
public function testPlayerHasNoTitle(): void
|
||||
{
|
||||
$player = Player::PlayersByName('Player 3', $this->testobject->Tournament)[0];
|
||||
$this->assertNull($player->Title);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user