Skip to content

Commit e810caf

Browse files
committed
added typing on tests, since minimum version is php 7.1 anyway
1 parent 008627e commit e810caf

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

Tests/Factory/AbstractHttpMessageFactoryTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ abstract class AbstractHttpMessageFactoryTest extends TestCase
3232
/**
3333
* @return HttpMessageFactoryInterface
3434
*/
35-
abstract protected function buildHttpMessageFactory();
35+
abstract protected function buildHttpMessageFactory(): HttpMessageFactoryInterface;
3636

3737
public function setUp(): void
3838
{
3939
$this->factory = $this->buildHttpMessageFactory();
4040
$this->tmpDir = sys_get_temp_dir();
4141
}
4242

43-
public function testCreateRequest()
43+
public function testCreateRequest(): void
4444
{
4545
$stdClass = new \stdClass();
4646
$request = new Request(
@@ -119,7 +119,7 @@ public function testCreateRequest()
119119
$this->assertEquals(['2.8'], $psrRequest->getHeader('X-Symfony'));
120120
}
121121

122-
public function testGetContentCanBeCalledAfterRequestCreation()
122+
public function testGetContentCanBeCalledAfterRequestCreation(): void
123123
{
124124
$header = ['HTTP_HOST' => 'dunglas.fr'];
125125
$request = new Request([], [], [], [], [], $header, 'Content');
@@ -143,7 +143,7 @@ private function createUploadedFile($content, $originalName, $mimeType, $error)
143143
return new UploadedFile($path, $originalName, $mimeType, filesize($path), $error, true);
144144
}
145145

146-
public function testCreateResponse()
146+
public function testCreateResponse(): void
147147
{
148148
$response = new Response(
149149
'Response content.',
@@ -163,7 +163,7 @@ public function testCreateResponse()
163163
$this->assertRegExp('{city=Lille; expires=Wed, 13-Jan-2021 22:23:01 GMT;( max-age=\d+;)? path=/; httponly}i', $cookieHeader[0]);
164164
}
165165

166-
public function testCreateResponseFromStreamed()
166+
public function testCreateResponseFromStreamed(): void
167167
{
168168
$response = new StreamedResponse(function () {
169169
echo "Line 1\n";
@@ -178,7 +178,7 @@ public function testCreateResponseFromStreamed()
178178
$this->assertEquals("Line 1\nLine 2\n", $psrResponse->getBody()->__toString());
179179
}
180180

181-
public function testCreateResponseFromBinaryFile()
181+
public function testCreateResponseFromBinaryFile(): void
182182
{
183183
$path = tempnam($this->tmpDir, uniqid());
184184
file_put_contents($path, 'Binary');
@@ -190,7 +190,7 @@ public function testCreateResponseFromBinaryFile()
190190
$this->assertEquals('Binary', $psrResponse->getBody()->__toString());
191191
}
192192

193-
public function testUploadErrNoFile()
193+
public function testUploadErrNoFile(): void
194194
{
195195
if (class_exists('Symfony\Component\HttpFoundation\HeaderUtils')) {
196196
// Symfony 4.1+

Tests/Factory/DiactorosFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory;
1313

1414
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
15+
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
1516

1617
/**
1718
* @author Kévin Dunglas <[email protected]>
@@ -21,7 +22,7 @@
2122
*/
2223
class DiactorosFactoryTest extends AbstractHttpMessageFactoryTest
2324
{
24-
protected function buildHttpMessageFactory()
25+
protected function buildHttpMessageFactory(): HttpMessageFactoryInterface
2526
{
2627
if (!class_exists('Zend\Diactoros\ServerRequestFactory')) {
2728
$this->markTestSkipped('Zend Diactoros is not installed.');

Tests/Factory/HttpFoundationFactoryTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function setUp(): void
3939
$this->tmpDir = sys_get_temp_dir();
4040
}
4141

42-
public function testCreateRequest()
42+
public function testCreateRequest(): void
4343
{
4444
$stdClass = new \stdClass();
4545
$serverRequest = new ServerRequest(
@@ -84,7 +84,7 @@ public function testCreateRequest()
8484
$this->assertEquals(['a', 'b'], $symfonyRequest->headers->all('X-data'));
8585
}
8686

87-
public function testCreateRequestWithNullParsedBody()
87+
public function testCreateRequestWithNullParsedBody(): void
8888
{
8989
$serverRequest = new ServerRequest(
9090
'1.1',
@@ -104,7 +104,7 @@ public function testCreateRequestWithNullParsedBody()
104104
$this->assertCount(0, $this->factory->createRequest($serverRequest)->request);
105105
}
106106

107-
public function testCreateRequestWithObjectParsedBody()
107+
public function testCreateRequestWithObjectParsedBody(): void
108108
{
109109
$serverRequest = new ServerRequest(
110110
'1.1',
@@ -124,7 +124,7 @@ public function testCreateRequestWithObjectParsedBody()
124124
$this->assertCount(0, $this->factory->createRequest($serverRequest)->request);
125125
}
126126

127-
public function testCreateRequestWithUri()
127+
public function testCreateRequestWithUri(): void
128128
{
129129
$serverRequest = new ServerRequest(
130130
'1.1',
@@ -144,7 +144,7 @@ public function testCreateRequestWithUri()
144144
$this->assertEquals('/about/kevin', $this->factory->createRequest($serverRequest)->getPathInfo());
145145
}
146146

147-
public function testCreateUploadedFile()
147+
public function testCreateUploadedFile(): void
148148
{
149149
$uploadedFile = $this->createUploadedFile('An uploaded file.', UPLOAD_ERR_OK, 'myfile.txt', 'text/plain');
150150
$symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile);
@@ -161,7 +161,7 @@ public function testCreateUploadedFile()
161161
$this->assertEquals('An uploaded file.', file_get_contents($this->tmpDir.'/'.$uniqid));
162162
}
163163

164-
public function testCreateUploadedFileWithError()
164+
public function testCreateUploadedFileWithError(): void
165165
{
166166
$this->expectException(FileException::class);
167167
$this->expectExceptionMessage('The file "e" could not be written on disk.');
@@ -174,15 +174,15 @@ public function testCreateUploadedFileWithError()
174174
$symfonyUploadedFile->move($this->tmpDir, 'shouldFail.txt');
175175
}
176176

177-
private function createUploadedFile($content, $error, $clientFileName, $clientMediaType)
177+
private function createUploadedFile($content, $error, $clientFileName, $clientMediaType): UploadedFile
178178
{
179179
$filePath = tempnam($this->tmpDir, uniqid());
180180
file_put_contents($filePath, $content);
181181

182182
return new UploadedFile($filePath, filesize($filePath), $error, $clientFileName, $clientMediaType);
183183
}
184184

185-
private function callCreateUploadedFile(UploadedFileInterface $uploadedFile)
185+
private function callCreateUploadedFile(UploadedFileInterface $uploadedFile): \Symfony\Component\HttpFoundation\File\UploadedFile
186186
{
187187
$reflection = new \ReflectionClass($this->factory);
188188
$createUploadedFile = $reflection->getMethod('createUploadedFile');
@@ -191,7 +191,7 @@ private function callCreateUploadedFile(UploadedFileInterface $uploadedFile)
191191
return $createUploadedFile->invokeArgs($this->factory, [$uploadedFile]);
192192
}
193193

194-
public function testCreateResponse()
194+
public function testCreateResponse(): void
195195
{
196196
$response = new Response(
197197
'1.0',

Tests/Factory/PsrHttpFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313

1414
use Nyholm\Psr7\Factory\Psr17Factory;
1515
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
16+
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
1617

1718
/**
1819
* @author Kévin Dunglas <[email protected]>
1920
* @author Antonio J. García Lagar <[email protected]>
2021
*/
2122
class PsrHttpFactoryTest extends AbstractHttpMessageFactoryTest
2223
{
23-
protected function buildHttpMessageFactory()
24+
protected function buildHttpMessageFactory(): HttpMessageFactoryInterface
2425
{
2526
$factory = new Psr17Factory();
2627

0 commit comments

Comments
 (0)