Skip to content

Commit

Permalink
Laravel 8 update (#432)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
manelgavalda and manelgavalda authored Sep 19, 2020
1 parent ad8d2b9 commit c8618fc
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 25 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ Please be sure to check you environment.
## Optional requirements
* [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.

## Laravel 6 and older
## Laravel 7 and older

This package works smoothly with Laravel 6.x with 6.x version
- This package works smoothly with Laravel 7.x with 7.x version
- This package works smoothly with Laravel 6.x|5.x with 6.x version

## Laravel Routes

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
}
],
"require": {
"php": "^7.2.5",
"php": "^7.3",
"creativeorange/gravatar": "~1.0",
"laravel/framework": "^7.0",
"laravel/framework": "^8.0",
"acacha/filesystem": "^0.1.2",
"acacha/helpers": "^0.1.4",
"league/flysystem": "^1.0",
"laravel/ui": "^2.1"
"laravel/ui": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.2.3",
"laravel/dusk": "^6.0"
},
Expand Down
3 changes: 2 additions & 1 deletion src/Console/AdminLTEAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Acacha\AdminLTETemplateLaravel\Console;

use Illuminate\Console\Command;
use App\Models\User;

/**
* Class AdminLTEAdmin.
Expand Down Expand Up @@ -41,7 +42,7 @@ public function handle()
protected function createAdminUser()
{
try {
factory(get_class(app('App\User')))->create([
User::factory()->create([
"name" => env('ADMIN_USER', $this->username()),
"email" => env('ADMIN_EMAIL', $this->email()),
"password" => bcrypt(env('ADMIN_PWD', '123456'))]);
Expand Down
2 changes: 1 addition & 1 deletion src/Console/MakeAdminUserSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function handle()
{
try {
$this->filesystem->overwrite(
$path = database_path('seeds/' . config('AdminUserSeeder', 'AdminUserSeeder.php')),
$path = database_path('seeders/' . config('AdminUserSeeder', 'AdminUserSeeder.php')),
$this->compiler->compile(
$this->filesystem->get($this->getStubPath()),
[
Expand Down
3 changes: 2 additions & 1 deletion src/Console/stubs/AdminUserSeeder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Illuminate\Database\Seeder;
use App\Models\User;

/**
* Class AdminUserSeeder
Expand All @@ -15,7 +16,7 @@ class AdminUserSeeder extends Seeder
public function run()
{
try {
factory(App\User::class)->create([
User::factory()->create([
"name" => env('ADMIN_USER', "$USER_NAME$"),
"email" => env('ADMIN_EMAIL', "$USER_EMAIL"),
"password" => bcrypt(env('ADMIN_PWD', '123456'))]);
Expand Down
2 changes: 0 additions & 2 deletions src/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
* RouteServiceProvider
*/
Route::group(['middleware' => 'web'], function () {
// Route::auth();

Route::get('/home', 'HomeController@index');
});
2 changes: 1 addition & 1 deletion src/Providers/AdminLTETemplateServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class AdminLTETemplateServiceProvider extends ServiceProvider
{

/**
* Register the application services.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/stubs/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers\Auth;

use App\User;
use App\Models\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RegistersUsers;
Expand Down
30 changes: 22 additions & 8 deletions tests/Browser/AcachaAdmintLTELaravelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use App\Models\User;

/**
* Class AcachaAdmintLTELaravelTest.
Expand Down Expand Up @@ -53,7 +54,8 @@ private function logout()
public function testLandingPageWithUserLogged()
{
$this->browse(function (Browser $browser) {
$user = factory(\App\User::class)->create();
$user = User::factory()->create();

$browser->loginAs($user)
->visit('/')
->assertSee('Acacha')
Expand Down Expand Up @@ -87,7 +89,8 @@ public function testLoginPage()
public function testLogin()
{
$this->browse(function (Browser $browser) {
$user = factory(\App\User::class)->create(['password' => Hash::make('passw0RD')]);
$user = User::factory()->create(['password' => Hash::make('passw0RD')]);

$browser->visit('/login')
->type('email', $user->email)
->type('password', 'passw0RD')
Expand Down Expand Up @@ -168,12 +171,13 @@ public function testLoginCredentialsNotMatchDissappearsOnKeyDown()
{
$this->browse(function (Browser $browser) {
$browser->visit('/login')
->waitFor("[name='email']")
->type('email', '[email protected]')
->type('password', '12345678')
->press('Sign In')
->pause(1000)
->type('password', '1')
->pause(1000)
->pause(2000)
->assertDontSee('These credentials do not match our records');
});
}
Expand All @@ -186,18 +190,21 @@ public function testLoginCredentialsNotMatchDissappearsOnKeyDown()
public function testLoginWithRememberMe()
{
$this->browse(function (Browser $browser) {
$user = factory(\App\User::class)->create(['password' => Hash::make('passw0RD')]);
$user = User::factory()->create(['password' => Hash::make('passw0RD')]);

$browser->visit('/login')
->type('email', $user->email)
->type('password', 'passw0RD')
->script("$('input[name=remember]').iCheck('check');");

$browser->press('Sign In')
->waitFor('#result')
->pause(5000)
->assertPathIs('/home')
->assertHasCookie(Auth::getRecallerName())
->assertSee($user->name);
});

$this->logout();
}

Expand Down Expand Up @@ -235,8 +242,10 @@ public function testPasswordResetPage()
public function testHomePageForUnauthenticatedUsers()
{
$this->browse(function (Browser $browser) {
$user = factory(\App\User::class)->create();
$user = User::factory()->create();

view()->share('user', $user);

$browser->visit('/home')
->pause(2000)
->assertPathIs('/login');
Expand All @@ -251,8 +260,10 @@ public function testHomePageForUnauthenticatedUsers()
public function testHomePageForAuthenticatedUsers()
{
$this->browse(function (Browser $browser) {
$user = factory(\App\User::class)->create();
$user = User::factory()->create();

view()->share('user', $user);

$browser->loginAs($user)
->visit('/home')
->assertSee($user->name);
Expand All @@ -269,8 +280,10 @@ public function testHomePageForAuthenticatedUsers()
public function testLogout()
{
$this->browse(function (Browser $browser) {
$user = factory(\App\User::class)->create();
$user = User::factory()->create();

view()->share('user', $user);

$browser->loginAs($user)
->visit('/home')
->click('#user_menu')
Expand Down Expand Up @@ -376,7 +389,8 @@ public function testNewUserRegistrationRequiredFieldsDissappearsOnKeyDown()
public function testSendPasswordReset()
{
$this->browse(function (Browser $browser) {
$user = factory(\App\User::class)->create();
$user = User::factory()->create();

$browser->visit('password/reset')
->type('email', $user->email)
->press('Send Password Reset Link')
Expand Down
9 changes: 5 additions & 4 deletions tests/Feature/AcachaAdminLTELaravelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Hash;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use App\Models\User;

/**
* Class AcachaAdminLTELaravelTest.
Expand Down Expand Up @@ -206,7 +207,7 @@ public function testNewUserRegistrationRequiredFields()
*/
public function testLogin()
{
$user = factory(\App\User::class)->create(['password' => Hash::make('passw0RD')]);
$user = User::factory()->create(['password' => Hash::make('passw0RD')]);

$response = $this->json('POST', '/login', [
'email' => $user->email,
Expand Down Expand Up @@ -293,12 +294,12 @@ public function testMakeViewCommand()
*/
public function testAdminlteAdminCommand()
{
$seed = database_path('seeds/AdminUserSeeder.php');
$seeder = database_path('seeders/AdminUserSeeder.php');
try {
unlink($seed);
unlink($seeder);
} catch (\Exception $e) {
}
Artisan::call('adminlte:admin');
$this->assertFileExists($seed);
$this->assertFileExists($seeder);
}
}

0 comments on commit c8618fc

Please sign in to comment.