Completed
Push — master ( 90ceec...0b4c25 )
by Michael
03:34
created

StvElectionTest::testNewElection()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 2
eloc 13
nc 2
nop 0
1
<?php
2
3
namespace Tests\Michaelc\Voting;
4
5
use Michaelc\Voting\STV\{Election, Candidate, Ballot};
6
7
class StvElectionTest extends \PHPUnit_Framework_TestCase
8
{
9
	public function testNewElection()
10
	{
11
		$winners = 2;
12
		$candidateCount = 6;
13
14
		$candidates = $ballots = [];
15
16
		for ($i=1; $i <= $candidateCount; $i++) {
17
			$candidates[$i] = new Candidate($i);
18
		}
19
20
		$ballots[] = new Ballot([4, 5, 6]);
21
		$ballots[] = new Ballot([1, 2, 3]);
22
23
		$election = new Election($winners, $candidates, $ballots);
24
25
		$this->assertEquals($candidates[3], $election->getCandidate(3));
26
		$this->assertEquals($candidateCount, $election->getCandidateCount());
27
		$this->assertEquals($candidateCount, $election->getActiveCandidateCount());
28
		$this->assertEquals($winners, $election->getWinnersCount());
29
	}
30
}
31