Completed
Push — master ( 3a37c9...90ceec )
by Michael
04:14
created

StvElectionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testNewElection() 0 25 1
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
		$candidates[1] = new Candidate(1);
16
		$candidates[2] = new Candidate(2);
17
		$candidates[3] = new Candidate(3);
18
		$candidates[4] = new Candidate(4);
19
		$candidates[5] = new Candidate(5);
20
		$candidates[6] = new Candidate(6);
21
22
		$ballots[] = new Ballot([4, 5, 6]);
23
		$ballots[] = new Ballot([1, 2, 3]);
24
		$ballots[] = new Ballot([4, 5, 6]);
25
		$ballots[] = new Ballot([1, 4, 2]);
26
27
		$election = new Election($winners, $candidates, $ballots);
28
29
		$this->assertEquals($candidates[3], $election->getCandidate(3));
30
		$this->assertEquals($candidateCount, $election->getCandidateCount());
31
		$this->assertEquals($candidateCount, $election->getActiveCandidateCount());
32
		$this->assertEquals($winners, $election->getWinnersCount());
33
	}
34
}
35