Skip to content

Commit ee79f46

Browse files
author
Greg Bowler
committed
Fix tests
1 parent 97c4b79 commit ee79f46

File tree

4 files changed

+18
-35
lines changed

4 files changed

+18
-35
lines changed

src/ServerInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function getServerProtocolVersion():float {
4747
FILTER_SANITIZE_NUMBER_FLOAT,
4848
FILTER_FLAG_ALLOW_FRACTION
4949
);
50-
return $version;
50+
return (float)$version;
5151
}
5252

5353
/**

test/unit/RequestFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function testCreateServerRequest() {
1818
/** @var MockObject|ServerInfo $serverInfo */
1919
$serverInfo = self::createMock(ServerInfo::class);
2020
$serverInfo->method("getServerProtocolVersion")
21-
->willReturn("123");
21+
->willReturn(123.000);
2222
$serverInfo->method("getRequestMethod")
2323
->willReturn(RequestMethod::METHOD_GET);
2424
/** @var MockObject|Input $input */

test/unit/SteamTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SteamTest extends TestCase {
1414
protected $tmpStream;
1515
protected $tmpFileFull;
1616

17-
public function setUp() {
17+
public function setUp():void {
1818
$this->tmpDir = implode(DIRECTORY_SEPARATOR, [
1919
sys_get_temp_dir(),
2020
"phpgt",
@@ -27,7 +27,7 @@ public function setUp() {
2727
file_put_contents($this->tmpFileFull, uniqid("data-"));
2828
}
2929

30-
public function tearDown() {
30+
public function tearDown():void {
3131
/** @var SplFileInfo[] $files */
3232
$files = new RecursiveIteratorIterator(
3333
new RecursiveDirectoryIterator(

test/unit/UriTest.php

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<?php
22
namespace Gt\Http\Test;
33

4+
use Gt\Http\PortOutOfBoundsException;
45
use Gt\Http\Uri;
56
use Gt\Http\UriFactory;
7+
use Gt\Http\UriParseErrorException;
68
use PHPUnit\Framework\TestCase;
9+
use TypeError;
710

811
class UriTest extends TestCase {
912
public function testParsesProvidedUri() {
@@ -83,11 +86,9 @@ public function getValidUris() {
8386
];
8487
}
8588

86-
/**
87-
* @expectedException \Gt\Http\UriParseErrorException
88-
* @dataProvider getInvalidUris
89-
*/
89+
/** @dataProvider getInvalidUris */
9090
public function testInvalidUrisThrowException($invalidUri) {
91+
self::expectException(UriParseErrorException::class);
9192
new Uri($invalidUri);
9293
}
9394

@@ -101,59 +102,43 @@ public function getInvalidUris() {
101102
];
102103
}
103104

104-
/**
105-
* @expectedException \Gt\Http\PortOutOfBoundsException
106-
*/
107105
public function testPortMustBeValid() {
106+
self::expectException(PortOutOfBoundsException::class);
108107
(new Uri())->withPort(100000);
109108
}
110109

111-
/**
112-
* @expectedException \Gt\Http\PortOutOfBoundsException
113-
*/
114110
public function testWithPortCannotBeZero() {
111+
self::expectException(PortOutOfBoundsException::class);
115112
(new Uri())->withPort(0);
116113
}
117114

118-
/**
119-
* @expectedException \Gt\Http\UriParseErrorException
120-
*/
121115
public function testParseUriPortCannotBeZero() {
116+
self::expectException(UriParseErrorException::class);
122117
new Uri('//example.com:0');
123118
}
124119

125-
/**
126-
* @expectedException \TypeError
127-
*/
128120
public function testSchemeMustHaveCorrectType() {
121+
self::expectException(TypeError::class);
129122
(new Uri())->withScheme([]);
130123
}
131124

132-
/**
133-
* @expectedException \TypeError
134-
*/
135125
public function testHostMustHaveCorrectType() {
126+
self::expectException(TypeError::class);
136127
(new Uri())->withHost([]);
137128
}
138129

139-
/**
140-
* @expectedException \TypeError
141-
*/
142130
public function testPathMustHaveCorrectType() {
131+
self::expectException(TypeError::class);
143132
(new Uri())->withPath([]);
144133
}
145134

146-
/**
147-
* @expectedException \TypeError
148-
*/
149135
public function testQueryMustHaveCorrectType() {
136+
self::expectException(TypeError::class);
150137
(new Uri())->withQuery([]);
151138
}
152139

153-
/**
154-
* @expectedException \TypeError
155-
*/
156140
public function testFragmentMustHaveCorrectType() {
141+
self::expectException(TypeError::class);
157142
(new Uri())->withFragment([]);
158143
}
159144

@@ -379,10 +364,8 @@ public function testStandardPortIsNullIfSchemeChanges() {
379364
$this->assertNull($uri->getPort());
380365
}
381366

382-
/**
383-
* @expectedException \TypeError
384-
*/
385367
public function testPortPassedAsStringIsCastedToInt() {
368+
self::expectException(TypeError::class);
386369
$uri = (new Uri('//example.com'))->withPort('8080');
387370
}
388371

0 commit comments

Comments
 (0)