Skip to content

Fix CS #91

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
Feb 16, 2021
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
2 changes: 1 addition & 1 deletion Factory/PsrHttpFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function getFiles(array $uploadedFiles)

foreach ($uploadedFiles as $key => $value) {
if (null === $value) {
$files[$key] = $this->uploadedFileFactory->createUploadedFile($this->streamFactory->createStream(), 0, UPLOAD_ERR_NO_FILE);
$files[$key] = $this->uploadedFileFactory->createUploadedFile($this->streamFactory->createStream(), 0, \UPLOAD_ERR_NO_FILE);
continue;
}
if ($value instanceof UploadedFile) {
Expand Down
2 changes: 1 addition & 1 deletion Factory/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(UploadedFileInterface $psrUploadedFile, callable $ge
$error = $psrUploadedFile->getError();
$path = '';

if (UPLOAD_ERR_NO_FILE !== $error) {
if (\UPLOAD_ERR_NO_FILE !== $error) {
$path = $psrUploadedFile->getStream()->getMetadata('uri') ?? '';

if ($this->test = !\is_string($path) || !is_uploaded_file($path)) {
Expand Down
20 changes: 10 additions & 10 deletions Tests/Factory/AbstractHttpMessageFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class AbstractHttpMessageFactoryTest extends TestCase

abstract protected function buildHttpMessageFactory(): HttpMessageFactoryInterface;

public function setUp(): void
protected function setUp(): void
{
$this->factory = $this->buildHttpMessageFactory();
$this->tmpDir = sys_get_temp_dir();
Expand Down Expand Up @@ -61,8 +61,8 @@ public function testCreateRequest()
'c2' => ['c3' => 'bar'],
],
[
'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', UPLOAD_ERR_OK),
'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', UPLOAD_ERR_OK)],
'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', \UPLOAD_ERR_OK),
'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', \UPLOAD_ERR_OK)],
],
[
'REQUEST_METHOD' => 'POST',
Expand Down Expand Up @@ -102,12 +102,12 @@ public function testCreateRequest()
$this->assertEquals('F1', $uploadedFiles['f1']->getStream()->__toString());
$this->assertEquals('f1.txt', $uploadedFiles['f1']->getClientFilename());
$this->assertEquals('text/plain', $uploadedFiles['f1']->getClientMediaType());
$this->assertEquals(UPLOAD_ERR_OK, $uploadedFiles['f1']->getError());
$this->assertEquals(\UPLOAD_ERR_OK, $uploadedFiles['f1']->getError());

$this->assertEquals('F2', $uploadedFiles['foo']['f2']->getStream()->__toString());
$this->assertEquals('f2.txt', $uploadedFiles['foo']['f2']->getClientFilename());
$this->assertEquals('text/plain', $uploadedFiles['foo']['f2']->getClientMediaType());
$this->assertEquals(UPLOAD_ERR_OK, $uploadedFiles['foo']['f2']->getError());
$this->assertEquals(\UPLOAD_ERR_OK, $uploadedFiles['foo']['f2']->getError());

$serverParams = $psrRequest->getServerParams();
$this->assertEquals('POST', $serverParams['REQUEST_METHOD']);
Expand Down Expand Up @@ -201,10 +201,10 @@ public function testCreateResponseFromBinaryFileWithRange()

public function testUploadErrNoFile()
{
$file = new UploadedFile('', '', null, UPLOAD_ERR_NO_FILE, true);
$file = new UploadedFile('', '', null, \UPLOAD_ERR_NO_FILE, true);

$this->assertEquals(0, $file->getSize());
$this->assertEquals(UPLOAD_ERR_NO_FILE, $file->getError());
$this->assertEquals(\UPLOAD_ERR_NO_FILE, $file->getError());
$this->assertFalse($file->getSize(), 'SplFile::getSize() returns false on error');

$request = new Request(
Expand All @@ -214,7 +214,7 @@ public function testUploadErrNoFile()
[],
[
'f1' => $file,
'f2' => ['name' => null, 'type' => null, 'tmp_name' => null, 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0],
'f2' => ['name' => null, 'type' => null, 'tmp_name' => null, 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0],
],
[
'REQUEST_METHOD' => 'POST',
Expand All @@ -228,7 +228,7 @@ public function testUploadErrNoFile()

$uploadedFiles = $psrRequest->getUploadedFiles();

$this->assertEquals(UPLOAD_ERR_NO_FILE, $uploadedFiles['f1']->getError());
$this->assertEquals(UPLOAD_ERR_NO_FILE, $uploadedFiles['f2']->getError());
$this->assertEquals(\UPLOAD_ERR_NO_FILE, $uploadedFiles['f1']->getError());
$this->assertEquals(\UPLOAD_ERR_NO_FILE, $uploadedFiles['f2']->getError());
}
}
16 changes: 8 additions & 8 deletions Tests/Factory/HttpFoundationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class HttpFoundationFactoryTest extends TestCase
/** @var string */
private $tmpDir;

public function setUp(): void
protected function setUp(): void
{
$this->factory = new HttpFoundationFactory();
$this->tmpDir = sys_get_temp_dir();
Expand All @@ -57,11 +57,11 @@ public function testCreateRequest()
['city' => 'Lille'],
['url' => 'http://les-tilleuls.coop'],
[
'doc1' => $this->createUploadedFile('Doc 1', UPLOAD_ERR_OK, 'doc1.txt', 'text/plain'),
'doc1' => $this->createUploadedFile('Doc 1', \UPLOAD_ERR_OK, 'doc1.txt', 'text/plain'),
'nested' => [
'docs' => [
$this->createUploadedFile('Doc 2', UPLOAD_ERR_OK, 'doc2.txt', 'text/plain'),
$this->createUploadedFile('Doc 3', UPLOAD_ERR_OK, 'doc3.txt', 'text/plain'),
$this->createUploadedFile('Doc 2', \UPLOAD_ERR_OK, 'doc2.txt', 'text/plain'),
$this->createUploadedFile('Doc 3', \UPLOAD_ERR_OK, 'doc3.txt', 'text/plain'),
],
],
],
Expand Down Expand Up @@ -168,15 +168,15 @@ public function testCreateRequestWithUri()

public function testCreateUploadedFile()
{
$uploadedFile = $this->createUploadedFile('An uploaded file.', UPLOAD_ERR_OK, 'myfile.txt', 'text/plain');
$uploadedFile = $this->createUploadedFile('An uploaded file.', \UPLOAD_ERR_OK, 'myfile.txt', 'text/plain');
$symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile);
$size = $symfonyUploadedFile->getSize();

$uniqid = uniqid();
$symfonyUploadedFile->move($this->tmpDir, $uniqid);

$this->assertEquals($uploadedFile->getSize(), $size);
$this->assertEquals(UPLOAD_ERR_OK, $symfonyUploadedFile->getError());
$this->assertEquals(\UPLOAD_ERR_OK, $symfonyUploadedFile->getError());
$this->assertEquals('myfile.txt', $symfonyUploadedFile->getClientOriginalName());
$this->assertEquals('txt', $symfonyUploadedFile->getClientOriginalExtension());
$this->assertEquals('text/plain', $symfonyUploadedFile->getClientMimeType());
Expand All @@ -188,10 +188,10 @@ 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');
$uploadedFile = $this->createUploadedFile('Error.', \UPLOAD_ERR_CANT_WRITE, 'e', 'text/plain');
$symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile);

$this->assertEquals(UPLOAD_ERR_CANT_WRITE, $symfonyUploadedFile->getError());
$this->assertEquals(\UPLOAD_ERR_CANT_WRITE, $symfonyUploadedFile->getError());

$symfonyUploadedFile->move($this->tmpDir, 'shouldFail.txt');
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function isSeekable()
return true;
}

public function seek($offset, $whence = SEEK_SET)
public function seek($offset, $whence = \SEEK_SET)
{
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class UploadedFile implements UploadedFileInterface
private $clientFileName;
private $clientMediaType;

public function __construct($filePath, $size = null, $error = UPLOAD_ERR_OK, $clientFileName = null, $clientMediaType = null)
public function __construct($filePath, $size = null, $error = \UPLOAD_ERR_OK, $clientFileName = null, $clientMediaType = null)
{
$this->filePath = $filePath;
$this->size = $size;
Expand Down
8 changes: 4 additions & 4 deletions Tests/Functional/CovertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class CovertTest extends TestCase
{
private $tmpDir;

public function setUp(): void
protected function setUp(): void
{
if (!class_exists('Nyholm\Psr7\ServerRequest')) {
if (!class_exists(Psr7Request::class)) {
$this->markTestSkipped('nyholm/psr7 is not installed.');
}

Expand Down Expand Up @@ -124,8 +124,8 @@ public function requestProvider()
'c2' => ['c3' => 'bar'],
],
[
'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', UPLOAD_ERR_OK),
'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', UPLOAD_ERR_OK)],
'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', \UPLOAD_ERR_OK),
'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', \UPLOAD_ERR_OK)],
],
[
'REQUEST_METHOD' => 'POST',
Expand Down