Skip to content

Commit

Permalink
Update to Laravel 6.5 + PHPUnit 8.4 + PHP CS Fixer
Browse files Browse the repository at this point in the history
Original PR #80 by @TheFrankman and #84 @michaelaguiar
  • Loading branch information
TheFrankman authored and pionl committed Nov 5, 2019
1 parent 1f1da75 commit 51f0261
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ composer.phar
/vendor/
composer.lock
/build

.phpunit.result.cache
.php_cs.cache
3 changes: 2 additions & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ return PhpCsFixer\Config::create()
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'no_superfluous_phpdoc_tags' => false,
))
->setFinder($finder);
->setFinder($finder);
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
"test": "./vendor/bin/phpunit"
},
"require": {
"illuminate/http": "5.1 - 5.8",
"illuminate/console": "5.1 - 5.8",
"illuminate/support": "5.1 - 5.8",
"illuminate/filesystem": "5.1 - 5.8"
"illuminate/http": "5.1 - 6.5",
"illuminate/console": "5.1 - 6.5",
"illuminate/support": "5.1 - 6.5",
"illuminate/filesystem": "5.1 - 6.5"
},
"require-dev": {
"laravel/laravel": "5.1 - 5.8",
"phpunit/phpunit": "5.7 || 6.0 || 7.0 || 7.5",
"laravel/laravel": "5.1 - 6.4",
"phpunit/phpunit": "5.7 || 6.0 || 7.0 || 7.5 || 8.4",
"mockery/mockery": "^1.1.0",
"friendsofphp/php-cs-fixer": "^2.12",
"friendsofphp/php-cs-fixer": "^2.16.0",
"overtrue/phplint": "^1.1"
},
"autoload": {
Expand Down
5 changes: 0 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Application Test Suite">
Expand All @@ -18,9 +17,5 @@
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
<exclude>
<directory>vendor/</directory>
<directory>tests/</directory>
</exclude>
</filter>
</phpunit>
4 changes: 2 additions & 2 deletions src/Handler/ContentRangeUploadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Pion\Laravel\ChunkUpload\Exceptions\ChunkSaveException;
use Pion\Laravel\ChunkUpload\Save\ChunkSave;
use Pion\Laravel\ChunkUpload\Config\AbstractConfig;
use Pion\Laravel\ChunkUpload\Exceptions\ChunkSaveException;
use Pion\Laravel\ChunkUpload\Exceptions\ContentRangeValueToLargeException;
use Pion\Laravel\ChunkUpload\Save\ChunkSave;
use Pion\Laravel\ChunkUpload\Storage\ChunkStorage;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Handler/NgFileUploadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Pion\Laravel\ChunkUpload\Handler;

use Pion\Laravel\ChunkUpload\Exceptions\ChunkInvalidValueException;
use Illuminate\Http\Request;
use Pion\Laravel\ChunkUpload\Exceptions\ChunkInvalidValueException;

/**
* Class NgFileUploadHandler.
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/ChunkUploadServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function register()
$request = $app->make('request');

// Get the first file object - must be converted instances of UploadedFile
$file = array_first($request->allFiles());
$file = Arr::first($request->allFiles());

// Build the file receiver
return new FileReceiver($file, $request, HandlerFactory::classFromRequest($request));
Expand Down
2 changes: 1 addition & 1 deletion src/Receiver/FileReceiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Pion\Laravel\ChunkUpload\Receiver;

use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Pion\Laravel\ChunkUpload\Config\AbstractConfig;
use Pion\Laravel\ChunkUpload\Exceptions\UploadFailedException;
use Pion\Laravel\ChunkUpload\Handler\AbstractHandler;
use Pion\Laravel\ChunkUpload\Save\AbstractSave;
use Pion\Laravel\ChunkUpload\Save\ChunkSave;
use Pion\Laravel\ChunkUpload\Save\SingleSave;
use Illuminate\Http\UploadedFile;
use Pion\Laravel\ChunkUpload\Storage\ChunkStorage;

class FileReceiver
Expand Down
4 changes: 2 additions & 2 deletions src/Save/AbstractSave.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Pion\Laravel\ChunkUpload\Save;

use Illuminate\Http\UploadedFile;
use Pion\Laravel\ChunkUpload\Config\AbstractConfig;
use Pion\Laravel\ChunkUpload\Handler\AbstractHandler;
use Symfony\Component\HttpFoundation\File\File;
use Illuminate\Http\UploadedFile;

/**
* Class AbstractSave.
Expand Down Expand Up @@ -95,7 +95,7 @@ public function getFile()
/**
* Returns always the uploaded chunk file.
*
* @return null|UploadedFile
* @return UploadedFile|null
*/
public function getUploadedFile()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Save/ChunkSave.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Pion\Laravel\ChunkUpload\Save;

use Illuminate\Http\UploadedFile;
use Pion\Laravel\ChunkUpload\Config\AbstractConfig;
use Pion\Laravel\ChunkUpload\Exceptions\ChunkSaveException;
use Pion\Laravel\ChunkUpload\FileMerger;
use Pion\Laravel\ChunkUpload\Handler\AbstractHandler;
use Illuminate\Http\UploadedFile;
use Pion\Laravel\ChunkUpload\Storage\ChunkStorage;

class ChunkSave extends AbstractSave
Expand Down Expand Up @@ -122,7 +122,7 @@ public function getChunkDirectory($absolutePath = false)
* Returns the uploaded file if the chunk if is not completed, otherwise passes the
* final chunk file.
*
* @return null|UploadedFile
* @return UploadedFile|null
*/
public function getFile()
{
Expand Down
5 changes: 3 additions & 2 deletions src/Save/ParallelSave.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace Pion\Laravel\ChunkUpload\Save;

use Illuminate\Http\UploadedFile;
use Illuminate\Support\Str;
use Pion\Laravel\ChunkUpload\ChunkFile;
use Pion\Laravel\ChunkUpload\Config\AbstractConfig;
use Pion\Laravel\ChunkUpload\Exceptions\ChunkSaveException;
use Pion\Laravel\ChunkUpload\Exceptions\MissingChunkFilesException;
use Pion\Laravel\ChunkUpload\FileMerger;
use Pion\Laravel\ChunkUpload\Handler\AbstractHandler;
use Pion\Laravel\ChunkUpload\ChunkFile;
use Pion\Laravel\ChunkUpload\Handler\Traits\HandleParallelUploadTrait;
use Pion\Laravel\ChunkUpload\Storage\ChunkStorage;

Expand Down Expand Up @@ -87,7 +88,7 @@ protected function getSavedChunksFiles()
);

return $this->chunkStorage->files(function ($file) use ($chunkFileName) {
return false === str_contains($file, $chunkFileName);
return false === Str::contains($file, $chunkFileName);
});
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Handler/DropZoneUploadHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DropZoneUploadHandlerTest extends TestCase
{
protected $file = null;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->file = UploadedFile::fake()->create('test');
Expand Down
25 changes: 4 additions & 21 deletions tests/Handler/NgFileUploadHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
use Illuminate\Http\UploadedFile;
use PHPUnit\Framework\TestCase;
use Pion\Laravel\ChunkUpload\Config\FileConfig;
use Pion\Laravel\ChunkUpload\Exceptions\ChunkInvalidValueException;
use Pion\Laravel\ChunkUpload\Handler\NgFileUploadHandler;

class NgFileUploadHandlerTest extends TestCase
{
/**
* @throws \Exception
*/
public function testInitWithoutChunk()
{
$request = Request::create('test', 'POST', [], [], [], []);
Expand All @@ -24,9 +22,6 @@ public function testInitWithoutChunk()
$this->assertFalse($ngFileUpload->isChunkedUpload());
}

/**
* @throws \Exception
*/
public function testInitWithChunk()
{
$request = Request::create(
Expand All @@ -47,9 +42,6 @@ public function testInitWithChunk()
$this->assertTrue($ngFileUpload->isChunkedUpload());
}

/**
* @throws \Exception
*/
public function testPercentageDoneWithoutChunk()
{
$request = Request::create('test', 'POST', [], [], [], []);
Expand All @@ -61,9 +53,6 @@ public function testPercentageDoneWithoutChunk()
$this->assertEquals(0, $ngFileUpload->getPercentageDone());
}

/**
* @throws \Exception
*/
public function testValidNgFileUploadFirstChunk()
{
$request = Request::create(
Expand All @@ -88,9 +77,6 @@ public function testValidNgFileUploadFirstChunk()
$this->assertTrue($ngFileUpload->isFirstChunk());
}

/**
* @throws \Exception
*/
public function testValidNgFileUploadNextChunk()
{
$request = Request::create(
Expand All @@ -116,9 +102,6 @@ public function testValidNgFileUploadNextChunk()
$this->assertFalse($ngFileUpload->isFirstChunk());
}

/**
* @throws \Exception
*/
public function testIsLastChunk()
{
$request = Request::create(
Expand Down Expand Up @@ -146,7 +129,7 @@ public function testIsLastChunk()
/**
* Checks if canBeUsedForRequest returns false when chunk is missing.
*
* @throws \Exception
* @throws ChunkInvalidValueException
*/
public function testCanBeUsedForInvalidRequest()
{
Expand All @@ -157,7 +140,7 @@ public function testCanBeUsedForInvalidRequest()
/**
* Checks if canBeUsedForRequest returns false when content-range is invalid.
*
* @throws \Exception
* @throws ChunkInvalidValueException
*/
public function testCanBeUsedForInvalidContentRangeFormat()
{
Expand All @@ -177,7 +160,7 @@ public function testCanBeUsedForInvalidContentRangeFormat()
/**
* Checks if canBeUsedForRequest returns false when content-range is missing.
*
* @throws \Exception
* @throws ChunkInvalidValueException
*/
public function testCanBeUsedForValidRange()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Providers/ChunkUploadServiceProviderMockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($name = null, array $data = [], $dataName = '')
parent::__construct($name, $data, $dataName);
}

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->app = Mockery::mock(\Illuminate\Contracts\Container\Container::class);
Expand Down

0 comments on commit 51f0261

Please sign in to comment.