Skip to content

Commit 587a55f

Browse files
nunomadurocrynoboneStyleCIBot
authored
[1.x] Merges develop (#515)
* Adds L11 support * Removes verbose * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Drops PHP 7.3 and PHP 7.4, and Laravel 8 * Migrates phpunit file * Drops PHP 8.0 * Adjust workflows * Drops L9 * Fixes test suite * Fixes `home` configuration * Apply fixes from StyleCI * wip * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip * Uses PHPUnit 10.4 * Uses `publishesMigrations` (#509) * Fixes tests * Apply fixes from StyleCI --------- Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io>
1 parent 2029e69 commit 587a55f

9 files changed

+48
-58
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,11 @@ jobs:
1616
strategy:
1717
fail-fast: true
1818
matrix:
19-
php: [7.3, 7.4, '8.0', 8.1, 8.2, 8.3]
20-
laravel: [8, 9, 10]
19+
php: [8.1, 8.2, 8.3]
20+
laravel: [10, 11]
2121
exclude:
22-
- php: 7.3
23-
laravel: 9
24-
- php: 7.3
25-
laravel: 10
26-
- php: 7.4
27-
laravel: 9
28-
- php: 7.4
29-
laravel: 10
30-
- php: '8.0'
31-
laravel: 10
32-
- php: 8.3
33-
laravel: 8
34-
- php: 8.3
35-
laravel: 9
22+
- php: 8.1
23+
laravel: 11
3624

3725
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
3826

@@ -53,4 +41,4 @@ jobs:
5341
run: composer require "illuminate/contracts=^${{ matrix.laravel }}" --prefer-dist --no-interaction
5442

5543
- name: Execute tests
56-
run: vendor/bin/phpunit --verbose
44+
run: vendor/bin/phpunit

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
}
1515
],
1616
"require": {
17-
"php": "^7.3|^8.0",
17+
"php": "^8.1",
1818
"ext-json": "*",
1919
"bacon/bacon-qr-code": "^2.0",
20-
"illuminate/support": "^8.82|^9.0|^10.0",
21-
"pragmarx/google2fa": "^7.0|^8.0"
20+
"illuminate/support": "^10.0|^11.0",
21+
"pragmarx/google2fa": "^8.0"
2222
},
2323
"require-dev": {
2424
"mockery/mockery": "^1.0",
25-
"orchestra/testbench": "^6.34|^7.31|^8.11",
25+
"orchestra/testbench": "^8.16|^9.0",
2626
"phpstan/phpstan": "^1.10",
27-
"phpunit/phpunit": "^9.3"
27+
"phpunit/phpunit": "^10.4"
2828
},
2929
"autoload": {
3030
"psr-4": {

phpunit.xml.dist

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
bootstrap="vendor/autoload.php"
5-
colors="true"
6-
convertDeprecationsToExceptions="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false"
12-
>
2+
<phpunit colors="true">
133
<testsuites>
144
<testsuite name="Fortify Test Suite">
15-
<directory suffix=".php">./tests/</directory>
5+
<directory suffix="Test.php">./tests/</directory>
166
</testsuite>
177
</testsuites>
188
<php>
19-
<server name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
9+
<env name="APP_KEY" value="base64:uz4B1RtFO57QGzbZX1kRYX9hIRB50+QzqFeg9zbFJlY="/>
2010
</php>
2111
</phpunit>

src/FortifyServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ protected function configurePublishing()
136136
__DIR__.'/../stubs/UpdateUserPassword.php' => app_path('Actions/Fortify/UpdateUserPassword.php'),
137137
], 'fortify-support');
138138

139-
$this->publishes([
139+
$method = method_exists($this, 'publishesMigrations') ? 'publishesMigrations' : 'publishes';
140+
141+
$this->{$method}([
140142
__DIR__.'/../database/migrations' => database_path('migrations'),
141143
], 'fortify-migrations');
142144
}

stubs/fortify.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
use App\Providers\RouteServiceProvider;
43
use Laravel\Fortify\Features;
54

65
return [
@@ -74,7 +73,7 @@
7473
|
7574
*/
7675

77-
'home' => RouteServiceProvider::HOME,
76+
'home' => '/home',
7877

7978
/*
8079
|--------------------------------------------------------------------------

tests/AuthenticatedSessionControllerTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
use Laravel\Fortify\LoginRateLimiter;
1717
use Laravel\Fortify\TwoFactorAuthenticatable;
1818
use Mockery;
19+
use Orchestra\Testbench\Attributes\WithMigration;
1920
use PragmaRX\Google2FA\Google2FA;
2021

22+
#[WithMigration]
2123
class AuthenticatedSessionControllerTest extends OrchestraTestCase
2224
{
2325
use RefreshDatabase;
@@ -210,12 +212,12 @@ static function ($mock) use ($username) {
210212
self::assertSame($expectedResult.'|192.168.0.1', $method->invoke($loginRateLimiter, $request));
211213
}
212214

213-
public function usernameProvider(): array
215+
public static function usernameProvider(): array
214216
{
215217
return [
216218
'lowercase special characters' => ['ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ', 'test@laravel.com'],
217219
'uppercase special characters' => ['ⓉⒺⓈⓉ@ⓁⒶⓇⒶⓋⒺⓁ.ⒸⓄⓂ', 'test@laravel.com'],
218-
'special character numbers' =>['test⑩⓸③@laravel.com', 'test1043@laravel.com'],
220+
'special character numbers' => ['test⑩⓸③@laravel.com', 'test1043@laravel.com'],
219221
'default email' => ['test@laravel.com', 'test@laravel.com'],
220222
];
221223
}

tests/ConfirmablePasswordControllerTest.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,22 @@
66
use Illuminate\Foundation\Testing\RefreshDatabase;
77
use Laravel\Fortify\Contracts\ConfirmPasswordViewResponse;
88
use Laravel\Fortify\Fortify;
9+
use Orchestra\Testbench\Attributes\WithMigration;
910

11+
#[WithMigration]
1012
class ConfirmablePasswordControllerTest extends OrchestraTestCase
1113
{
1214
use RefreshDatabase;
1315

1416
protected $user;
1517

16-
protected function setUp(): void
18+
protected function afterRefreshingDatabase()
1719
{
18-
$this->afterApplicationCreated(function () {
19-
$this->user = TestConfirmPasswordUser::forceCreate([
20-
'name' => 'Taylor Otwell',
21-
'email' => 'taylor@laravel.com',
22-
'password' => bcrypt('secret'),
23-
]);
24-
});
25-
26-
parent::setUp();
20+
$this->user = TestConfirmPasswordUser::forceCreate([
21+
'name' => 'Taylor Otwell',
22+
'email' => 'taylor@laravel.com',
23+
'password' => bcrypt('secret'),
24+
]);
2725
}
2826

2927
public function test_the_confirm_password_view_is_returned()

tests/OrchestraTestCase.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22

33
namespace Laravel\Fortify\Tests;
44

5+
use Illuminate\Foundation\Testing\RefreshDatabaseState;
56
use Laravel\Fortify\Features;
6-
use Orchestra\Testbench\Concerns\WithLaravelMigrations;
77
use Orchestra\Testbench\Concerns\WithWorkbench;
88
use Orchestra\Testbench\TestCase;
99

1010
abstract class OrchestraTestCase extends TestCase
1111
{
12-
use WithLaravelMigrations, WithWorkbench;
12+
use WithWorkbench;
13+
14+
public function setUp(): void
15+
{
16+
if (class_exists(RefreshDatabaseState::class)) {
17+
RefreshDatabaseState::$migrated = false;
18+
}
19+
20+
parent::setUp();
21+
}
1322

1423
protected function defineEnvironment($app)
1524
{

tests/TwoFactorAuthenticationControllerTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
use Laravel\Fortify\Events\TwoFactorAuthenticationDisabled;
1010
use Laravel\Fortify\Events\TwoFactorAuthenticationEnabled;
1111
use Laravel\Fortify\TwoFactorAuthenticatable;
12+
use Orchestra\Testbench\Attributes\DefineEnvironment;
13+
use Orchestra\Testbench\Attributes\ResetRefreshDatabaseState;
14+
use Orchestra\Testbench\Attributes\WithMigration;
1215
use PragmaRX\Google2FA\Google2FA;
1316

17+
#[WithMigration]
1418
class TwoFactorAuthenticationControllerTest extends OrchestraTestCase
1519
{
1620
use RefreshDatabase;
@@ -62,9 +66,8 @@ public function test_two_factor_authentication_secret_key_can_be_retrieved()
6266
$this->assertEquals('foo', $response->original['secretKey']);
6367
}
6468

65-
/**
66-
* @define-env withConfirmedTwoFactorAuthentication
67-
*/
69+
#[DefineEnvironment('withConfirmedTwoFactorAuthentication')]
70+
#[ResetRefreshDatabaseState]
6871
public function test_two_factor_authentication_can_be_confirmed()
6972
{
7073
Event::fake();
@@ -100,9 +103,8 @@ public function test_two_factor_authentication_can_be_confirmed()
100103
$this->assertFalse($user->hasEnabledTwoFactorAuthentication());
101104
}
102105

103-
/**
104-
* @define-env withConfirmedTwoFactorAuthentication
105-
*/
106+
#[DefineEnvironment('withConfirmedTwoFactorAuthentication')]
107+
#[ResetRefreshDatabaseState]
106108
public function test_two_factor_authentication_can_not_be_confirmed_with_invalid_code()
107109
{
108110
Event::fake();

0 commit comments

Comments
 (0)