Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
470cde32
Commit
470cde32
authored
Jan 02, 2018
by
Viral Solani
Committed by
StyleCI Bot
Jan 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply fixes from StyleCI
parent
eed3f488
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
29 deletions
+27
-29
UserRepository.php
app/Repositories/Backend/Access/User/UserRepository.php
+2
-2
ChangePasswordTest.php
tests/Feature/Backend/ChangePasswordTest.php
+12
-14
ManageUsersTest.php
tests/Feature/Backend/ManageUsersTest.php
+13
-13
No files found.
app/Repositories/Backend/Access/User/UserRepository.php
View file @
470cde32
...
@@ -160,7 +160,7 @@ class UserRepository extends BaseRepository
...
@@ -160,7 +160,7 @@ class UserRepository extends BaseRepository
}
}
/**
/**
* Change Password
* Change Password
.
*
*
* @param $user
* @param $user
* @param $input
* @param $input
...
@@ -174,11 +174,11 @@ class UserRepository extends BaseRepository
...
@@ -174,11 +174,11 @@ class UserRepository extends BaseRepository
$user
=
$this
->
find
(
access
()
->
id
());
$user
=
$this
->
find
(
access
()
->
id
());
if
(
Hash
::
check
(
$input
[
'old_password'
],
$user
->
password
))
{
if
(
Hash
::
check
(
$input
[
'old_password'
],
$user
->
password
))
{
$user
->
password
=
bcrypt
(
$input
[
'password'
]);
$user
->
password
=
bcrypt
(
$input
[
'password'
]);
if
(
$user
->
save
())
{
if
(
$user
->
save
())
{
event
(
new
UserPasswordChanged
(
$user
));
event
(
new
UserPasswordChanged
(
$user
));
return
true
;
return
true
;
}
}
...
...
tests/Feature/Backend/ChangePasswordTest.php
View file @
470cde32
...
@@ -2,21 +2,19 @@
...
@@ -2,21 +2,19 @@
namespace
Tests\Feature\Backend
;
namespace
Tests\Feature\Backend
;
use
Tests\TestCase
;
use
Illuminate\Support\Facades\Event
;
use
App\Events\Backend\Access\User\UserPasswordChanged
;
use
App\Events\Backend\Access\User\UserPasswordChanged
;
use
Illuminate\Support\Facades\Event
;
use
Tests\TestCase
;
class
ChangePasswordTest
extends
TestCase
class
ChangePasswordTest
extends
TestCase
{
{
/** @test */
/** @test */
public
function
a_user_require_old_password_to_change_password
()
public
function
a_user_require_old_password_to_change_password
()
{
{
$data
=
[];
$data
=
[];
$data
[
'old_password'
]
=
'12345'
;
$data
[
'old_password'
]
=
'12345'
;
$data
[
'password'
]
=
'Viral@1234'
;
$data
[
'password'
]
=
'Viral@1234'
;
$data
[
'password_confirmation'
]
=
'Viral@1234'
;
$data
[
'password_confirmation'
]
=
'Viral@1234'
;
$this
->
withExceptionHandling
()
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
actingAs
(
$this
->
admin
)
...
@@ -28,9 +26,9 @@ class ChangePasswordTest extends TestCase
...
@@ -28,9 +26,9 @@ class ChangePasswordTest extends TestCase
public
function
a_user_require_strong_password_to_change_password
()
public
function
a_user_require_strong_password_to_change_password
()
{
{
$data
=
[];
$data
=
[];
$data
[
'old_password'
]
=
'1234'
;
$data
[
'old_password'
]
=
'1234'
;
$data
[
'password'
]
=
'12345678'
;
$data
[
'password'
]
=
'12345678'
;
$data
[
'password_confirmation'
]
=
'12345678'
;
$data
[
'password_confirmation'
]
=
'12345678'
;
$this
->
withExceptionHandling
()
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
actingAs
(
$this
->
admin
)
...
@@ -38,15 +36,15 @@ class ChangePasswordTest extends TestCase
...
@@ -38,15 +36,15 @@ class ChangePasswordTest extends TestCase
->
assertSessionHas
(
'The given data was invalid.'
);
->
assertSessionHas
(
'The given data was invalid.'
);
}
}
/** @test */
/** @test */
public
function
a_user_can_change_password
()
public
function
a_user_can_change_password
()
{
{
Event
::
fake
();
Event
::
fake
();
$data
=
[];
$data
=
[];
$data
[
'old_password'
]
=
'1234'
;
$data
[
'old_password'
]
=
'1234'
;
$data
[
'password'
]
=
'Viral@1234'
;
$data
[
'password'
]
=
'Viral@1234'
;
$data
[
'password_confirmation'
]
=
'Viral@1234'
;
$data
[
'password_confirmation'
]
=
'Viral@1234'
;
$this
->
actingAs
(
$this
->
admin
)
$this
->
actingAs
(
$this
->
admin
)
->
patch
(
route
(
'admin.access.user.change-password'
,
$this
->
admin
),
$data
)
->
patch
(
route
(
'admin.access.user.change-password'
,
$this
->
admin
),
$data
)
...
...
tests/Feature/Backend/ManageUsersTest.php
View file @
470cde32
...
@@ -2,16 +2,16 @@
...
@@ -2,16 +2,16 @@
namespace
Tests\Feature\Backend
;
namespace
Tests\Feature\Backend
;
use
Tests\TestCase
;
use
App\Models\Access\Role\Role
;
use
App\Models\Access\User\User
;
use
Illuminate\Support\Facades\Event
;
use
App\Models\Access\Permission\Permission
;
use
Illuminate\Support\Facades\Notification
;
use
App\Events\Backend\Access\User\UserCreated
;
use
App\Events\Backend\Access\User\UserCreated
;
use
App\Events\Backend\Access\User\UserDeleted
;
use
App\Events\Backend\Access\User\UserDeleted
;
use
App\Events\Backend\Access\User\UserUpdated
;
use
App\Events\Backend\Access\User\UserUpdated
;
use
App\Models\Access\Permission\Permission
;
use
App\Models\Access\Role\Role
;
use
App\Models\Access\User\User
;
use
App\Notifications\Frontend\Auth\UserNeedsConfirmation
;
use
App\Notifications\Frontend\Auth\UserNeedsConfirmation
;
use
Illuminate\Support\Facades\Event
;
use
Illuminate\Support\Facades\Notification
;
use
Tests\TestCase
;
class
ManageUsersTest
extends
TestCase
class
ManageUsersTest
extends
TestCase
{
{
...
@@ -222,7 +222,7 @@ class ManageUsersTest extends TestCase
...
@@ -222,7 +222,7 @@ class ManageUsersTest extends TestCase
Event
::
assertDispatched
(
UserCreated
::
class
);
Event
::
assertDispatched
(
UserCreated
::
class
);
}
}
/** @test */
/** @test */
public
function
it_fails_for_validation_on_update_user
()
public
function
it_fails_for_validation_on_update_user
()
{
{
$user
=
create
(
User
::
class
);
$user
=
create
(
User
::
class
);
...
@@ -262,17 +262,16 @@ class ManageUsersTest extends TestCase
...
@@ -262,17 +262,16 @@ class ManageUsersTest extends TestCase
->
assertRedirect
(
route
(
'admin.access.user.index'
))
->
assertRedirect
(
route
(
'admin.access.user.index'
))
->
assertSessionHas
([
'flash_success'
=>
trans
(
'alerts.backend.users.updated'
)]);
->
assertSessionHas
([
'flash_success'
=>
trans
(
'alerts.backend.users.updated'
)]);
$this
->
assertDatabaseHas
(
config
(
'access.users_table'
),[
$this
->
assertDatabaseHas
(
config
(
'access.users_table'
),
[
'id'
=>
$user
->
id
,
'id'
=>
$user
->
id
,
'first_name'
=>
$data
[
'first_name'
],
'first_name'
=>
$data
[
'first_name'
],
'last_name'
=>
$data
[
'last_name'
],
'last_name'
=>
$data
[
'last_name'
],
]);
]);
Event
::
assertDispatched
(
UserUpdated
::
class
);
Event
::
assertDispatched
(
UserUpdated
::
class
);
}
}
/** @test */
/** @test */
public
function
a_user_can_delete_a_user
()
public
function
a_user_can_delete_a_user
()
{
{
Event
::
fake
();
Event
::
fake
();
...
@@ -288,7 +287,7 @@ class ManageUsersTest extends TestCase
...
@@ -288,7 +287,7 @@ class ManageUsersTest extends TestCase
Event
::
assertDispatched
(
UserDeleted
::
class
);
Event
::
assertDispatched
(
UserDeleted
::
class
);
}
}
/** @test */
/** @test */
public
function
a_user_can_not_delete_himself
()
public
function
a_user_can_not_delete_himself
()
{
{
$this
->
withExceptionHandling
()
$this
->
withExceptionHandling
()
...
@@ -298,6 +297,7 @@ class ManageUsersTest extends TestCase
...
@@ -298,6 +297,7 @@ class ManageUsersTest extends TestCase
$this
->
assertDatabaseHas
(
config
(
'access.users_table'
),
[
'id'
=>
$this
->
admin
->
id
,
'deleted_at'
=>
null
]);
$this
->
assertDatabaseHas
(
config
(
'access.users_table'
),
[
'id'
=>
$this
->
admin
->
id
,
'deleted_at'
=>
null
]);
}
}
// change password
// change password
// export / import feature
// export / import feature
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment