Skip to content

Commit

Permalink
PHPUnit: Use $this assertions style
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-boudry committed Jul 24, 2023
1 parent 35b3870 commit 45bbeb7
Show file tree
Hide file tree
Showing 47 changed files with 1,022 additions and 1,019 deletions.
26 changes: 13 additions & 13 deletions Tests/src/Algo/Methods/Borda/BordaCountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testResult_1(): void
D>C>B>A * 17
');

self::assertSame(
$this->assertSame(
[
1 => 'B',
2 => 'C',
Expand All @@ -46,7 +46,7 @@ public function testResult_1(): void
$this->election->getResult('Borda Count')->getResultAsArray(true)
);

self::assertEquals(
$this->assertEquals(
[
'B' => 294,
'C' => 273,
Expand Down Expand Up @@ -74,7 +74,7 @@ public function testResult_2(): void
A>D>C>B ^ 15
');

self::assertSame(
$this->assertSame(
[
1 => 'A',
2 => 'B',
Expand All @@ -83,7 +83,7 @@ public function testResult_2(): void
$this->election->getResult('Borda Count')->getResultAsArray(true)
);

self::assertEquals(
$this->assertEquals(
[
'A' => 340,
'B' => 280,
Expand All @@ -103,14 +103,14 @@ public function testResult_3(): void
A
');

self::assertSame(
$this->assertSame(
[
1 => 'A',
2 => ['B', 'C'], ],
$this->election->getResult('Borda Count')->getResultAsArray(true)
);

self::assertEquals(
$this->assertEquals(
[
'A' => 3,
'B' => 1.5,
Expand All @@ -120,14 +120,14 @@ public function testResult_3(): void

$this->election->setImplicitRanking(false);

self::assertSame(
$this->assertSame(
[
1 => 'A',
2 => ['B', 'C'], ],
$this->election->getResult('Borda Count')->getResultAsArray(true)
);

self::assertEquals(
$this->assertEquals(
[
'A' => 3,
'B' => 0,
Expand All @@ -152,7 +152,7 @@ public function testResult_4(): void
D>C>B>A * 17
');

self::assertSame(
$this->assertSame(
[
1 => 'B',
2 => 'C',
Expand All @@ -161,7 +161,7 @@ public function testResult_4(): void
$this->election->getResult('Borda Count')->getResultAsArray(true)
);

self::assertEquals(
$this->assertEquals(
[
'B' => 294,
'C' => 273,
Expand Down Expand Up @@ -189,7 +189,7 @@ public function testResult_variant(): void

$this->election->setMethodOption('Borda Count', 'Starting', 0);

self::assertSame(
$this->assertSame(
[
1 => 'B',
2 => 'C',
Expand All @@ -198,7 +198,7 @@ public function testResult_variant(): void
$this->election->getResult('Borda Count')->getResultAsArray(true)
);

self::assertEquals(
$this->assertEquals(
[
'B' => 294 - 100,
'C' => 273 - 100,
Expand All @@ -215,6 +215,6 @@ public function testVeryHighVoteWeightAndPerformances(): void

$this->election->parseVotes('1 > 0 ^6973568802');

self::assertSame('1', $this->election->getResult('Borda Count')->getResultAsString());
$this->assertSame('1', $this->election->getResult('Borda Count')->getResultAsString());
}
}
4 changes: 2 additions & 2 deletions Tests/src/Algo/Methods/Borda/DowdallSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testResult_1(): void
A>B>C>D>E>F
');

self::assertSame(
$this->assertSame(
[
1 => 'A',
2 => 'B',
Expand All @@ -43,7 +43,7 @@ public function testResult_1(): void
$this->election->getResult('DowdallSystem')->getResultAsArray(true)
);

self::assertEqualsWithDelta(
$this->assertEqualsWithDelta(
[
'A' => 1/1,
'B' => 1/2,
Expand Down
20 changes: 10 additions & 10 deletions Tests/src/Algo/Methods/CondorcetBasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testResult_Basic(): void

$this->election->addVote($vote);

self::assertEquals('a', $this->election->getCondorcetWinner());
$this->assertEquals('a', $this->election->getCondorcetWinner());
}

public function testResult_1(): void
Expand All @@ -44,7 +44,7 @@ public function testResult_1(): void
c > a > b * 2
');

self::assertEquals('c', $this->election->getCondorcetWinner());
$this->assertEquals('c', $this->election->getCondorcetWinner());
}

public function testResult_2(): void
Expand All @@ -59,10 +59,10 @@ public function testResult_2(): void
Z > X > Y * 22
');

self::assertNull($this->election->getWinner());
$this->assertNull($this->election->getWinner());

// Schulze Substitution
self::assertEquals('X', $this->election->getWinner('Schulze'));
$this->assertEquals('X', $this->election->getWinner('Schulze'));
}

public function testResult_3(): void
Expand All @@ -79,8 +79,8 @@ public function testResult_3(): void
Knoxville > Chattanooga > Nashville * 17
');

self::assertEquals('Nashville', $this->election->getCondorcetWinner());
self::assertEquals('Memphis', $this->election->getCondorcetLoser());
$this->assertEquals('Nashville', $this->election->getCondorcetWinner());
$this->assertEquals('Memphis', $this->election->getCondorcetLoser());
}

public function testResult_4(): void
Expand All @@ -97,7 +97,7 @@ public function testResult_4(): void
Knoxville > Chattanooga > Nashville * 17
');

self::assertEquals('Chattanooga', $this->election->getCondorcetWinner());
$this->assertEquals('Chattanooga', $this->election->getCondorcetWinner());
}

public function testResult_5(): void
Expand All @@ -118,8 +118,8 @@ public function testResult_5(): void
L > C > A * 2
');

self::assertEquals('L', $this->election->getCondorcetLoser());
self::assertNull($this->election->getCondorcetWinner());
$this->assertEquals('L', $this->election->getCondorcetLoser());
$this->assertNull($this->election->getCondorcetWinner());
}

public function testResult_6(): void
Expand All @@ -137,7 +137,7 @@ public function testResult_6(): void
A > C > L
');

self::assertEquals('L', $this->election->getCondorcetLoser());
$this->assertEquals('L', $this->election->getCondorcetLoser());
}

public function testNoResultObject(): never
Expand Down
16 changes: 8 additions & 8 deletions Tests/src/Algo/Methods/Copeland/CopelandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testResult_1(): void
');


self::assertSame(
$this->assertSame(
[
1 => 'Nashville',
2 => 'Chattanooga',
Expand All @@ -42,9 +42,9 @@ public function testResult_1(): void
$this->election->getResult('Copeland')->getResultAsArray(true)
);

self::assertSame($this->election->getWinner('Copeland'), $this->election->getWinner());
$this->assertSame($this->election->getWinner('Copeland'), $this->election->getWinner());

self::assertSame(
$this->assertSame(
[
'Memphis' => [
'balance' => -3,
Expand Down Expand Up @@ -80,10 +80,10 @@ public function testResult_2(): void
D > A > E * 10
');

self::assertNull($this->election->getWinner());
self::assertSame($candidateA, $this->election->getWinner('Copeland'));
$this->assertNull($this->election->getWinner());
$this->assertSame($candidateA, $this->election->getWinner('Copeland'));

self::assertSame(
$this->assertSame(
[1 => $candidateA,
2 => [$candidateB, $candidateC, $candidateE],
3 => $candidateD,
Expand Down Expand Up @@ -118,9 +118,9 @@ public function testResult_3(): void
Dave>Cora>Brad>Abby>Erin * 23
');

self::assertEquals(['Abby', 'Brad'], $this->election->getWinner('Copeland'));
$this->assertEquals(['Abby', 'Brad'], $this->election->getWinner('Copeland'));

self::assertSame(
$this->assertSame(
[1 => ['Abby', 'Brad'],
2 => ['Dave', 'Erin'],
3 => 'Cora', ],
Expand Down
Loading

0 comments on commit 45bbeb7

Please sign in to comment.