Skip to content

Allow Symfony 5.0 #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions Tests/Factory/AbstractHttpMessageFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ abstract class AbstractHttpMessageFactoryTest extends TestCase
private $factory;
private $tmpDir;

/**
* @return HttpMessageFactoryInterface
*/
abstract protected function buildHttpMessageFactory();
abstract protected function buildHttpMessageFactory(): HttpMessageFactoryInterface;

public function setup()
public function setUp(): void
{
$this->factory = $this->buildHttpMessageFactory();
$this->tmpDir = sys_get_temp_dir();
Expand Down Expand Up @@ -158,7 +155,7 @@ public function testCreateResponse()
$this->assertEquals(['3.4'], $psrResponse->getHeader('X-Symfony'));

$cookieHeader = $psrResponse->getHeader('Set-Cookie');
$this->assertInternalType('array', $cookieHeader);
$this->assertIsArray($cookieHeader);
$this->assertCount(1, $cookieHeader);
$this->assertRegExp('{city=Lille; expires=Wed, 13-Jan-2021 22:23:01 GMT;( max-age=\d+;)? path=/; httponly}i', $cookieHeader[0]);
}
Expand Down
3 changes: 2 additions & 1 deletion Tests/Factory/DiactorosFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory;

use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;

/**
* @author Kévin Dunglas <[email protected]>
Expand All @@ -21,7 +22,7 @@
*/
class DiactorosFactoryTest extends AbstractHttpMessageFactoryTest
{
protected function buildHttpMessageFactory()
protected function buildHttpMessageFactory(): HttpMessageFactoryInterface
{
if (!class_exists('Zend\Diactoros\ServerRequestFactory')) {
$this->markTestSkipped('Zend Diactoros is not installed.');
Expand Down
17 changes: 9 additions & 8 deletions Tests/Factory/HttpFoundationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\UploadedFile;
use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Uri;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Component\HttpFoundation\File\UploadedFile as HttpFoundationUploadedFile;

/**
* @author Kévin Dunglas <[email protected]>
Expand All @@ -32,7 +34,7 @@ class HttpFoundationFactoryTest extends TestCase
/** @var string */
private $tmpDir;

public function setup()
public function setUp(): void
{
$this->factory = new HttpFoundationFactory();
$this->tmpDir = sys_get_temp_dir();
Expand Down Expand Up @@ -80,7 +82,7 @@ public function testCreateRequest()
$this->assertEquals('France', $symfonyRequest->server->get('country'));
$this->assertEquals('The body', $symfonyRequest->getContent());
$this->assertEquals('1.0', $symfonyRequest->headers->get('X-Dunglas-API-Platform'));
$this->assertEquals(['a', 'b'], $symfonyRequest->headers->get('X-data', null, false));
$this->assertEquals(['a', 'b'], $symfonyRequest->headers->all('X-data'));
}

public function testCreateRequestWithNullParsedBody()
Expand Down Expand Up @@ -160,12 +162,11 @@ public function testCreateUploadedFile()
$this->assertEquals('An uploaded file.', file_get_contents($this->tmpDir.'/'.$uniqid));
}

/**
* @expectedException \Symfony\Component\HttpFoundation\File\Exception\FileException
* @expectedExceptionMessage The file "e" could not be written on disk.
*/
public function testCreateUploadedFileWithError()
{
$this->expectException(FileException::class);
$this->expectExceptionMessage('The file "e" could not be written on disk.');

$uploadedFile = $this->createUploadedFile('Error.', UPLOAD_ERR_CANT_WRITE, 'e', 'text/plain');
$symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile);

Expand All @@ -174,15 +175,15 @@ public function testCreateUploadedFileWithError()
$symfonyUploadedFile->move($this->tmpDir, 'shouldFail.txt');
}

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

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

private function callCreateUploadedFile(UploadedFileInterface $uploadedFile)
private function callCreateUploadedFile(UploadedFileInterface $uploadedFile): HttpFoundationUploadedFile
{
$reflection = new \ReflectionClass($this->factory);
$createUploadedFile = $reflection->getMethod('createUploadedFile');
Expand Down
3 changes: 2 additions & 1 deletion Tests/Factory/PsrHttpFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

use Nyholm\Psr7\Factory\Psr17Factory;
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;

/**
* @author Kévin Dunglas <[email protected]>
* @author Antonio J. García Lagar <[email protected]>
*/
class PsrHttpFactoryTest extends AbstractHttpMessageFactoryTest
{
protected function buildHttpMessageFactory()
protected function buildHttpMessageFactory(): HttpMessageFactoryInterface
{
$factory = new Psr17Factory();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/CovertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CovertTest extends TestCase
{
private $tmpDir;

public function setup()
public function setUp(): void
{
if (!class_exists('Nyholm\Psr7\ServerRequest')) {
$this->markTestSkipped('nyholm/psr7 is not installed.');
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"require": {
"php": "^7.1",
"psr/http-message": "^1.0",
"symfony/http-foundation": "^3.4 || ^4.0"
"symfony/http-foundation": "^4.4 || ^5.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^3.4.20 || ^4.0",
"symfony/phpunit-bridge": "^4.4 || ^5.0",
"nyholm/psr7": "^1.1",
"zendframework/zend-diactoros": "^1.4.1 || ^2.0"
},
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
<testsuites>
Expand Down