Skip to content
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

feat: Laravel 11 support #81

Merged
merged 3 commits into from
May 19, 2024
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
22 changes: 14 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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') }}
Expand All @@ -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
Expand All @@ -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
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
41 changes: 19 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Laravel Upload Handler Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
<text outputFile="build/coverage.txt"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<coverage>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Laravel Upload Handler Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
24 changes: 24 additions & 0 deletions phpunit.xml.dist.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Laravel Upload Handler Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
<text outputFile="build/coverage.txt"/>
</logging>
</phpunit>
11 changes: 6 additions & 5 deletions tests/Driver/BlueimpHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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');
Expand All @@ -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([
Expand Down Expand Up @@ -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]);

Expand Down Expand Up @@ -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]);

Expand Down
9 changes: 5 additions & 4 deletions tests/Driver/DropzoneHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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]);

Expand Down Expand Up @@ -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]);

Expand Down Expand Up @@ -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]);

Expand Down
11 changes: 6 additions & 5 deletions tests/Driver/FlowJsHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -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);
}

Expand All @@ -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();
}

Expand Down Expand Up @@ -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]);

Expand Down Expand Up @@ -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]);

Expand Down
5 changes: 3 additions & 2 deletions tests/Driver/MonolithHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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'));
Expand Down
13 changes: 7 additions & 6 deletions tests/Driver/NgFileHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -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]);
}
Expand All @@ -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]);
}
Expand Down Expand Up @@ -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]);

Expand Down Expand Up @@ -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]);

Expand Down Expand Up @@ -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]);

Expand Down
Loading