Skip to content

Commit 528d0ef

Browse files
committed
Update phpunit, add psalm
1 parent 914ec4b commit 528d0ef

File tree

4 files changed

+34
-28
lines changed

4 files changed

+34
-28
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ jobs:
1414
run: composer install --no-interaction --no-progress
1515
- name: Run tests
1616
run: php${{ matrix.php }} vendor/bin/phpunit --configuration Tests/phpunit.xml --verbose --fail-on-warning
17+
- name: Run psalm
18+
run: php${{ matrix.php }} vendor/bin/psalm

Tests/Tests.php

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function Sherlock( Buffer $Buffer, int $Length ) : bool
6161
}
6262
}
6363

64-
class SourceQueryTests extends TestCase
64+
class Tests extends \PHPUnit\Framework\TestCase
6565
{
6666
private TestableSocket $Socket;
6767
private SourceQuery $SourceQuery;
@@ -80,38 +80,30 @@ public function tearDown() : void
8080
unset( $this->Socket, $this->SourceQuery );
8181
}
8282

83-
/**
84-
* @expectedException xPaw\SourceQuery\Exception\InvalidArgumentException
85-
*/
8683
public function testInvalidTimeout() : void
8784
{
85+
$this->expectException( 'xPaw\SourceQuery\Exception\InvalidArgumentException' );
8886
$SourceQuery = new SourceQuery( );
8987
$SourceQuery->Connect( '', 2, -1 );
9088
}
9189

92-
/**
93-
* @expectedException xPaw\SourceQuery\Exception\SocketException
94-
*/
9590
public function testNotConnectedGetInfo() : void
9691
{
92+
$this->expectException( 'xPaw\SourceQuery\Exception\SocketException' );
9793
$this->SourceQuery->Disconnect();
9894
$this->SourceQuery->GetInfo();
9995
}
10096

101-
/**
102-
* @expectedException xPaw\SourceQuery\Exception\SocketException
103-
*/
10497
public function testNotConnectedPing() : void
10598
{
99+
$this->expectException( 'xPaw\SourceQuery\Exception\SocketException' );
106100
$this->SourceQuery->Disconnect();
107101
$this->SourceQuery->Ping();
108102
}
109103

110-
/**
111-
* @expectedException xPaw\SourceQuery\Exception\SocketException
112-
*/
113104
public function testNotConnectedGetPlayers() : void
114105
{
106+
$this->expectException( 'xPaw\SourceQuery\Exception\SocketException' );
115107
$this->SourceQuery->Disconnect();
116108
$this->SourceQuery->GetPlayers();
117109
}
@@ -121,33 +113,28 @@ public function testNotConnectedGetPlayers() : void
121113
*/
122114
public function testNotConnectedGetRules() : void
123115
{
116+
$this->expectException( 'xPaw\SourceQuery\Exception\SocketException' );
124117
$this->SourceQuery->Disconnect();
125118
$this->SourceQuery->GetRules();
126119
}
127120

128-
/**
129-
* @expectedException xPaw\SourceQuery\Exception\SocketException
130-
*/
131121
public function testNotConnectedSetRconPassword() : void
132122
{
123+
$this->expectException( 'xPaw\SourceQuery\Exception\SocketException' );
133124
$this->SourceQuery->Disconnect();
134125
$this->SourceQuery->SetRconPassword('a');
135126
}
136127

137-
/**
138-
* @expectedException xPaw\SourceQuery\Exception\SocketException
139-
*/
140128
public function testNotConnectedRcon() : void
141129
{
130+
$this->expectException( 'xPaw\SourceQuery\Exception\SocketException' );
142131
$this->SourceQuery->Disconnect();
143132
$this->SourceQuery->Rcon('a');
144133
}
145134

146-
/**
147-
* @expectedException xPaw\SourceQuery\Exception\SocketException
148-
*/
149135
public function testRconWithoutPassword() : void
150136
{
137+
$this->expectException( 'xPaw\SourceQuery\Exception\SocketException' );
151138
$this->SourceQuery->Rcon('a');
152139
}
153140

@@ -187,45 +174,45 @@ public function InfoProvider() : array
187174
}
188175

189176
/**
190-
* @expectedException xPaw\SourceQuery\Exception\InvalidPacketException
191177
* @dataProvider BadPacketProvider
192178
*/
193179
public function testBadGetInfo( string $Data ) : void
194180
{
181+
$this->expectException( 'xPaw\SourceQuery\Exception\InvalidPacketException' );
195182
$this->Socket->Queue( $Data );
196183

197184
$this->SourceQuery->GetInfo();
198185
}
199186

200187
/**
201-
* @expectedException xPaw\SourceQuery\Exception\InvalidPacketException
202188
* @dataProvider BadPacketProvider
203189
*/
204190
public function testBadGetChallengeViaPlayers( string $Data ) : void
205191
{
192+
$this->expectException( 'xPaw\SourceQuery\Exception\InvalidPacketException' );
206193
$this->Socket->Queue( $Data );
207194

208195
$this->SourceQuery->GetPlayers();
209196
}
210197

211198
/**
212-
* @expectedException xPaw\SourceQuery\Exception\InvalidPacketException
213199
* @dataProvider BadPacketProvider
214200
*/
215201
public function testBadGetPlayersAfterCorrectChallenge( string $Data ) : void
216202
{
203+
$this->expectException( 'xPaw\SourceQuery\Exception\InvalidPacketException' );
217204
$this->Socket->Queue( "\xFF\xFF\xFF\xFF\x41\x11\x11\x11\x11" );
218205
$this->Socket->Queue( $Data );
219206

220207
$this->SourceQuery->GetPlayers();
221208
}
222209

223210
/**
224-
* @expectedException xPaw\SourceQuery\Exception\InvalidPacketException
225211
* @dataProvider BadPacketProvider
226212
*/
227213
public function testBadGetRulesAfterCorrectChallenge( string $Data ) : void
228214
{
215+
$this->expectException( 'xPaw\SourceQuery\Exception\InvalidPacketException' );
229216
$this->Socket->Queue( "\xFF\xFF\xFF\xFF\x41\x11\x11\x11\x11" );
230217
$this->Socket->Queue( $Data );
231218

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
},
2323
"require-dev":
2424
{
25-
"phpunit/phpunit": "^6.0",
26-
"php-coveralls/php-coveralls": "^2.1"
25+
"phpunit/phpunit": "9.2",
26+
"vimeo/psalm": "^3.12",
27+
"php-coveralls/php-coveralls": "^2.2"
2728
},
2829
"autoload":
2930
{

psalm.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="1"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
>
9+
<projectFiles>
10+
<directory name="SourceQuery" />
11+
<directory name="Tests" />
12+
<ignoreFiles>
13+
<directory name="vendor" />
14+
</ignoreFiles>
15+
</projectFiles>
16+
</psalm>

0 commit comments

Comments
 (0)