diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 68f3e9b..e38fe00 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,12 +15,18 @@ jobs: strategy: fail-fast: false matrix: - php: [ 8.0, 8.1, 8.2 ] - laravel: [ '^9.0', '^10.0' ] + php: [ 8.0, 8.1, 8.2, 8.3 ] + laravel: [ '^9.0', '^10.0', '^11.0' ] dependency-version: [prefer-lowest, prefer-stable] exclude: - - php: 8.0 - laravel: '^10.0' + - laravel: '^9.0' + php: 8.3 + - laravel: '^10.0' + php: 8.0 + - laravel: '^11.0' + php: 8.0 + - laravel: '^11.0' + php: 8.1 name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }} @@ -29,10 +35,10 @@ jobs: run: sudo apt-get update --fix-missing - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.composer/cache/files key: laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} @@ -42,7 +48,7 @@ jobs: with: php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick - coverage: none + coverage: xdebug - name: Validate composer.json run: composer validate @@ -53,4 +59,4 @@ jobs: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest - name: Execute tests - run: vendor/bin/phpunit --verbose + run: vendor/bin/phpunit diff --git a/composer.json b/composer.json index 7131fed..0b940e7 100644 --- a/composer.json +++ b/composer.json @@ -15,12 +15,12 @@ ], "require": { "php": "^8.0", - "illuminate/support": "^9.0 || ^10.0", - "illuminate/http": "^9.0 || ^10.0" + "illuminate/support": "^9.0 || ^10.0 || ^11.0", + "illuminate/http": "^9.0 || ^10.0 || ^11.0" }, "require-dev": { - "orchestra/testbench": "^7.3 || ^8.0", - "phpunit/phpunit": "^9.5" + "orchestra/testbench": "^7.3 || ^8.0 || ^9.0", + "phpunit/phpunit": "^9.5 || ^10.5" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 13f7337..4a2475d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,24 +1,21 @@ - - - - src/ - - - - - - - - tests - - - - - - + + + + + + + + + tests + + + + + + + + src/ + + diff --git a/phpunit.xml.dist.bak b/phpunit.xml.dist.bak new file mode 100644 index 0000000..13f7337 --- /dev/null +++ b/phpunit.xml.dist.bak @@ -0,0 +1,24 @@ + + + + + src/ + + + + + + + + tests + + + + + + + diff --git a/tests/Driver/BlueimpHandlerTest.php b/tests/Driver/BlueimpHandlerTest.php index 07bf496..b0bff43 100644 --- a/tests/Driver/BlueimpHandlerTest.php +++ b/tests/Driver/BlueimpHandlerTest.php @@ -11,6 +11,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Storage; +use Illuminate\Testing\TestResponse; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; @@ -60,14 +61,14 @@ public function testMethodNotAllowed($requestMethod) $this->expectException(MethodNotAllowedHttpException::class); - $this->createTestResponse($this->handler->handle($request)); + TestResponse::fromBaseResponse($this->handler->handle($request)); } public function testInfo() { $request = Request::create('', Request::METHOD_HEAD); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertHeader('Pragma', 'no-cache'); @@ -86,7 +87,7 @@ public function testResume() 'totalSize' => '200', ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson([ @@ -128,7 +129,7 @@ public function testUploadFirstChunk() 'HTTP_CONTENT_RANGE' => 'bytes 0-99/200', ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 50]); @@ -168,7 +169,7 @@ public function testUploadLastChunk() 'HTTP_CONTENT_RANGE' => 'bytes 100-199/200', ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 100]); diff --git a/tests/Driver/DropzoneHandlerTest.php b/tests/Driver/DropzoneHandlerTest.php index 4b5dc90..5666d38 100644 --- a/tests/Driver/DropzoneHandlerTest.php +++ b/tests/Driver/DropzoneHandlerTest.php @@ -11,6 +11,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Storage; +use Illuminate\Testing\TestResponse; use Illuminate\Validation\ValidationException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; @@ -65,7 +66,7 @@ public function testMethodNotAllowed($requestMethod) $this->expectException(MethodNotAllowedHttpException::class); - $this->createTestResponse($this->handler->handle($request)); + TestResponse::fromBaseResponse($this->handler->handle($request)); } public function testUploadWhenFileParameterIsEmpty() @@ -97,7 +98,7 @@ public function testUploadMonolith() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 100]); @@ -179,7 +180,7 @@ public function testUploadFirstChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 50]); @@ -229,7 +230,7 @@ public function testUploadLastChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 100]); diff --git a/tests/Driver/FlowJsHandlerTest.php b/tests/Driver/FlowJsHandlerTest.php index df92ee7..aaabb66 100644 --- a/tests/Driver/FlowJsHandlerTest.php +++ b/tests/Driver/FlowJsHandlerTest.php @@ -11,6 +11,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Storage; +use Illuminate\Testing\TestResponse; use Illuminate\Validation\ValidationException; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; @@ -66,7 +67,7 @@ public function testMethodNotAllowed($requestMethod) $this->expectException(MethodNotAllowedHttpException::class); - $this->createTestResponse($this->handler->handle($request)); + TestResponse::fromBaseResponse($this->handler->handle($request)); } public function testResumeWhenChunkDoesNotExists() @@ -84,7 +85,7 @@ public function testResumeWhenChunkDoesNotExists() 'flowCurrentChunkSize' => 100, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertStatus(Response::HTTP_NO_CONTENT); } @@ -103,7 +104,7 @@ public function testResume() 'flowCurrentChunkSize' => 100, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); } @@ -187,7 +188,7 @@ public function testUploadFirstChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 50]); @@ -241,7 +242,7 @@ public function testUploadLastChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 100]); diff --git a/tests/Driver/MonolithHandlerTest.php b/tests/Driver/MonolithHandlerTest.php index 48ea105..9e81c8b 100644 --- a/tests/Driver/MonolithHandlerTest.php +++ b/tests/Driver/MonolithHandlerTest.php @@ -11,6 +11,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Storage; +use Illuminate\Testing\TestResponse; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; @@ -63,7 +64,7 @@ public function testMethodNotAllowed($requestMethod) $this->expectException(MethodNotAllowedHttpException::class); - $this->createTestResponse($this->handler->handle($request)); + TestResponse::fromBaseResponse($this->handler->handle($request)); } public function testUploadWhenFileParameterIsEmpty() @@ -95,7 +96,7 @@ public function testUpload() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); Storage::disk('local')->assertExists($file->hashName('merged')); diff --git a/tests/Driver/NgFileHandlerTest.php b/tests/Driver/NgFileHandlerTest.php index 0f7b9ad..90e0f90 100644 --- a/tests/Driver/NgFileHandlerTest.php +++ b/tests/Driver/NgFileHandlerTest.php @@ -11,6 +11,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Storage; +use Illuminate\Testing\TestResponse; use Illuminate\Validation\ValidationException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; @@ -65,7 +66,7 @@ public function testMethodNotAllowed($requestMethod) $this->expectException(MethodNotAllowedHttpException::class); - $this->createTestResponse($this->handler->handle($request)); + TestResponse::fromBaseResponse($this->handler->handle($request)); } public function testResumeWhenChunkDoesNotExists() @@ -75,7 +76,7 @@ public function testResumeWhenChunkDoesNotExists() 'totalSize' => '200', ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['size' => 0]); } @@ -89,7 +90,7 @@ public function testResume() 'totalSize' => '200', ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['size' => 100]); } @@ -123,7 +124,7 @@ public function testUploadMonolith() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 100]); @@ -200,7 +201,7 @@ public function testUploadFirstChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 50]); @@ -246,7 +247,7 @@ public function testUploadLastChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 100]); diff --git a/tests/Driver/PluploadHandlerTest.php b/tests/Driver/PluploadHandlerTest.php index 0cec954..e8a9f6a 100644 --- a/tests/Driver/PluploadHandlerTest.php +++ b/tests/Driver/PluploadHandlerTest.php @@ -11,6 +11,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Storage; +use Illuminate\Testing\TestResponse; use Illuminate\Validation\ValidationException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; @@ -66,7 +67,7 @@ public function testMethodNotAllowed($requestMethod) $this->expectException(MethodNotAllowedHttpException::class); - $this->createTestResponse($this->handler->handle($request)); + TestResponse::fromBaseResponse($this->handler->handle($request)); } public function testUploadWhenFileParameterIsEmpty() @@ -134,7 +135,7 @@ public function testUploadFirstChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 50]); @@ -178,7 +179,7 @@ public function testUploadLastChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 100]); diff --git a/tests/Driver/ResumableJsHandlerTest.php b/tests/Driver/ResumableJsHandlerTest.php index 90281b7..2beab0b 100644 --- a/tests/Driver/ResumableJsHandlerTest.php +++ b/tests/Driver/ResumableJsHandlerTest.php @@ -11,6 +11,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Storage; +use Illuminate\Testing\TestResponse; use Illuminate\Validation\ValidationException; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; @@ -66,7 +67,7 @@ public function testMethodNotAllowed($requestMethod) $this->expectException(MethodNotAllowedHttpException::class); - $this->createTestResponse($this->handler->handle($request)); + TestResponse::fromBaseResponse($this->handler->handle($request)); } public function testResumeWhenChunkDoesNotExists() @@ -85,7 +86,7 @@ public function testResumeWhenChunkDoesNotExists() 'resumableType' => 'text/plain', ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertStatus(Response::HTTP_NO_CONTENT); } @@ -105,7 +106,7 @@ public function testResume() 'resumableType' => 'text/plain', ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); } @@ -192,7 +193,7 @@ public function testUploadFirstChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 50]); @@ -248,7 +249,7 @@ public function testUploadLastChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 100]); diff --git a/tests/Driver/SimpleUploaderJsHandlerTest.php b/tests/Driver/SimpleUploaderJsHandlerTest.php index 10ea0f4..24a6e25 100644 --- a/tests/Driver/SimpleUploaderJsHandlerTest.php +++ b/tests/Driver/SimpleUploaderJsHandlerTest.php @@ -11,6 +11,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Storage; +use Illuminate\Testing\TestResponse; use Illuminate\Validation\ValidationException; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; @@ -66,7 +67,7 @@ public function testMethodNotAllowed($requestMethod) $this->expectException(MethodNotAllowedHttpException::class); - $this->createTestResponse($this->handler->handle($request)); + TestResponse::fromBaseResponse($this->handler->handle($request)); } public function testResumeWhenChunkDoesNotExists() @@ -84,7 +85,7 @@ public function testResumeWhenChunkDoesNotExists() 'currentChunkSize' => 100, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertStatus(Response::HTTP_NO_CONTENT); } @@ -103,7 +104,7 @@ public function testResume() 'currentChunkSize' => 100, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); } @@ -187,7 +188,7 @@ public function testUploadFirstChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 50]); @@ -241,7 +242,7 @@ public function testUploadLastChunk() 'file' => $file, ]); - $response = $this->createTestResponse($this->handler->handle($request)); + $response = TestResponse::fromBaseResponse($this->handler->handle($request)); $response->assertSuccessful(); $response->assertJson(['done' => 100]); diff --git a/tests/IdentityManagerTest.php b/tests/IdentityManagerTest.php index 888a1f0..f3a0b63 100644 --- a/tests/IdentityManagerTest.php +++ b/tests/IdentityManagerTest.php @@ -24,7 +24,7 @@ protected function setUp(): void $this->manager = new IdentityManager($this->app); } - public function availableDrivers() + public static function availableDrivers() { return [ 'auth' => ['auth', AuthIdentifier::class], diff --git a/tests/Range/NgFileUploadRangeTest.php b/tests/Range/NgFileUploadRangeTest.php index 6425bc5..713ddf9 100644 --- a/tests/Range/NgFileUploadRangeTest.php +++ b/tests/Range/NgFileUploadRangeTest.php @@ -10,7 +10,7 @@ class NgFileUploadRangeTest extends TestCase { - public function invalidArgumentProvider() + public static function invalidArgumentProvider() { return [ 'Chunk number less than zero' => [-1, 10, 10, 100, '`_chunkNumber` must be greater than or equal to zero'], diff --git a/tests/Range/PluploadRangeTest.php b/tests/Range/PluploadRangeTest.php index a634f95..469f454 100644 --- a/tests/Range/PluploadRangeTest.php +++ b/tests/Range/PluploadRangeTest.php @@ -10,7 +10,7 @@ class PluploadRangeTest extends TestCase { - public function invalidArgumentProvider() + public static function invalidArgumentProvider() { return [ 'Number of chunks size equal to zero' => [-1, 10, '`chunk` must be greater than or equal to zero'], diff --git a/tests/Response/PercentageJsonResponseTest.php b/tests/Response/PercentageJsonResponseTest.php index ab38918..ab14781 100644 --- a/tests/Response/PercentageJsonResponseTest.php +++ b/tests/Response/PercentageJsonResponseTest.php @@ -12,7 +12,7 @@ class PercentageJsonResponseTest extends TestCase { use MakesHttpRequests; - public function percentageProvider() + public static function percentageProvider() { return [ [21, ['done' => 21]], @@ -33,7 +33,7 @@ public function testContent(int $percentage, array $expectedContent) if (class_exists('\Illuminate\Testing\TestResponse')) { $response = TestResponse::fromBaseResponse(new PercentageJsonResponse($percentage)); } else { - $response = $this->createTestResponse(new PercentageJsonResponse($percentage)); + $response = TestResponse::fromBaseResponse(new PercentageJsonResponse($percentage)); } $response->assertSuccessful(); diff --git a/tests/TestCase.php b/tests/TestCase.php index f3eef4d..1fcb303 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -41,7 +41,7 @@ protected function createClosureMock($expects, ...$arguments) { /** @var \Closure|\PHPUnit\Framework\MockObject\MockObject $callback */ $callback = $this->getMockBuilder(\stdClass::class) - ->setMethods(['__invoke']) + ->addMethods(['__invoke']) ->getMock(); $callback->expects($expects) ->method('__invoke') diff --git a/tests/UploadManagerTest.php b/tests/UploadManagerTest.php index 342cf24..c27b31a 100644 --- a/tests/UploadManagerTest.php +++ b/tests/UploadManagerTest.php @@ -29,7 +29,7 @@ protected function setUp(): void $this->manager = new UploadManager($this->app); } - public function availableDrivers() + public static function availableDrivers() { return [ 'monolith' => ['monolith', MonolithHandler::class],