Skip to content

Commit c8618fc

Browse files
authored
Laravel 8 update (#432)
* Update dependencies to laravel 8 * Update minim PHP version * Update factories to laravel 8 * Fix dusk tests * Remove auth routes comment * Style * Readme update * Readme update * Update factory on feature test * Add import * Update user import * Update seeders path * update variable name Co-authored-by: Manel Gavaldà <[email protected]>
1 parent ad8d2b9 commit c8618fc

10 files changed

+41
-25
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ Please be sure to check you environment.
7373
## Optional requirements
7474
* [Laravel menu](https://github.com/spatie/laravel-menu): only used with command adminlte:menu that replaces default adminlte menu with a menu with spatie/laravel-menu support.
7575

76-
## Laravel 6 and older
76+
## Laravel 7 and older
7777

78-
This package works smoothly with Laravel 6.x with 6.x version
78+
- This package works smoothly with Laravel 7.x with 7.x version
79+
- This package works smoothly with Laravel 6.x|5.x with 6.x version
7980

8081
## Laravel Routes
8182

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
}
1414
],
1515
"require": {
16-
"php": "^7.2.5",
16+
"php": "^7.3",
1717
"creativeorange/gravatar": "~1.0",
18-
"laravel/framework": "^7.0",
18+
"laravel/framework": "^8.0",
1919
"acacha/filesystem": "^0.1.2",
2020
"acacha/helpers": "^0.1.4",
2121
"league/flysystem": "^1.0",
22-
"laravel/ui": "^2.1"
22+
"laravel/ui": "^3.0"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^8.5",
25+
"phpunit/phpunit": "^9.0",
2626
"squizlabs/php_codesniffer": "^3.2.3",
2727
"laravel/dusk": "^6.0"
2828
},

src/Console/AdminLTEAdmin.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Acacha\AdminLTETemplateLaravel\Console;
44

55
use Illuminate\Console\Command;
6+
use App\Models\User;
67

78
/**
89
* Class AdminLTEAdmin.
@@ -41,7 +42,7 @@ public function handle()
4142
protected function createAdminUser()
4243
{
4344
try {
44-
factory(get_class(app('App\User')))->create([
45+
User::factory()->create([
4546
"name" => env('ADMIN_USER', $this->username()),
4647
"email" => env('ADMIN_EMAIL', $this->email()),
4748
"password" => bcrypt(env('ADMIN_PWD', '123456'))]);

src/Console/MakeAdminUserSeeder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function handle()
6464
{
6565
try {
6666
$this->filesystem->overwrite(
67-
$path = database_path('seeds/' . config('AdminUserSeeder', 'AdminUserSeeder.php')),
67+
$path = database_path('seeders/' . config('AdminUserSeeder', 'AdminUserSeeder.php')),
6868
$this->compiler->compile(
6969
$this->filesystem->get($this->getStubPath()),
7070
[

src/Console/stubs/AdminUserSeeder.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Illuminate\Database\Seeder;
4+
use App\Models\User;
45

56
/**
67
* Class AdminUserSeeder
@@ -15,7 +16,7 @@ class AdminUserSeeder extends Seeder
1516
public function run()
1617
{
1718
try {
18-
factory(App\User::class)->create([
19+
User::factory()->create([
1920
"name" => env('ADMIN_USER', "$USER_NAME$"),
2021
"email" => env('ADMIN_EMAIL', "$USER_EMAIL"),
2122
"password" => bcrypt(env('ADMIN_PWD', '123456'))]);

src/Http/routes.php

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@
66
* RouteServiceProvider
77
*/
88
Route::group(['middleware' => 'web'], function () {
9-
// Route::auth();
10-
119
Route::get('/home', 'HomeController@index');
1210
});

src/Providers/AdminLTETemplateServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class AdminLTETemplateServiceProvider extends ServiceProvider
1717
{
18-
18+
1919
/**
2020
* Register the application services.
2121
*/

src/stubs/RegisterController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace App\Http\Controllers\Auth;
44

5-
use App\User;
5+
use App\Models\User;
66
use Validator;
77
use App\Http\Controllers\Controller;
88
use Illuminate\Foundation\Auth\RegistersUsers;

tests/Browser/AcachaAdmintLTELaravelTest.php

+22-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\Auth;
88
use Illuminate\Support\Facades\Hash;
99
use Illuminate\Foundation\Testing\DatabaseMigrations;
10+
use App\Models\User;
1011

1112
/**
1213
* Class AcachaAdmintLTELaravelTest.
@@ -53,7 +54,8 @@ private function logout()
5354
public function testLandingPageWithUserLogged()
5455
{
5556
$this->browse(function (Browser $browser) {
56-
$user = factory(\App\User::class)->create();
57+
$user = User::factory()->create();
58+
5759
$browser->loginAs($user)
5860
->visit('/')
5961
->assertSee('Acacha')
@@ -87,7 +89,8 @@ public function testLoginPage()
8789
public function testLogin()
8890
{
8991
$this->browse(function (Browser $browser) {
90-
$user = factory(\App\User::class)->create(['password' => Hash::make('passw0RD')]);
92+
$user = User::factory()->create(['password' => Hash::make('passw0RD')]);
93+
9194
$browser->visit('/login')
9295
->type('email', $user->email)
9396
->type('password', 'passw0RD')
@@ -168,12 +171,13 @@ public function testLoginCredentialsNotMatchDissappearsOnKeyDown()
168171
{
169172
$this->browse(function (Browser $browser) {
170173
$browser->visit('/login')
174+
->waitFor("[name='email']")
171175
->type('email', '[email protected]')
172176
->type('password', '12345678')
173177
->press('Sign In')
174178
->pause(1000)
175179
->type('password', '1')
176-
->pause(1000)
180+
->pause(2000)
177181
->assertDontSee('These credentials do not match our records');
178182
});
179183
}
@@ -186,18 +190,21 @@ public function testLoginCredentialsNotMatchDissappearsOnKeyDown()
186190
public function testLoginWithRememberMe()
187191
{
188192
$this->browse(function (Browser $browser) {
189-
$user = factory(\App\User::class)->create(['password' => Hash::make('passw0RD')]);
193+
$user = User::factory()->create(['password' => Hash::make('passw0RD')]);
194+
190195
$browser->visit('/login')
191196
->type('email', $user->email)
192197
->type('password', 'passw0RD')
193198
->script("$('input[name=remember]').iCheck('check');");
199+
194200
$browser->press('Sign In')
195201
->waitFor('#result')
196202
->pause(5000)
197203
->assertPathIs('/home')
198204
->assertHasCookie(Auth::getRecallerName())
199205
->assertSee($user->name);
200206
});
207+
201208
$this->logout();
202209
}
203210

@@ -235,8 +242,10 @@ public function testPasswordResetPage()
235242
public function testHomePageForUnauthenticatedUsers()
236243
{
237244
$this->browse(function (Browser $browser) {
238-
$user = factory(\App\User::class)->create();
245+
$user = User::factory()->create();
246+
239247
view()->share('user', $user);
248+
240249
$browser->visit('/home')
241250
->pause(2000)
242251
->assertPathIs('/login');
@@ -251,8 +260,10 @@ public function testHomePageForUnauthenticatedUsers()
251260
public function testHomePageForAuthenticatedUsers()
252261
{
253262
$this->browse(function (Browser $browser) {
254-
$user = factory(\App\User::class)->create();
263+
$user = User::factory()->create();
264+
255265
view()->share('user', $user);
266+
256267
$browser->loginAs($user)
257268
->visit('/home')
258269
->assertSee($user->name);
@@ -269,8 +280,10 @@ public function testHomePageForAuthenticatedUsers()
269280
public function testLogout()
270281
{
271282
$this->browse(function (Browser $browser) {
272-
$user = factory(\App\User::class)->create();
283+
$user = User::factory()->create();
284+
273285
view()->share('user', $user);
286+
274287
$browser->loginAs($user)
275288
->visit('/home')
276289
->click('#user_menu')
@@ -376,7 +389,8 @@ public function testNewUserRegistrationRequiredFieldsDissappearsOnKeyDown()
376389
public function testSendPasswordReset()
377390
{
378391
$this->browse(function (Browser $browser) {
379-
$user = factory(\App\User::class)->create();
392+
$user = User::factory()->create();
393+
380394
$browser->visit('password/reset')
381395
->type('email', $user->email)
382396
->press('Send Password Reset Link')

tests/Feature/AcachaAdminLTELaravelTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\Hash;
88
use Tests\TestCase;
99
use Illuminate\Foundation\Testing\DatabaseMigrations;
10+
use App\Models\User;
1011

1112
/**
1213
* Class AcachaAdminLTELaravelTest.
@@ -206,7 +207,7 @@ public function testNewUserRegistrationRequiredFields()
206207
*/
207208
public function testLogin()
208209
{
209-
$user = factory(\App\User::class)->create(['password' => Hash::make('passw0RD')]);
210+
$user = User::factory()->create(['password' => Hash::make('passw0RD')]);
210211

211212
$response = $this->json('POST', '/login', [
212213
'email' => $user->email,
@@ -293,12 +294,12 @@ public function testMakeViewCommand()
293294
*/
294295
public function testAdminlteAdminCommand()
295296
{
296-
$seed = database_path('seeds/AdminUserSeeder.php');
297+
$seeder = database_path('seeders/AdminUserSeeder.php');
297298
try {
298-
unlink($seed);
299+
unlink($seeder);
299300
} catch (\Exception $e) {
300301
}
301302
Artisan::call('adminlte:admin');
302-
$this->assertFileExists($seed);
303+
$this->assertFileExists($seeder);
303304
}
304305
}

0 commit comments

Comments
 (0)