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

Upgraded Laravel to v8.0 #54

Merged
merged 9 commits into from
Sep 12, 2020
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
2 changes: 1 addition & 1 deletion .github/actions/common/setup
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ commit="tmp-$(git rev-parse --verify HEAD)"
git checkout -b $commit

# Create Laravel project
composer create-project --prefer-dist laravel/laravel test-app '7.*'
composer create-project --prefer-dist laravel/laravel test-app '8.*'
cd test-app

# Require Laravel auth preset and setup views
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/tests-with-email-verification
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ php artisan make:auth-tests
# Prepare for running tests
sed -i 's#<server name="SESSION_DRIVER" value="array"/>#<server name="SESSION_DRIVER" value="array"/><server name="DB_CONNECTION" value="sqlite"/><server name="DB_DATABASE" value=":memory:"/>#g' phpunit.xml
sed -i $'s#Auth::routes();#Auth::routes(\[\'verify\' => true\]);#g' ./routes/web.php
sed -i 's#extends Authenticatable#extends Authenticatable implements MustVerifyEmail#g' ./app/User.php
sed -i 's#extends Authenticatable#extends Authenticatable implements MustVerifyEmail#g' ./app/Models/User.php
8 changes: 4 additions & 4 deletions .github/workflows/run-tests-on-laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ on:

jobs:
test_without_email_verification:
name: (PHP ${{ matrix.php }}, Laravel 7) Tests without email verification
name: (PHP ${{ matrix.php }}, Laravel 8) Tests without email verification
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4']
php: ['7.3', '7.4']

steps:
- uses: actions/checkout@v2
Expand All @@ -37,11 +37,11 @@ jobs:
run: ( cd test-app && ./vendor/bin/phpunit )

test_with_email_verification:
name: (PHP ${{ matrix.php }}, Laravel 7) Tests with email verification
name: (PHP ${{ matrix.php }}, Laravel 8) Tests with email verification
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4']
php: ['7.3', '7.4']

steps:
- uses: actions/checkout@v2
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

![](https://i.imgur.com/1z5XkDc.png)

## ⚠️ Deprecation notice ⚠️
As of Laravel 8, the [laravel/ui](https://github.com/laravel/ui) package is discouraged to be used on new Laravel installations. **This package should be used only with already-existing, created with Laravel 7 or lower, applications that use laravel/ui auth controllers.**

All of the applications already using [laravel/ui](https://github.com/laravel/ui) will get updates of this package to new Laravel versions, although the support may be dropped in the future. This doesn't mean you won't be able to use the package or upgrade to new Laravel versions, but that the upgrades to the major versions may require manual changes from the consumers of this package.

The new way of installing Laravel 8's and above auth scaffolding is using the `--jet` option in the Laravel installer. Laravel [Jetstream](https://github.com/laravel/jetstream) hides all of its controllers inside the package, meaning it doesn't make sense to test those controllers, as they [are already tested inside the package](https://github.com/laravel/jetstream/tree/1.x/tests).

## Versioning
~The version of this package reflects current major version of the Laravel framework. For example:
If Laravel framework has version 5.6, version of this package compatible will be `5.6.*`.~
Expand Down Expand Up @@ -37,7 +44,7 @@ If you want to use the e-mail verification feature, you will have to make follow
- Auth::routes();
+ Auth::routes(['verify' => true]);
```
- update `app/User.php`:
- update `app/Models/User.php`:
```diff
- class User extends Authenticatable
+ class User extends Authenticatable implements MustVerifyEmail
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"laravel/framework": "^7.0"
"laravel/framework": "^8.0"
},
"extra": {
"laravel": {
Expand Down
2 changes: 1 addition & 1 deletion src/AuthTestsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace DCzajkowski\AuthTests;

use Illuminate\Support\ServiceProvider;
use DCzajkowski\AuthTests\Console\Commands\AuthTestsMakeCommand;
use Illuminate\Support\ServiceProvider;

class AuthTestsServiceProvider extends ServiceProvider
{
Expand Down
28 changes: 14 additions & 14 deletions src/Console/stubs/tests/Feature/Auth/EmailVerificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Tests\Feature\Auth;

use App\User;
use Tests\TestCase;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Notification;
use App\Models\User;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\URL;
use Tests\TestCase;

class EmailVerificationTest extends TestCase
{
Expand Down Expand Up @@ -60,7 +60,7 @@ public function testGuestCannotSeeTheVerificationNotice()

public function testUserSeesTheVerificationNoticeWhenNotVerified()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'email_verified_at' => null,
]);

Expand All @@ -72,7 +72,7 @@ public function testUserSeesTheVerificationNoticeWhenNotVerified()

public function testVerifiedUserIsRedirectedHomeWhenVisitingVerificationNoticeRoute()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'email_verified_at' => now(),
]);

Expand All @@ -83,7 +83,7 @@ public function testVerifiedUserIsRedirectedHomeWhenVisitingVerificationNoticeRo

public function testGuestCannotSeeTheVerificationVerifyRoute()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'id' => 1,
'email_verified_at' => null,
]);
Expand All @@ -95,12 +95,12 @@ public function testGuestCannotSeeTheVerificationVerifyRoute()

public function testUserCannotVerifyOthers()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'id' => 1,
'email_verified_at' => null,
]);

$user2 = factory(User::class)->create(['id' => 2, 'email_verified_at' => null]);
$user2 = User::factory()->create(['id' => 2, 'email_verified_at' => null]);

$response = $this->actingAs($user)->get($this->validVerificationVerifyRoute($user2));

Expand All @@ -110,7 +110,7 @@ public function testUserCannotVerifyOthers()

public function testUserIsRedirectedToCorrectRouteWhenAlreadyVerified()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'email_verified_at' => now(),
]);

Expand All @@ -121,7 +121,7 @@ public function testUserIsRedirectedToCorrectRouteWhenAlreadyVerified()

public function testForbiddenIsReturnedWhenSignatureIsInvalidInVerificationVerifyRoute()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'email_verified_at' => now(),
]);

Expand All @@ -132,7 +132,7 @@ public function testForbiddenIsReturnedWhenSignatureIsInvalidInVerificationVerif

public function testUserCanVerifyThemselves()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'email_verified_at' => null,
]);

Expand All @@ -151,7 +151,7 @@ public function testGuestCannotResendAVerificationEmail()

public function testUserIsRedirectedToCorrectRouteIfAlreadyVerified()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'email_verified_at' => now(),
]);

Expand All @@ -163,7 +163,7 @@ public function testUserIsRedirectedToCorrectRouteIfAlreadyVerified()
public function testUserCanResendAVerificationEmail()
{
Notification::fake();
$user = factory(User::class)->create([
$user = User::factory()->create([
'email_verified_at' => null,
]);

Expand Down
14 changes: 7 additions & 7 deletions src/Console/stubs/tests/Feature/Auth/ForgotPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Tests\Feature\Auth;

use App\User;
use Tests\TestCase;
use App\Models\User;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Notification;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class ForgotPasswordTest extends TestCase
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public function testUserCanViewAnEmailPasswordForm()

public function testUserCanViewAnEmailPasswordFormWhenAuthenticated()
{
$user = factory(User::class)->make();
$user = User::factory()->make();

$response = $this->actingAs($user)->get($this->passwordRequestRoute());

Expand All @@ -50,7 +50,7 @@ public function testUserCanViewAnEmailPasswordFormWhenAuthenticated()
public function testUserReceivesAnEmailWithAPasswordResetLink()
{
Notification::fake();
$user = factory(User::class)->create([
$user = User::factory()->create([
'email' => 'john@example.com',
]);

Expand All @@ -74,7 +74,7 @@ public function testUserDoesNotReceiveEmailWhenNotRegistered()

$response->assertRedirect($this->passwordEmailGetRoute());
$response->assertSessionHasErrors('email');
Notification::assertNotSentTo(factory(User::class)->make(['email' => 'nobody@example.com']), ResetPassword::class);
Notification::assertNotSentTo(User::factory()->make(['email' => 'nobody@example.com']), ResetPassword::class);
}

public function testEmailIsRequired()
Expand Down
20 changes: 10 additions & 10 deletions src/Console/stubs/tests/Feature/Auth/LoginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Tests\Feature\Auth;

use App\User;
use Tests\TestCase;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class LoginTest extends TestCase
{
Expand Down Expand Up @@ -57,7 +57,7 @@ public function testUserCanViewALoginForm()

public function testUserCannotViewALoginFormWhenAuthenticated()
{
$user = factory(User::class)->make();
$user = User::factory()->make();

$response = $this->actingAs($user)->get($this->loginGetRoute());

Expand All @@ -66,7 +66,7 @@ public function testUserCannotViewALoginFormWhenAuthenticated()

public function testUserCanLoginWithCorrectCredentials()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'password' => Hash::make($password = 'i-love-laravel'),
]);

Expand All @@ -81,7 +81,7 @@ public function testUserCanLoginWithCorrectCredentials()

public function testRememberMeFunctionality()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'id' => random_int(1, 100),
'password' => Hash::make($password = 'i-love-laravel'),
]);
Expand All @@ -105,7 +105,7 @@ public function testRememberMeFunctionality()

public function testUserCannotLoginWithIncorrectPassword()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'password' => Hash::make('i-love-laravel'),
]);

Expand Down Expand Up @@ -137,7 +137,7 @@ public function testUserCannotLoginWithEmailThatDoesNotExist()

public function testUserCanLogout()
{
$this->be(factory(User::class)->create());
$this->be(User::factory()->create());

$response = $this->post($this->logoutRoute());

Expand All @@ -155,7 +155,7 @@ public function testUserCannotLogoutWhenNotAuthenticated()

public function testUserCannotMakeMoreThanFiveAttemptsInOneMinute()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'password' => Hash::make($password = 'i-love-laravel'),
]);

Expand All @@ -168,7 +168,7 @@ public function testUserCannotMakeMoreThanFiveAttemptsInOneMinute()

$response->assertRedirect($this->loginGetRoute());
$response->assertSessionHasErrors('email');
$this->assertRegExp(
$this->assertMatchesRegularExpression(
$this->getTooManyLoginAttemptsMessage(),
collect(
$response
Expand Down
10 changes: 5 additions & 5 deletions src/Console/stubs/tests/Feature/Auth/RegisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Tests\Feature\Auth;

use App\User;
use Tests\TestCase;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Event;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Hash;
use Tests\TestCase;

class RegisterTest extends TestCase
{
Expand Down Expand Up @@ -43,7 +43,7 @@ public function testUserCanViewARegistrationForm()

public function testUserCannotViewARegistrationFormWhenAuthenticated()
{
$user = factory(User::class)->make();
$user = User::factory()->make();

$response = $this->actingAs($user)->get($this->registerGetRoute());

Expand Down
Loading