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
9d0e3718
Commit
9d0e3718
authored
Dec 26, 2017
by
Viral Solani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add assertion function for login and logout
parent
8d3ce723
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
BrowserKitTestCase.php
tests/BrowserKitTestCase.php
+21
-0
LoginTest.php
tests/Feature/Auth/LoginTest.php
+5
-0
helpers.php
tests/Utilities/helpers.php
+2
-0
No files found.
tests/BrowserKitTestCase.php
View file @
9d0e3718
...
...
@@ -5,6 +5,7 @@ namespace Tests;
use
App\Models\Access\Role\Role
;
use
App\Models\Access\User\User
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Support\Facades\Artisan
;
use
Illuminate\Support\Facades\DB
;
use
Laravel\BrowserKitTesting\TestCase
as
BaseTestCase
;
...
...
@@ -78,4 +79,24 @@ abstract class BrowserKitTestCase extends BaseTestCase
parent
::
tearDown
();
}
/**
* Check if User is logged in or not.
*
* @return boolean true or false
*/
protected
function
assertLoggedIn
()
{
$this
->
assertTrue
(
Auth
::
check
());
}
/**
* Check if User is logged out or not
*
* @return boolean true or false
*/
protected
function
assertLoggedOut
()
{
$this
->
assertFalse
(
Auth
::
check
());
}
}
tests/Feature/Auth/LoginTest.php
View file @
9d0e3718
...
...
@@ -58,6 +58,7 @@ class LoginTest extends BrowserKitTestCase
public
function
unconfirmed_users_can_not_logIn
()
{
Auth
::
logout
();
config
([
'access.users.requires_approval'
=>
false
]);
// Create default user to test with
...
...
@@ -104,6 +105,8 @@ class LoginTest extends BrowserKitTestCase
->
see
(
$this
->
user
->
name
)
->
seePageIs
(
'/dashboard'
);
$this
->
assertLoggedIn
();
Auth
::
logout
();
//Admin Test
...
...
@@ -115,6 +118,8 @@ class LoginTest extends BrowserKitTestCase
->
see
(
$this
->
admin
->
first_name
)
->
see
(
'Access Management'
);
$this
->
assertLoggedIn
();
Event
::
assertDispatched
(
UserLoggedIn
::
class
);
}
}
tests/Utilities/helpers.php
View file @
9d0e3718
...
...
@@ -9,3 +9,5 @@ function make($class, $attributes = [], $times = null)
{
return
factory
(
$class
,
$times
)
->
make
(
$attributes
);
}
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