-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathApplicationTest.php
More file actions
138 lines (115 loc) · 3.75 KB
/
Copy pathApplicationTest.php
File metadata and controls
138 lines (115 loc) · 3.75 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
namespace BNETDocs\Tests\Libraries\Packet;
use \BNETDocs\Libraries\Packet\Application;
use \OutOfBoundsException;
use \PHPUnit\Framework\TestCase;
class ApplicationTest extends TestCase
{
// Constructor — known IDs
public function testIdOneBnetV1Tcp(): void
{
$a = new Application(1);
$this->assertSame(1, $a->getId());
$this->assertSame('Battle.net v1 TCP Messages', $a->getLabel());
$this->assertSame('SID', $a->getTag());
}
public function testIdTwoBnetV1Udp(): void
{
$a = new Application(2);
$this->assertSame(2, $a->getId());
$this->assertSame('Battle.net v1 UDP Messages', $a->getLabel());
$this->assertSame('PKT', $a->getTag());
}
public function testIdThreeDiabloIiRealm(): void
{
$a = new Application(3);
$this->assertSame('Diablo II Realm Messages', $a->getLabel());
$this->assertSame('MCP', $a->getTag());
}
public function testIdFourDiabloIiInGame(): void
{
$a = new Application(4);
$this->assertSame('Diablo II In-Game Messages', $a->getLabel());
$this->assertSame('D2GS', $a->getTag());
}
public function testIdFiveWarcraftIiiInGame(): void
{
$a = new Application(5);
$this->assertSame('Warcraft III In-Game Messages', $a->getLabel());
$this->assertSame('W3GS', $a->getTag());
}
public function testIdSixBotNet(): void
{
$a = new Application(6);
$this->assertSame('BotNet Messages', $a->getLabel());
$this->assertSame('PACKET', $a->getTag());
}
public function testIdSevenBnls(): void
{
$a = new Application(7);
$this->assertSame('BNLS Messages', $a->getLabel());
$this->assertSame('BNLS', $a->getTag());
}
public function testIdEightStarcraftInGame(): void
{
$a = new Application(8);
$this->assertSame('Starcraft In-Game Messages', $a->getLabel());
$this->assertSame('SCGP', $a->getTag());
}
public function testIdNineBnetV2Tcp(): void
{
$a = new Application(9);
$this->assertSame(9, $a->getId());
$this->assertSame('Battle.net v2 TCP Messages', $a->getLabel());
$this->assertSame('SID2', $a->getTag());
}
// Constructor — invalid IDs
public function testZeroIdThrowsOutOfBounds(): void
{
$this->expectException(OutOfBoundsException::class);
new Application(0);
}
public function testOutOfRangeIdThrowsOutOfBounds(): void
{
$this->expectException(OutOfBoundsException::class);
new Application(10);
}
public function testNegativeIdThrowsOutOfBounds(): void
{
$this->expectException(OutOfBoundsException::class);
new Application(-1);
}
// getAllAsArray
public function testGetAllAsArrayHasNineEntries(): void
{
$this->assertCount(9, Application::getAllAsArray());
}
public function testGetAllAsArrayKeysAreIntegers(): void
{
$arr = Application::getAllAsArray();
foreach (array_keys($arr) as $key)
{
$this->assertIsInt($key);
}
}
// getAllAsObjects
public function testGetAllAsObjectsHasNineEntries(): void
{
$this->assertCount(9, Application::getAllAsObjects());
}
public function testGetAllAsObjectsReturnsApplicationInstances(): void
{
foreach (Application::getAllAsObjects() as $obj)
{
$this->assertInstanceOf(Application::class, $obj);
}
}
public function testGetAllAsObjectsIdsMatchTable(): void
{
$table = Application::getAllAsArray();
foreach (Application::getAllAsObjects() as $obj)
{
$this->assertArrayHasKey($obj->getId(), $table);
}
}
}