Skip to content

Commit

Permalink
[7.x] Supports PHP 8.4 (#182)
Browse files Browse the repository at this point in the history
* [7.x] Supports PHP 8.4

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* Apply fixes from StyleCI

* wip

* wip

* wip

* wip

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
crynobone and StyleCIBot authored Nov 21, 2024
1 parent cc4c1a7 commit 6d17635
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 55 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.2, 8.3]
php: [8.2, 8.3, 8.4]
phpunit: [10, 11]
laravel: [10, 11]
exclude:
- php: 8.4
laravel: 10
- phpunit: 11
laravel: 10

Expand All @@ -41,18 +43,18 @@ jobs:

- name: Install dependencies
run: |
composer update --with=laravel/framework=^${{ matrix.laravel }} --with=phpunit/phpunit:^${{ matrix.phpunit }} --prefer-dist --no-interaction --no-progress
composer update --prefer-dist --no-interaction --no-progress --with="laravel/framework=^${{ matrix.laravel }}" --with="phpunit/phpunit:^${{ matrix.phpunit }}"
- name: Execute tests
run: vendor/bin/phpunit
run: vendor/bin/phpunit --display-deprecations --fail-on-deprecation

paratests:
runs-on: ubuntu-22.04

strategy:
fail-fast: true
matrix:
php: [8.2, 8.3]
php: [8.2, 8.3, 8.4]

name: PHP ${{ matrix.php }} Paratest

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"symfony/http-kernel": "^6.2|^7.0"
},
"require-dev": {
"laravel/pint": "^1.17",
"orchestra/testbench-core": "^8.21|^9.0"
},
"autoload": {
Expand Down
6 changes: 6 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"preset": "laravel",
"rules": {
"no_superfluous_phpdoc_tags": false
}
}
10 changes: 5 additions & 5 deletions src/Concerns/MakesHttpRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function handle(Request $request)
* @param array|null $data
* @return $this
*/
protected function shouldReturnJson(array $data = null)
protected function shouldReturnJson(?array $data = null)
{
return $this->receiveJson($data);
}
Expand All @@ -391,7 +391,7 @@ protected function shouldReturnJson(array $data = null)
* @param array|null $data
* @return $this|null
*/
protected function receiveJson(array $data = null)
protected function receiveJson(?array $data = null)
{
return $this->seeJson($data);
}
Expand All @@ -416,7 +416,7 @@ public function seeJsonEquals(array $data)
* @param bool $negate
* @return $this
*/
public function seeJson(array $data = null, $negate = false)
public function seeJson(?array $data = null, $negate = false)
{
if (is_null($data)) {
$decodedResponse = json_decode($this->response->getContent(), true);
Expand All @@ -442,7 +442,7 @@ public function seeJson(array $data = null, $negate = false)
* @param array|null $data
* @return $this
*/
public function dontSeeJson(array $data = null)
public function dontSeeJson(?array $data = null)
{
return $this->seeJson($data, true);
}
Expand All @@ -454,7 +454,7 @@ public function dontSeeJson(array $data = null)
* @param array|null $responseData
* @return $this
*/
public function seeJsonStructure(array $structure = null, $responseData = null)
public function seeJsonStructure(?array $structure = null, $responseData = null)
{
$this->response->assertJsonStructure($structure, $responseData);

Expand Down
2 changes: 1 addition & 1 deletion src/Constraints/HasLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HasLink extends PageConstraint
*
* @var string|null
*/
protected readonly string|null $url;
protected readonly ?string $url;

/**
* Create a new constraint instance.
Expand Down
6 changes: 3 additions & 3 deletions src/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

abstract class TestCase extends BaseTestCase
{
use Concerns\InteractsWithContainer,
Concerns\MakesHttpRequests,
Concerns\ImpersonatesUsers,
use Concerns\ImpersonatesUsers,
Concerns\InteractsWithAuthentication,
Concerns\InteractsWithConsole,
Concerns\InteractsWithContainer,
Concerns\InteractsWithDatabase,
Concerns\InteractsWithExceptionHandling,
Concerns\InteractsWithSession,
Concerns\MakesHttpRequests,
InteractsWithTestCaseLifecycle;

/**
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/InteractsWithAuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected function createUserProviderToCredentials()
return new class
{
public $retrieveByCredentials;

public $validateCredentials;

public function make()
Expand Down
3 changes: 1 addition & 2 deletions tests/Unit/InteractsWithContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public function instance()
}
};
$abstract = 'Foo';
$instance = new class {
};
$instance = new class {};
$this->assertEquals(
$instance,
$this->instance($abstract, $instance)
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/InteractsWithDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

class InteractsWithDatabaseTest extends TestCase
{
use InteractsWithDatabase,
InteractsWithConsole;
use InteractsWithConsole,
InteractsWithDatabase;

protected $app;

Expand Down
39 changes: 16 additions & 23 deletions tests/Unit/InteractsWithExceptionHandlingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InteractsWithExceptionHandlingTest extends TestCase
#[Test]
public function withExceptionHandling_restore_exception_handling()
{
$this->app = new Application();
$this->app = new Application;
$this->previousExceptionHandler = 'MyExceptionHandler';
$this->withExceptionHandling();
$this->assertEquals(
Expand All @@ -33,8 +33,8 @@ public function withExceptionHandling_restore_exception_handling()
#[Test]
public function withoutExceptionHandling_disable_exception_handling_for_the_test()
{
$this->app = new Application();
$this->app->instance(ExceptionHandler::class, new ExceptionHandlerStub());
$this->app = new Application;
$this->app->instance(ExceptionHandler::class, new ExceptionHandlerStub);
$this->assertNull($this->previousExceptionHandler);
$this->withoutExceptionHandling();
$this->assertInstanceOf(
Expand All @@ -48,9 +48,8 @@ public function withExceptionHandling_throw_exception_NotFoundHttpException()
{
$this->expectException(NotFoundHttpException::class);
$this->expectExceptionMessage('Abort 404');
$this->app = new Application();
$this->app->instance(ExceptionHandler::class, new class {
});
$this->app = new Application;
$this->app->instance(ExceptionHandler::class, new class {});

$this->withoutExceptionHandling();
abort(404, 'Abort 404');
Expand All @@ -59,9 +58,8 @@ public function withExceptionHandling_throw_exception_NotFoundHttpException()
#[Test]
public function report_of_instance_ExceptionHandler_on_Application_does_nothing()
{
$this->app = new Application();
$this->app->instance(ExceptionHandler::class, new class {
});
$this->app = new Application;
$this->app->instance(ExceptionHandler::class, new class {});

$this->withoutExceptionHandling();
$this->assertNull(app(ExceptionHandler::class)->report(new Exception));
Expand All @@ -73,9 +71,8 @@ public function render_of_instance_ExceptionHandler_on_Application_throw_excepti
$this->expectException(NotFoundHttpException::class);
$this->expectExceptionMessage('GET http://localhost');

$this->app = new Application();
$this->app->instance(ExceptionHandler::class, new class {
});
$this->app = new Application;
$this->app->instance(ExceptionHandler::class, new class {});

$request = new class
{
Expand Down Expand Up @@ -105,12 +102,10 @@ public function render_of_instance_ExceptionHandler_on_Application_throw_excepti
$this->expectException(Exception::class);
$this->expectExceptionMessage('My Exception');

$this->app = new Application();
$this->app->instance(ExceptionHandler::class, new class {
});
$this->app = new Application;
$this->app->instance(ExceptionHandler::class, new class {});

$request = new class {
};
$request = new class {};

$this->withoutExceptionHandling();

Expand All @@ -120,9 +115,8 @@ public function render_of_instance_ExceptionHandler_on_Application_throw_excepti
#[Test]
public function renderForConsole_throw_exception_to_console_and_does_nothing()
{
$this->app = new Application();
$this->app->instance(ExceptionHandler::class, new class {
});
$this->app = new Application;
$this->app->instance(ExceptionHandler::class, new class {});
$output = new OutputStub;
$this->withoutExceptionHandling();

Expand All @@ -135,9 +129,8 @@ public function renderForConsole_throw_exception_to_console_and_does_nothing()
#[Test]
public function withoutExceptionHandling_doesnt_not_report_exceptions()
{
$this->app = new Application();
$this->app->instance(ExceptionHandler::class, new class {
});
$this->app = new Application;
$this->app->instance(ExceptionHandler::class, new class {});
$this->withoutExceptionHandling();
$this->assertFalse(
app(ExceptionHandler::class)->shouldReport(new NotFoundHttpException)
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/InteractsWithPagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class InteractsWithPagesTest extends TestCase
use InteractsWithPages;

protected $app;

protected $response;

protected $currentUri;

#[Test]
Expand Down
23 changes: 8 additions & 15 deletions tests/Unit/InteractsWithSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public function wasCalledPutMethod($times)
return $times == $this->put;
}
};
$this->app['session.store'] = new class {
};
$this->app['session.store'] = new class {};

$this->session([
'foo' => 'bar',
Expand Down Expand Up @@ -68,8 +67,7 @@ public function wasCalledPutMethod($times)
return $times == $this->put;
}
};
$this->app['session.store'] = new class {
};
$this->app['session.store'] = new class {};

$this->withSession([
'foo' => 'bar',
Expand Down Expand Up @@ -133,8 +131,7 @@ public function isCalledFlushMethod()
#[Test]
public function check_if_exists_data_on_session_and_check_exist_key()
{
$this->app['session'] = new class {
};
$this->app['session'] = new class {};
$this->app['session.store'] = new class
{
public function get($key)
Expand All @@ -157,8 +154,7 @@ public function has($key)
#[Test]
public function check_multi_data_on_session_and_check_multi_keys()
{
$this->app['session'] = new class {
};
$this->app['session'] = new class {};
$this->app['session.store'] = new class
{
protected $data = [
Expand Down Expand Up @@ -193,8 +189,7 @@ public function has($key)
#[Test]
public function check_not_exists_key_and_multi_key_on_session()
{
$this->app['session'] = new class {
};
$this->app['session'] = new class {};
$this->app['session.store'] = new class
{
public function has($key)
Expand All @@ -209,8 +204,7 @@ public function has($key)
#[Test]
public function check_if_exists_errors_on_session()
{
$this->app['session'] = new class {
};
$this->app['session'] = new class {};
$this->app['session.store'] = new class
{
public function get($key)
Expand All @@ -229,7 +223,7 @@ public function has($key)
#[Test]
public function check_if_exists_errors_with_value_on_session()
{
$this->app = new Application();
$this->app = new Application;
$this->app['session.store'] = new class
{
public function get($key)
Expand All @@ -254,8 +248,7 @@ public function has($key)
#[Test]
public function check_if_exists_old_input_on_session()
{
$this->app['session'] = new class {
};
$this->app['session'] = new class {};
$this->app['session.store'] = new class
{
public function has($key)
Expand Down

0 comments on commit 6d17635

Please sign in to comment.