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
a6019896
Commit
a6019896
authored
Jan 07, 2018
by
Vipul Basapati
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://github.com/viralsolani/laravel-adminpanel
into develop
parents
e1511a0f
28f4d362
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
187 additions
and
2 deletions
+187
-2
PermissionFactory.php
database/factories/PermissionFactory.php
+12
-0
LoginTest.php
tests/Feature/Api/V1/LoginTest.php
+23
-0
ManagePermissionsTest.php
tests/Feature/Backend/ManagePermissionsTest.php
+124
-0
ManageRolesTest.php
tests/Feature/Backend/ManageRolesTest.php
+5
-1
ManageUsersTest.php
tests/Feature/Backend/ManageUsersTest.php
+5
-1
PermissionTest.php
tests/Unit/Models/PermissionTest.php
+18
-0
No files found.
database/factories/PermissionFactory.php
View file @
a6019896
...
@@ -16,3 +16,15 @@ $factory->define(Permission::class, function (Generator $faker) {
...
@@ -16,3 +16,15 @@ $factory->define(Permission::class, function (Generator $faker) {
'sort'
=>
$faker
->
numberBetween
(
1
,
100
),
'sort'
=>
$faker
->
numberBetween
(
1
,
100
),
];
];
});
});
$factory
->
state
(
Permission
::
class
,
'active'
,
function
()
{
return
[
'status'
=>
1
,
];
});
$factory
->
state
(
Permission
::
class
,
'inactive'
,
function
()
{
return
[
'status'
=>
0
,
];
});
tests/Feature/Api/V1/LoginTest.php
0 → 100644
View file @
a6019896
<?php
namespace
Tests\Feature\Api\V1
;
use
Illuminate\Support\Facades\Auth
;
use
Tests\TestCase
;
class
LoginTest
extends
TestCase
{
/** @test */
public
function
users_can_login_through_api
()
{
$res
=
$this
->
json
(
'POST'
,
'/api/v1/auth/login'
,
[
'email'
=>
$this
->
user
->
email
,
'password'
=>
'1234'
,
])
->
assertStatus
(
200
)
->
assertJsonStructure
([
'message'
,
'token'
,
]);
}
}
tests/Feature/Backend/ManagePermissionsTest.php
0 → 100644
View file @
a6019896
<?php
namespace
Tests\Feature\Backend
;
use
App\Events\Backend\Access\Permission\PermissionCreated
;
use
App\Events\Backend\Access\Permission\PermissionDeleted
;
use
App\Events\Backend\Access\Permission\PermissionUpdated
;
use
App\Models\Access\Permission\Permission
;
use
Illuminate\Support\Facades\Event
;
use
Tests\TestCase
;
class
ManagePermissionsTest
extends
TestCase
{
/** @test */
public
function
a_user_can_view_permissions
()
{
$this
->
actingAs
(
$this
->
admin
)
->
get
(
route
(
'admin.access.permission.index'
))
->
assertViewIs
(
'backend.access.permissions.index'
)
->
assertSee
(
trans
(
'labels.backend.access.permissions.management'
))
->
assertSee
(
'Export'
)
->
assertSee
(
'Action'
);
}
/** @test */
public
function
a_permission_requires_a_name
()
{
$permission
=
make
(
Permission
::
class
,
[
'name'
=>
null
])
->
toArray
();
return
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
post
(
route
(
'admin.access.permission.store'
),
$permission
)
->
assertSessionHasErrors
(
'name'
);
}
/** @test */
public
function
a_permission_requires_a_display_name
()
{
$permission
=
make
(
Permission
::
class
,
[
'display_name'
=>
null
])
->
toArray
();
return
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
post
(
route
(
'admin.access.permission.store'
),
$permission
)
->
assertSessionHasErrors
(
'display_name'
);
}
/** @test */
public
function
a_user_can_create_new_permission
()
{
// Make sure our events are fired
Event
::
fake
();
$permission
=
make
(
Permission
::
class
,
[
'name'
=>
'test permission'
])
->
toArray
();
$this
->
actingAs
(
$this
->
admin
)
->
post
(
route
(
'admin.access.permission.store'
),
$permission
)
->
assertRedirect
(
route
(
'admin.access.permission.index'
))
->
assertSessionHas
([
'flash_success'
=>
trans
(
'alerts.backend.permissions.created'
)]);
$this
->
assertDatabaseHas
(
config
(
'access.permissions_table'
),
[
'name'
=>
$permission
[
'name'
],
]);
Event
::
assertDispatched
(
PermissionCreated
::
class
);
}
/** @test */
public
function
it_fails_for_validation_on_update_permission
()
{
$permission
=
create
(
Permission
::
class
);
$data
=
$permission
->
toArray
();
$data
[
'name'
]
=
''
;
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
patch
(
route
(
'admin.access.permission.update'
,
$permission
),
$data
)
->
assertSessionHasErrors
([
'name'
]);
}
/** @test */
public
function
a_user_can_update_permission
()
{
Event
::
fake
();
$permission
=
create
(
Permission
::
class
);
$data
=
$permission
->
toArray
();
$data
[
'name'
]
=
'Updated Permission Name'
;
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
patch
(
route
(
'admin.access.permission.update'
,
$permission
),
$data
)
->
assertRedirect
(
route
(
'admin.access.permission.index'
))
->
assertSessionHas
([
'flash_success'
=>
trans
(
'alerts.backend.permissions.updated'
)]);
$this
->
assertDatabaseHas
(
config
(
'access.permissions_table'
),
[
'name'
=>
$data
[
'name'
],
]);
Event
::
assertDispatched
(
PermissionUpdated
::
class
);
}
/** @test */
public
function
a_user_can_delete_a_permission
()
{
Event
::
fake
();
$permission
=
create
(
Permission
::
class
);
$this
->
actingAs
(
$this
->
admin
)
->
delete
(
route
(
'admin.access.permission.destroy'
,
$permission
))
->
assertStatus
(
302
)
->
assertSessionHas
([
'flash_success'
=>
trans
(
'alerts.backend.permissions.deleted'
)]);
/*$this->assertDatabaseMissing('permissions', [
'name' => $permission->name, 'id' => $permission->id
]);*/
Event
::
assertDispatched
(
PermissionDeleted
::
class
);
}
}
tests/Feature/Backend/ManageRolesTest.php
View file @
a6019896
...
@@ -162,9 +162,13 @@ class ManageRolesTest extends TestCase
...
@@ -162,9 +162,13 @@ class ManageRolesTest extends TestCase
$this
->
actingAs
(
$this
->
admin
)
$this
->
actingAs
(
$this
->
admin
)
->
delete
(
route
(
'admin.access.role.destroy'
,
$role
))
->
delete
(
route
(
'admin.access.role.destroy'
,
$role
))
->
assertStatus
(
302
)
->
assertSessionHas
([
'flash_success'
=>
trans
(
'alerts.backend.roles.deleted'
)]);
->
assertSessionHas
([
'flash_success'
=>
trans
(
'alerts.backend.roles.deleted'
)]);
$this
->
assertDatabaseMissing
(
config
(
'access.roles_table'
),
[
'name'
=>
$role
->
first_name
,
'id'
=>
$role
->
id
]);
/*$this->assertDatabaseMissing(config('access.roles_table'), [
'name' => $role->name,
'id' => $role->id
]);*/
Event
::
assertDispatched
(
RoleDeleted
::
class
);
Event
::
assertDispatched
(
RoleDeleted
::
class
);
}
}
...
...
tests/Feature/Backend/ManageUsersTest.php
View file @
a6019896
...
@@ -285,9 +285,13 @@ class ManageUsersTest extends TestCase
...
@@ -285,9 +285,13 @@ class ManageUsersTest extends TestCase
$this
->
actingAs
(
$this
->
admin
)
$this
->
actingAs
(
$this
->
admin
)
->
delete
(
route
(
'admin.access.user.destroy'
,
$user
))
->
delete
(
route
(
'admin.access.user.destroy'
,
$user
))
->
assertStatus
(
302
)
->
assertSessionHas
([
'flash_success'
=>
trans
(
'alerts.backend.users.deleted'
)]);
->
assertSessionHas
([
'flash_success'
=>
trans
(
'alerts.backend.users.deleted'
)]);
$this
->
assertDatabaseMissing
(
config
(
'access.users_table'
),
[
'name'
=>
$user
->
first_name
,
'id'
=>
$user
->
id
]);
$this
->
assertDatabaseMissing
(
config
(
'access.users_table'
),
[
'name'
=>
$user
->
first_name
,
'id'
=>
$user
->
id
,
]);
Event
::
assertDispatched
(
UserDeleted
::
class
);
Event
::
assertDispatched
(
UserDeleted
::
class
);
}
}
...
...
tests/Unit/Models/PermissionTest.php
0 → 100644
View file @
a6019896
<?php
namespace
Tests\Unit\Models
;
use
App\Models\Access\Permission\Permission
;
use
Tests\TestCase
;
class
PermissionTest
extends
TestCase
{
/** @test */
public
function
a_permission_has_roles
()
{
$permission
=
Permission
::
find
(
1
);
$this
->
assertInstanceOf
(
'Illuminate\Database\Eloquent\Collection'
,
$permission
->
roles
);
}
}
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