diff --git a/src/Teams.php b/src/Teams.php index 341d851..6630b20 100644 --- a/src/Teams.php +++ b/src/Teams.php @@ -11,13 +11,6 @@ class Teams */ public static function concat(Team ...$args/*variable arguments*/): array { - $result = []; - - foreach ($args as $currentTeam) { - $localCurrentTeam = $currentTeam; - $result[] = $localCurrentTeam; - } - - return $result; + return $args; } } diff --git a/tests/GameInfoTest.php b/tests/GameInfoTest.php index f84ea24..621af32 100644 --- a/tests/GameInfoTest.php +++ b/tests/GameInfoTest.php @@ -5,7 +5,7 @@ declare(strict_types=1); namespace DNW\Skills\Tests; use DNW\Skills\GameInfo; -use \DNW\Skills\Rating; +use DNW\Skills\Rating; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; diff --git a/tests/PlayerTest.php b/tests/PlayerTest.php index b6f6461..82092be 100644 --- a/tests/PlayerTest.php +++ b/tests/PlayerTest.php @@ -10,7 +10,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; - #[CoversClass(Player::class)] #[UsesClass(Guard::class)] class PlayerTest extends TestCase diff --git a/tests/RatingContainerTest.php b/tests/RatingContainerTest.php new file mode 100644 index 0000000..d93e564 --- /dev/null +++ b/tests/RatingContainerTest.php @@ -0,0 +1,47 @@ +assertEquals([], $rc->getAllPlayers()); + $this->assertEquals([], $rc->getAllRatings()); + $this->assertEquals(0, $rc->count()); + + $p1 = new Player(1); + $p2 = new Player(2); + + $r1 = new Rating(100, 10); + $r2 = new Rating(200, 20); + + $rc->setRating($p1, $r1); + $rc->setRating($p2, $r2); + + $this->assertEquals($r1, $rc->getRating($p1)); + $this->assertEquals($r2, $rc->getRating($p2)); + + $this->assertEquals([$p1, $p2], $rc->getAllPlayers()); + $this->assertEquals([$r1, $r2], $rc->getAllRatings()); + $this->assertEquals(2, $rc->count()); + } +} diff --git a/tests/TeamTest.php b/tests/TeamTest.php new file mode 100644 index 0000000..62770cf --- /dev/null +++ b/tests/TeamTest.php @@ -0,0 +1,69 @@ +assertEquals($r1, $rc->getRating($p1)); + $this->assertEquals([$p1], $rc->getAllPlayers()); + $this->assertEquals([$r1], $rc->getAllRatings()); + $this->assertEquals(1, $rc->count()); + + $rc->addPlayer($p2, $r2); + + $this->assertEquals($r2, $rc->getRating($p2)); + + $this->assertEquals([$p1, $p2], $rc->getAllPlayers()); + $this->assertEquals([$r1, $r2], $rc->getAllRatings()); + $this->assertEquals(2, $rc->count()); + } + + public function testTeamConstructor(): void + { + $p = new Player(0); + $r = new Rating(100, 10); + + $rc = new Team(NULL, NULL); + $this->assertEquals(0, $rc->count()); + + $rc = new Team($p, NULL); + $this->assertEquals(0, $rc->count()); + + $rc = new Team(NULL, $r); + $this->assertEquals(0, $rc->count()); + + $rc = new Team($p, $r); + $this->assertEquals($r, $rc->getRating($p)); + $this->assertEquals([$p], $rc->getAllPlayers()); + $this->assertEquals([$r], $rc->getAllRatings()); + $this->assertEquals(1, $rc->count()); + } +} diff --git a/tests/TeamsTest.php b/tests/TeamsTest.php new file mode 100644 index 0000000..fcb0ba7 --- /dev/null +++ b/tests/TeamsTest.php @@ -0,0 +1,28 @@ +assertEquals([$t1], Teams::concat($t1)); + $this->assertEquals([$t1, $t2, $t3], Teams::concat($t1, $t2, $t3)); + } +}