Skip to content

Commit

Permalink
(tests) Better CondorcetTest_ValidAlgorithmName
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-boudry committed May 28, 2024
1 parent 3f20f26 commit 8f9d388
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tests/src/CondorcetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use CondorcetPHP\Condorcet\{Condorcet, Result};
use CondorcetPHP\Condorcet\{Candidate, Condorcet, Result};
use CondorcetPHP\Condorcet\Algo\{Method, MethodInterface};
use CondorcetPHP\Condorcet\Throwable\AlgorithmException;

Expand Down Expand Up @@ -118,11 +118,9 @@ protected function getStats(): array

protected function makeRanking(): void
{
$this->selfElection->get()->getPairwise();
$election = $this->getElection();

$result = [0 => 1, 1 => 2, 2 => 3]; // Candidate must be valid candidates

$this->Result = $this->createResult($result);
$this->Result = $this->createResult(array_slice(array_map(fn(Candidate $e): int => $election->getCandidateKey($e), $this->getElection()->getCandidatesList()), 0, 3));
}
}

Expand All @@ -141,7 +139,7 @@ class CondorcetTest_UnvalidAlgorithmName
public function getResult($options = null): Result
{
// Cache
if ($thisResult !== null) {
if ($this->Result !== null) {
return $this->Result;
}

Expand All @@ -168,7 +166,7 @@ protected function getStats(): array

protected function makeRanking(): void
{
$this->selfElection->getPairwise();
$this->getElection()->getPairwise();

$result = [0 => 0, 1 => [1, 2], 2 => 3]; // Candidate must be valid internal candidate key.

Expand Down

0 comments on commit 8f9d388

Please sign in to comment.