Commit 47d05798 authored by Johan Vervloet's avatar Johan Vervloet

Bugfix and test for score log read model, #114.

Closes #114.
parent 7fed9745
Pipeline #111994502 passed with stages
in 4 minutes and 29 seconds
......@@ -5,6 +5,7 @@
### Changed
- Better naming for API regarding proposing with nobody along, #113.
- Bugfix correction lines messing up other sheets, #114.
## [0.2] - 2020-01-22
......
......@@ -137,6 +137,8 @@ final class ScoreLogReadModel implements ScoreLogs, ScoreLogUpdater
): void {
$criteria = (new Criteria())->where(
Criteria::expr()->gte('gameNumber', $gameNumber->toInteger())
)->andWhere(
Criteria::expr()->eq('scoreSheetId', $scoreSheetIdentifier->toString())
)->orderBy(['gameNumber' => 'DESC']);
/** @var OrmStoredLogEntry[] $existing */
$existing = $this->repository->matching($criteria);
......
......@@ -109,4 +109,60 @@ final class ScoreLogReadModelTest extends KernelTestCase
$this->assertEquals($expected, $actual);
}
/**
* See https://gitlab.com/rva-vzw/dikdikdik/issues/114.
*
* @test
* @covers \App\Domain\ReadModel\ScoreLog\ScoreLogReadModel::insertLine
*/
public function itLeavesAloneSheetsOfOtherTablesWhenShiftingDown(): void
{
$otherScoreSheetIdentifier = ScoreSheetIdentifier::forTable(
TableIdentifier::fromString('c7a7877d-8a73-4ac9-9d34-e925f753477f')
);
$this->readModel->setScoreFactor(
$this->scoreSheetIdentifier,
GameNumber::first(),
ScoreFactor::fromInteger(2)
);
$this->readModel->setDealer(
$this->scoreSheetIdentifier,
GameNumber::first(),
TestPlayer::penningmeester()
);
$this->readModel->setScoreFactor(
$otherScoreSheetIdentifier,
GameNumber::first(),
ScoreFactor::fromInteger(3)
);
$this->readModel->setScoreFactor(
$otherScoreSheetIdentifier,
GameNumber::second(),
ScoreFactor::fromInteger(2)
);
$scoreLine = new ScoreLine(
[
TestIds::PLAYER_SECRETARIS => -1,
TestIds::PLAYER_DTL => -1,
TestIds::PLAYER_TLM => -1,
TestIds::PLAYER_DLB => -1,
TestIds::PLAYER_PENNINGMEESTER => 4,
],
'compensation_passing_around'
);
$this->readModel->insertLine(
$this->scoreSheetIdentifier,
GameNumber::first(),
$scoreLine
);
$entry = $this->readModel->getOrCreateLogEntry(
$otherScoreSheetIdentifier,
GameNumber::second()
);
$this->assertEquals(ScoreFactor::fromInteger(2), $entry->getScoreFactor());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment