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

StvElectionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testNewElection() 0 21 2
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