Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Upgrade to Laravel v8 and Livewire v2 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pktharindu authored Sep 10, 2020
1 parent ec54f09 commit e24421b
Show file tree
Hide file tree
Showing 23 changed files with 124 additions and 70 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/phpunit.xml.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
</coverage>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
</php>
</phpunit>
9 changes: 7 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.2, 7.3, 7.4]
laravel: [^7.0]
php: [7.3, 7.4]
laravel: [^8.0]
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
steps:
- name: Checkout code
Expand Down Expand Up @@ -39,6 +39,11 @@ jobs:
run: |
cd ../app
php artisan ui ttall --auth --option=code-helpers
- name: Overwrite configuration
run: |
cd ../app
rm phpunit.xml
cp ../ttall/.github/workflows/phpunit.xml.stub ./phpunit.xml
- name: Execute tests
run: |
cd ../app
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

An opinionated Laravel front-end scaffolding preset for TTALL stack - Tailwindcss | Turbolinks | Alpine.js | Laravel | Livewire 🚀

It comes bundled with some helpful packages and their configurations (optional):

It uses concerns of [laravel/ui](https://github.com/laravel/ui) through Livewire actions. So, security features of laravel/ui (ex: login throttling) are built right in. It also comes bundled with some helpful packages and their configurations (optional):

- Laravel debugbar
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
],
"require": {
"php": "^7.2.5",
"laravel/framework": "^7.0",
"laravel/framework": "^8.0",
"laravel/ui": "^2.0",
"livewire/livewire": "^1.3"
"livewire/livewire": "^2.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.14",
Expand Down
2 changes: 1 addition & 1 deletion src/HandlesGeneralScaffolding.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected static function updateComposerPackageArray(array $composer, string $de
} else {
return array_merge([
'laravel/ui' => '^2.0',
'livewire/livewire' => '^1.0',
'livewire/livewire' => '^2.0',
], $composer);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/TtallPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TtallPreset extends Preset

const NPM_PACKAGES_TO_ADD = [
'@tailwindcss/ui' => '^0.4',
'alpinejs' => '^2.2',
'alpinejs' => '^2.6',
'laravel-mix' => '^5.0.1',
'laravel-mix-tailwind' => '^0.1.0',
'tailwindcss' => '^1.6',
Expand Down
2 changes: 1 addition & 1 deletion src/stubs/auth/app/Http/Livewire/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ protected function sendLoginResponse(Request $request)

public function render()
{
return view('livewire.auth.login');
return view('livewire.auth.login')->extends('layouts.auth');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public function confirm()

public function render()
{
return view('livewire.auth.passwords.confirm');
return view('livewire.auth.passwords.confirm')->extends('layouts.auth');
}
}
2 changes: 1 addition & 1 deletion src/stubs/auth/app/Http/Livewire/Auth/Passwords/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ protected function sendResetLinkResponse($response)

public function render()
{
return view('livewire.auth.passwords.email');
return view('livewire.auth.passwords.email')->extends('layouts.auth');
}
}
2 changes: 1 addition & 1 deletion src/stubs/auth/app/Http/Livewire/Auth/Passwords/Reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ protected function sendResetResponse($response)

public function render()
{
return view('livewire.auth.passwords.reset');
return view('livewire.auth.passwords.reset')->extends('layouts.auth');
}
}
4 changes: 2 additions & 2 deletions src/stubs/auth/app/Http/Livewire/Auth/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Livewire\Auth;

use App\Providers\RouteServiceProvider;
use App\User;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
Expand Down Expand Up @@ -50,6 +50,6 @@ protected function guard()

public function render()
{
return view('livewire.auth.register');
return view('livewire.auth.register')->extends('layouts.auth');
}
}
2 changes: 1 addition & 1 deletion src/stubs/auth/app/Http/Livewire/Auth/Verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ protected function redirectIfVerified()

public function render()
{
return view('livewire.auth.verify');
return view('livewire.auth.verify')->extends('layouts.auth');
}
}
12 changes: 8 additions & 4 deletions src/stubs/auth/resources/views/layouts/auth.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
@extends('layouts.base')

@section('body')
<div class="flex flex-col justify-center min-h-screen py-12 bg-gray-50 sm:px-6 lg:px-8">
@yield('content')
</div>
@endsection
<div class="flex flex-col justify-center min-h-screen py-12 bg-gray-50 sm:px-6 lg:px-8">
@yield('content')

@isset($slot)
{{ $slot }}
@endisset
</div>
@endsection
45 changes: 25 additions & 20 deletions src/stubs/auth/routes/web.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<?php

use App\Http\Livewire\Home;
use App\Http\Livewire\Auth\Login;
use App\Http\Livewire\Auth\Verify;
use App\Http\Livewire\Auth\Register;
use Illuminate\Support\Facades\Route;
use App\Http\Livewire\Auth\Passwords\Email;
use App\Http\Livewire\Auth\Passwords\Reset;
use App\Http\Livewire\Auth\Passwords\Confirm;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\VerificationController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
Expand All @@ -17,33 +24,31 @@

Route::view('/', 'welcome');

Route::layout('layouts.auth')->group(function () {
Route::middleware('guest')->group(function () {
Route::livewire('login', 'auth.login')
->name('login');
Route::middleware('guest')->group(function () {
Route::get('login', Login::class)
->name('login');

Route::livewire('register', 'auth.register')
->name('register');
});
Route::get('register', Register::class)
->name('register');
});

Route::livewire('password/reset', 'auth.passwords.email')
->name('password.request');
Route::get('password/reset', Email::class)
->name('password.request');

Route::livewire('password/reset/{token}', 'auth.passwords.reset')
->name('password.reset');
Route::get('password/reset/{token}', Reset::class)
->name('password.reset');

Route::middleware('auth')->group(function () {
Route::livewire('email/verify', 'auth.verify')
->middleware('throttle:6,1')
->name('verification.notice');
Route::middleware('auth')->group(function () {
Route::get('email/verify', Verify::class)
->middleware('throttle:6,1')
->name('verification.notice');

Route::livewire('password/confirm', 'auth.passwords.confirm')
->name('password.confirm');
});
Route::get('password/confirm', Confirm::class)
->name('password.confirm');
});

Route::middleware('auth')->group(function () {
Route::livewire('home', 'home')
Route::get('home', Home::class)
->name('home');

Route::get('email/verify/{id}/{hash}', [VerificationController::class, 'verify'])
Expand Down
14 changes: 7 additions & 7 deletions src/stubs/auth/tests/Feature/Auth/LoginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Tests\Feature\Auth;

use App\Providers\RouteServiceProvider;
use App\User;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
Expand All @@ -25,7 +25,7 @@ public function can_view_login_page()
/** @test */
public function is_redirected_if_already_logged_in()
{
$user = factory(User::class)->create();
$user = User::factory()->create();

$this->be($user);

Expand All @@ -36,7 +36,7 @@ public function is_redirected_if_already_logged_in()
/** @test */
public function a_user_can_login()
{
$user = factory(User::class)->create(['password' => Hash::make('password')]);
$user = User::factory()->create(['password' => Hash::make('password')]);

Livewire::test('auth.login')
->set('email', $user->email)
Expand All @@ -49,7 +49,7 @@ public function a_user_can_login()
/** @test */
public function is_redirected_to_the_home_page_after_login()
{
$user = factory(User::class)->create(['password' => Hash::make('password')]);
$user = User::factory()->create(['password' => Hash::make('password')]);

Livewire::test('auth.login')
->set('email', $user->email)
Expand All @@ -61,7 +61,7 @@ public function is_redirected_to_the_home_page_after_login()
/** @test */
public function email_is_required()
{
$user = factory(User::class)->create(['password' => Hash::make('password')]);
$user = User::factory()->create(['password' => Hash::make('password')]);

Livewire::test('auth.login')
->set('password', 'password')
Expand All @@ -72,7 +72,7 @@ public function email_is_required()
/** @test */
public function password_is_required()
{
$user = factory(User::class)->create(['password' => Hash::make('password')]);
$user = User::factory()->create(['password' => Hash::make('password')]);

Livewire::test('auth.login')
->set('email', $user->email)
Expand All @@ -83,7 +83,7 @@ public function password_is_required()
/** @test */
public function bad_login_attempt_shows_message()
{
$user = factory(User::class)->create();
$user = User::factory()->create();

Livewire::test('auth.login')
->set('email', $user->email)
Expand Down
4 changes: 2 additions & 2 deletions src/stubs/auth/tests/Feature/Auth/LogoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tests\Feature\Auth;

use App\User;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Auth;
use Tests\TestCase;
Expand All @@ -14,7 +14,7 @@ class LogoutTest extends TestCase
/** @test */
public function an_authenticated_user_can_log_out()
{
$user = factory(User::class)->create();
$user = User::factory()->create();
$this->be($user);

$this->post(route('logout'))
Expand Down
8 changes: 4 additions & 4 deletions src/stubs/auth/tests/Feature/Auth/Passwords/ConfirmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tests\Feature\Auth\Passwords;

use App\User;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Route;
Expand All @@ -25,7 +25,7 @@ protected function setUp(): void
/** @test */
public function a_user_must_confirm_their_password_before_visiting_a_protected_page()
{
$user = factory(User::class)->create();
$user = User::factory()->create();
$this->be($user);

$this->get('/must-be-confirmed')
Expand All @@ -47,7 +47,7 @@ public function a_user_must_enter_a_password_to_confirm_it()
/** @test */
public function a_user_must_enter_their_own_password_to_confirm_it()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'password' => Hash::make('password'),
]);

Expand All @@ -60,7 +60,7 @@ public function a_user_must_enter_their_own_password_to_confirm_it()
/** @test */
public function a_user_who_confirms_their_password_will_get_redirected()
{
$user = factory(User::class)->create([
$user = User::factory()->create([
'password' => Hash::make('password'),
]);

Expand Down
4 changes: 2 additions & 2 deletions src/stubs/auth/tests/Feature/Auth/Passwords/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tests\Feature\Auth\Passwords;

use App\User;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\TestCase;
Expand Down Expand Up @@ -39,7 +39,7 @@ public function a_user_must_enter_a_valid_email_address()
/** @test */
public function a_user_who_enters_a_valid_email_address_will_get_sent_an_email()
{
$user = factory(User::class)->create();
$user = User::factory()->create();

Livewire::test('auth.passwords.email')
->set('email', $user->email)
Expand Down
6 changes: 3 additions & 3 deletions src/stubs/auth/tests/Feature/Auth/Passwords/ResetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tests\Feature\Auth\Passwords;

use App\User;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
Expand All @@ -19,7 +19,7 @@ class ResetTest extends TestCase
/** @test */
public function can_view_password_reset_page()
{
$user = factory(User::class)->create();
$user = User::factory()->create();

$token = Str::random(16);

Expand All @@ -40,7 +40,7 @@ public function can_view_password_reset_page()
/** @test */
public function can_reset_password()
{
$user = factory(User::class)->create();
$user = User::factory()->create();

$token = Str::random(16);

Expand Down
Loading

0 comments on commit e24421b

Please sign in to comment.