51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
use Lubiana\Aoc\Y2023\D02\D02;
|
|
use Lubiana\Aoc\Y2023\D02\Game;
|
|
use Lubiana\Aoc\Y2023\D02\Set;
|
|
|
|
final class D02Test extends \PHPUnit\Framework\TestCase
|
|
{
|
|
private \Lubiana\Aoc\Y2023\D02\D02 $d02;
|
|
public function setUp(): void
|
|
{
|
|
$this->d02 = new D02(D02::TESTFILE);
|
|
parent::setUp();
|
|
}
|
|
|
|
public function testResult(): void
|
|
{
|
|
$this->assertEquals(8, $this->d02->solve());
|
|
}
|
|
|
|
|
|
public function testReadInput(): void
|
|
{
|
|
$this->assertEquals(file(D02::TESTFILE), $this->d02->readData());
|
|
}
|
|
|
|
public function testValidGames(): void
|
|
{
|
|
$configurationSet = [
|
|
new Set(12, 'red'),
|
|
new Set(13, 'green'),
|
|
new Set(14, 'blue'),
|
|
];
|
|
$games = $this->d02->getValidGames($configurationSet);
|
|
$this->assertEquals(1, array_shift($games)->id);
|
|
$this->assertEquals(2, array_shift($games)->id);
|
|
$this->assertEquals(5, array_shift($games)->id);
|
|
|
|
}
|
|
|
|
public function testReadGames(): void
|
|
{
|
|
$games = $this->d02->getGames();
|
|
$this->assertEquals(1, array_shift($games)->id);
|
|
$this->assertEquals(2, array_shift($games)->id);
|
|
$this->assertEquals(3, array_shift($games)->id);
|
|
$this->assertEquals(4, array_shift($games)->id);
|
|
$this->assertEquals(5, array_shift($games)->id);
|
|
}
|
|
}
|
|
|