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
be50a012
Commit
be50a012
authored
Dec 24, 2017
by
Viral Solani
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test-cases' of
https://github.com/viralsolani/laravel-adminpanel
into develop
parents
546a8362
cf420162
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
17 deletions
+92
-17
ModelFactory.php
database/factories/ModelFactory.php
+3
-2
UserTableSeeder.php
database/seeds/Access/UserTableSeeder.php
+6
-6
AuthTest.php
tests/Feature/AuthTest.php
+32
-9
TestCase.php
tests/TestCase.php
+51
-0
No files found.
database/factories/ModelFactory.php
View file @
be50a012
...
...
@@ -19,11 +19,12 @@ $factory->define(User::class, function (Generator $faker) {
static
$password
;
return
[
'name'
=>
$faker
->
name
,
'first_name'
=>
$faker
->
name
,
'last_name'
=>
$faker
->
name
,
'email'
=>
$faker
->
safeEmail
,
'password'
=>
$password
?:
$password
=
bcrypt
(
'secret'
),
'remember_token'
=>
str_random
(
10
),
'confirmation_code'
=>
md5
(
uniqid
(
mt_rand
(),
true
)),
'remember_token'
=>
str_random
(
10
),
];
});
...
...
database/seeds/Access/UserTableSeeder.php
View file @
be50a012
...
...
@@ -26,8 +26,8 @@ class UserTableSeeder extends Seeder
//Add the master administrator, user id of 1
$users
=
[
[
'first_name'
=>
'
Admin Istrator
'
,
'last_name'
=>
'
Admin Istrator
'
,
'first_name'
=>
'
Viral
'
,
'last_name'
=>
'
Solani
'
,
'email'
=>
'admin@admin.com'
,
'password'
=>
bcrypt
(
'1234'
),
'confirmation_code'
=>
md5
(
uniqid
(
mt_rand
(),
true
)),
...
...
@@ -39,8 +39,8 @@ class UserTableSeeder extends Seeder
'deleted_at'
=>
null
,
],
[
'first_name'
=>
'
Backend User
'
,
'last_name'
=>
'
Admin Istrator
'
,
'first_name'
=>
'
Vipul
'
,
'last_name'
=>
'
Basapati
'
,
'email'
=>
'executive@executive.com'
,
'password'
=>
bcrypt
(
'1234'
),
'confirmation_code'
=>
md5
(
uniqid
(
mt_rand
(),
true
)),
...
...
@@ -52,8 +52,8 @@ class UserTableSeeder extends Seeder
'deleted_at'
=>
null
,
],
[
'first_name'
=>
'
Default User
'
,
'last_name'
=>
'
Admin Istrator
'
,
'first_name'
=>
'
John
'
,
'last_name'
=>
'
Doe
'
,
'email'
=>
'user@user.com'
,
'password'
=>
bcrypt
(
'1234'
),
'confirmation_code'
=>
md5
(
uniqid
(
mt_rand
(),
true
)),
...
...
tests/Feature/AuthTest.php
View file @
be50a012
...
...
@@ -2,7 +2,10 @@
namespace
Tests\Feature
;
use
Illuminate\Support\Facades\Auth
;
use
Tests\BrowserKitTestCase
;
use
Illuminate\Support\Facades\Event
;
use
App\Events\Frontend\Auth\UserLoggedIn
;
class
AuthTest
extends
BrowserKitTestCase
{
...
...
@@ -27,23 +30,43 @@ class AuthTest extends BrowserKitTestCase
}
/** @test */
public
function
test_login_failure_with_wrong_inputs
()
/*
public function test_login_failure_with_wrong_inputs()
{
$this
->
visit
(
'/login'
)
$this->visit(
"/login"
)
->type('wrongusername@wrongpassword.com', 'email')
->type('wrongpassword', 'password')
->press('Login')
->seePageIs('/login')
->see('These credentials do not match our records.');
}
}
*/
/** @test */
public
function
users_can_login
()
{
// Make sure our events are fired
Event
::
fake
();
Auth
::
logout
();
//User Test
$this
->
visit
(
'/login'
)
->
type
(
$this
->
user
->
email
,
'email'
)
->
type
(
'1234'
,
'password'
)
->
press
(
'Login'
)
->
see
(
$this
->
user
->
name
)
->
seePageIs
(
'/dashboard'
);
Auth
::
logout
();
//Admin Test
$this
->
visit
(
'/login'
)
->
type
(
'user@user.com'
,
'email'
)
->
type
(
$this
->
admin
->
email
,
'email'
)
->
type
(
'1234'
,
'password'
)
->
press
(
'Login'
)
->
seePageIs
(
route
(
'frontend.user.dashboard'
));
->
seePageIs
(
'/admin/dashboard'
)
->
see
(
$this
->
admin
->
first_name
)
->
see
(
'Access Management'
);
Event
::
assertDispatched
(
UserLoggedIn
::
class
);
}
}
\ No newline at end of file
tests/TestCase.php
View file @
be50a012
...
...
@@ -2,12 +2,45 @@
namespace
Tests
;
use
App\Models\Access\Role\Role
;
use
App\Models\Access\User\User
;
use
Illuminate\Foundation\Testing\TestCase
as
BaseTestCase
;
use
Illuminate\Support\Facades\Artisan
;
abstract
class
TestCase
extends
BaseTestCase
{
use
CreatesApplication
;
/**
* @var
*/
protected
$admin
;
/**
* @var
*/
protected
$executive
;
/**
* @var
*/
protected
$user
;
/**
* @var
*/
protected
$adminRole
;
/**
* @var
*/
protected
$executiveRole
;
/**
* @var
*/
protected
$userRole
;
public
function
signIn
(
$user
=
null
)
{
$user
=
$user
?:
create
(
'App\User'
);
...
...
@@ -17,10 +50,28 @@ abstract class TestCase extends BaseTestCase
return
$this
;
}
/**
* Set up tests.
*/
public
function
setUp
()
{
parent
::
setUp
();
$this
->
withoutExceptionHandling
();
// Set up the database
Artisan
::
call
(
'migrate:refresh'
);
Artisan
::
call
(
'db:seed'
);
/*
* Create class properties to be used in tests
*/
$this
->
admin
=
User
::
find
(
1
);
$this
->
executive
=
User
::
find
(
2
);
$this
->
user
=
User
::
find
(
3
);
$this
->
adminRole
=
Role
::
find
(
1
);
$this
->
executiveRole
=
Role
::
find
(
2
);
$this
->
userRole
=
Role
::
find
(
3
);
}
}
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