Skip to content

Commit

Permalink
fix test suite running similarly to annechko#1
Browse files Browse the repository at this point in the history
  • Loading branch information
Akos committed May 21, 2024
1 parent 15dedb7 commit a9548e9
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tests/acceptance.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ modules:
enabled:
- PhpBrowser:
url: http://localhost/myapp
- \Helper\Acceptance
#- \Helper\Acceptance
step_decorators: ~
coverage:
enabled: false
Empty file added tests/acceptance/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion tests/functional.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ actor: FunctionalTester
modules:
enabled:
# add a framework module here
- \Helper\Functional
#- \Helper\Functional
step_decorators: ~
Empty file added tests/functional/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion tests/unit.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ actor: UnitTester
modules:
enabled:
- Asserts
- \Helper\Unit
#- \Helper\Unit
step_decorators: ~
6 changes: 6 additions & 0 deletions tests/unit/BaseUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
namespace Tests\unit;

use Codeception\Test\Unit;
use Azul\Game\Table;
use Azul\Tile\Marker;

abstract class BaseUnit extends Unit
{
protected \UnitTester $tester;

public function createGameTable(): \Azul\Game\Table {
return new Table(new Marker());
}
}
2 changes: 1 addition & 1 deletion tests/unit/GameRoundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GameRoundTest extends BaseUnit
{
public function testKeepPlaying_EmptyFactoriesAndTable_False(): void
{
$t = $this->tester->createGameTable();
$t = $this->createGameTable();
$round = new GameRound($t,
[
$f = new Factory(
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/PlayerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public function testGetNextMove_ReturnMoveObject(): void
$player = new Player(new Board());
$factory = new Factory(new TileCollection([new Tile(Color::BLUE)]));
$move = $player->getNextMove(new FactoryCollection([$factory]),
$this->tester->createGameTable());
$this->createGameTable());
$this->assertNotNull($move);
}

public function testGetNextMove_TiledFactoryEmptyTable_TookTilesFromFactory(): void
{
$player = new Player(new Board());
$t = $this->tester->createGameTable();
$t = $this->createGameTable();
$factory = new Factory(new TileCollection([new Tile(Color::BLUE)]));

$move = $player->getNextMove(new FactoryCollection([$factory]), $t);
Expand All @@ -36,7 +36,7 @@ public function testGetNextMove_TiledFactoryEmptyTable_TookTilesFromFactory(): v
public function testGetNextMove_EmptyFactoryTiledTable_TookTilesFromTable(): void
{
$player = new Player(new Board());
$t = $this->tester->createGameTable();
$t = $this->createGameTable();
$t->addToCenterPile(new TileCollection([new Tile(Color::BLUE)]));

$move = $player->getNextMove(new FactoryCollection([new Factory(new TileCollection())]),
Expand All @@ -52,7 +52,7 @@ public function testGetNextMove_AllWallRowsHasRedTile_TookTilesAnyway(): void
$board->placeTiles(new TileCollection([new Tile(Color::RED)]), Board::ROW_3);
$board->placeTiles(new TileCollection([new Tile(Color::RED)]), Board::ROW_4);
$board->placeTiles(new TileCollection([new Tile(Color::RED)]), Board::ROW_5);
$t = $this->tester->createGameTable(null);
$t = $this->createGameTable(null);
$t->addToCenterPile(new TileCollection([new Tile(Color::BLACK)]));

$this->assertEquals(0, $board->getFloorTilesCount());
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TableTest extends BaseUnit
{
public function testCountTotal_2DifferentColors_Total2(): void
{
$table = $this->tester->createGameTable();
$table = $this->createGameTable();
$table->addToCenterPile(new TileCollection([
new Tile(Color::RED),
new Tile(Color::CYAN),
Expand All @@ -21,7 +21,7 @@ public function testCountTotal_2DifferentColors_Total2(): void

public function testCountTotal_2SameColors_Total2(): void
{
$table = $this->tester->createGameTable();
$table = $this->createGameTable();
$table->addToCenterPile(new TileCollection([
new Tile(Color::RED),
new Tile(Color::RED),
Expand All @@ -31,13 +31,13 @@ public function testCountTotal_2SameColors_Total2(): void

public function testCountTotal_Empty_Total0(): void
{
$table = $this->tester->createGameTable();
$table = $this->createGameTable();
$this->assertEquals(0, $table->getTilesCount());
}

public function testCountByColor(): void
{
$table = $this->tester->createGameTable();
$table = $this->createGameTable();
$table->addToCenterPile(new TileCollection([
new Tile(Color::RED),
new Tile(Color::RED),
Expand All @@ -54,7 +54,7 @@ public function testCountByColor(): void

public function testTakeMarker_HasMarker_NoMarkerAfter(): void
{
$table = $this->tester->createGameTable();
$table = $this->createGameTable();
$this->assertTrue($table->hasMarker());
$marker = $table->takeMarker();
$this->assertNotNull($marker);
Expand All @@ -63,15 +63,15 @@ public function testTakeMarker_HasMarker_NoMarkerAfter(): void

public function testTakeMarker_Twice_GotException(): void
{
$table = $this->tester->createGameTable();
$table = $this->createGameTable();
$table->takeMarker();
$this->expectException(MarkerAlreadyTakenException::class);
$table->takeMarker();
}

public function testTake_HasMarker_MarkerLeft(): void
{
$table = $this->tester->createGameTable();
$table = $this->createGameTable();
$color = Color::RED;
$table->addToCenterPile(new TileCollection([
new Tile($color),
Expand Down

0 comments on commit a9548e9

Please sign in to comment.