Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Analyst task
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
suvorova-ma
Analyst task
Commits
3ceede6e
Commit
3ceede6e
authored
2 years ago
by
Shizuco
Browse files
Options
Downloads
Patches
Plain Diff
feat: category details tests
parent
39af96a7
No related branches found
Branches containing commit
No related tags found
1 merge request
!3
Dctn 494/fix
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/Feature/CategoryDetailsTest.php
+72
-0
72 additions, 0 deletions
tests/Feature/CategoryDetailsTest.php
with
72 additions
and
0 deletions
tests/Feature/CategoryDetailsTest.php
0 → 100644
+
72
−
0
View file @
3ceede6e
<?php
namespace
Tests\Feature
;
use
App\Models\Category
;
use
App\Models\User
;
use
Hash
;
use
Laravel\Sanctum\Sanctum
;
use
Tests\TestCase
;
class
CategoryDetailsTest
extends
TestCase
{
public
function
test_success_access_to_category_details_by_admin
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'admin'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$category
=
Category
::
factory
()
->
create
();
$response
=
$this
->
get
(
'/nova/resources/categories/'
.
$category
->
id
);
$user
->
delete
();
$category
->
delete
();
$response
->
assertStatus
(
200
);
}
public
function
test_success_access_to_category_details_by_analyst
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'analyst'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$category
=
Category
::
factory
()
->
create
();
$response
=
$this
->
get
(
'/nova/resources/categories/'
.
$category
->
id
);
$user
->
delete
();
$category
->
delete
();
$response
->
assertStatus
(
200
);
}
public
function
test_access_to_category_detail_by_common
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'common'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$category
=
Category
::
factory
()
->
create
();
$response
=
$this
->
get
(
'/nova/resources/categories/'
.
$category
->
id
);
$user
->
delete
();
$category
->
delete
();
$response
->
assertStatus
(
403
);
}
public
function
test_access_to_retailers_detail_by_unauthorized
()
{
$category
=
Category
::
factory
()
->
create
();
$response
=
$this
->
get
(
'/nova/resources/categories/'
.
$category
->
id
);
$category
->
delete
();
$response
->
assertStatus
(
302
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment