From 9be15763e4b6db2f7ce31abf225584626b9686e4 Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Tue, 10 Jul 2018 21:05:22 -0500 Subject: [PATCH] Added spreadsheet test scenario 3. --- tests/RankedPairsCalculatorTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/RankedPairsCalculatorTest.php b/tests/RankedPairsCalculatorTest.php index 1c57fb2..45f1cda 100644 --- a/tests/RankedPairsCalculatorTest.php +++ b/tests/RankedPairsCalculatorTest.php @@ -287,4 +287,21 @@ public function testScenario2() $this->assertEquals($expectedRanking, $actualRanking); } + /** + * Scenario 3 from the test spreadsheet + * https://docs.google.com/spreadsheets/d/1634wP6-N8GG2Fig-yjIOk7vPBn4AijXOrjq6Z2T1K8M/edit?usp=sharing + */ + public function testScenario3() + { + $expectedRanking = (new CandidateRankingParser())->parse("MN>MC>BT>FE=CS>RR"); + + $ballots = (new TestScenario3())->getBallots(); + $tieBreakingBallot = $ballots[0]; + + $instance = new RankedPairsCalculator($tieBreakingBallot); + $results = $instance->calculate(sizeof($ballots), ...$ballots); + $actualRanking = $results->getRanking(); + + $this->assertEquals($expectedRanking, $actualRanking); + } }