BUGFIX: checking for the composer root

This commit is contained in:
Jeroen De Meerleer 2023-01-14 16:41:46 +01:00
parent c1db2253ce
commit b6c9be66cb
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 30 additions and 6 deletions

View File

@ -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);
}

View File

@ -9,14 +9,22 @@ 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
@ -51,7 +59,13 @@ class Swar5Test extends TestCase
public function testPlayerHasTitle(): void
{
$player1 = Player::PlayersByName('Player 1', $this->testobject->Tournament)[0];
$this->assertInstanceOf(Title::class, $player1->Title);
$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);
}
}