BUGFIX: checking for the composer root
This commit is contained in:
parent
c1db2253ce
commit
b6c9be66cb
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user