-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfoosmatch.test.php
75 lines (63 loc) · 2.74 KB
/
foosmatch.test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
require_once(dirname(__FILE__) . '/simpletest/autorun.php');
require_once('foos.class.php');
class TestFoosMatch extends UnitTestCase {
function testSort1() {
$player1 = new FoosPlayer('player1', 1000);
$player2 = new FoosPlayer('player2', 1000);
$match = new FoosMatch($player1, 2, $player2, 1);
$this->assertEqual($match->getPlayer1(), $player1);
$this->assertEqual($match->getPlayer2(), $player2);
$this->assertEqual($match->getScore1(), 2);
$this->assertEqual($match->getScore2(), 1);
}
function testSort2() {
$player1 = new FoosPlayer('player1', 1000);
$player2 = new FoosPlayer('player2', 1000);
$match = new FoosMatch($player1, 1, $player2, 2);
$this->assertEqual($match->getPlayer1(), $player2);
$this->assertEqual($match->getPlayer2(), $player1);
$this->assertEqual($match->getScore1(), 2);
$this->assertEqual($match->getScore2(), 1);
}
function testSortDraw() {
$player1 = new FoosPlayer('player1', 1000);
$player2 = new FoosPlayer('player2', 1000);
$match = new FoosMatch($player1, 2, $player2, 2);
$this->assertEqual($match->getPlayer1(), $player1);
$this->assertEqual($match->getPlayer2(), $player2);
$this->assertEqual($match->getScore1(), 2);
$this->assertEqual($match->getScore2(), 2);
}
function testPassingByReference() {
$player1 = new FoosPlayer('player1', 1000);
$player2 = new FoosPlayer('player2', 1000);
$match = new FoosMatch($player1, 2, $player2, 1);
$player1->setStrength(1);
$this->assertEqual($match->getPlayer1()->getStrength(), 1);
}
function testCalculateScoreDraw() {
$player1 = new FoosPlayer('player1', 1000);
$player2 = new FoosPlayer('player2', 1000);
$match = new FoosMatch($player1, 2, $player2, 2);
$match->calculateScore();
$this->assertEqual($player1->getStrength(), 1000);
$this->assertEqual($player2->getStrength(), 1000);
}
function testCalculateScore1() {
$player1 = new FoosPlayer('player1', 1000);
$player2 = new FoosPlayer('player2', 1000);
$match = new FoosMatch($player1, 2, $player2, 1);
$match->calculateScore();
$this->assertEqual($player1->getStrength(), 1100);
$this->assertEqual($player2->getStrength(), 900);
}
function testCalculateScore2() {
$player1 = new FoosPlayer('player1', 1000);
$player2 = new FoosPlayer('player2', 1000);
$match = new FoosMatch($player1, 1, $player2, 2);
$match->calculateScore();
$this->assertEqual($player2->getStrength(), 1100);
$this->assertEqual($player1->getStrength(), 900);
}
}