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
39af96a7
Commit
39af96a7
authored
2 years ago
by
Shizuco
Browse files
Options
Downloads
Patches
Plain Diff
feat: category details tests
parent
ab0e2f94
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/RetailerDetailsTest.php
+58
-9
58 additions, 9 deletions
tests/Feature/RetailerDetailsTest.php
with
58 additions
and
9 deletions
tests/Feature/RetailerDetailsTest.php
+
58
−
9
View file @
39af96a7
...
...
@@ -2,21 +2,70 @@
namespace
Tests\Feature
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
use
Illuminate\Foundation\Testing\WithFaker
;
use
App\Models\Retailer
;
use
App\Models\User
;
use
Hash
;
use
Laravel\Sanctum\Sanctum
;
use
Tests\TestCase
;
class
RetailerDetailsTest
extends
TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public
function
test_example
()
public
function
test_success_access_to_retailer_details_by_admin
()
{
$response
=
$this
->
get
(
'/'
);
$user
=
User
::
factory
()
->
create
([
'role'
=>
'admin'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$retailer
=
Retailer
::
factory
()
->
create
();
$response
=
$this
->
get
(
'/nova/resources/retailers/'
.
$retailer
->
id
);
$user
->
delete
();
$retailer
->
delete
();
$response
->
assertStatus
(
200
);
}
public
function
test_success_access_to_retailer_details_by_analyst
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'analyst'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$retailer
=
Retailer
::
factory
()
->
create
();
$response
=
$this
->
get
(
'/nova/resources/retailers/'
.
$retailer
->
id
);
$user
->
delete
();
$retailer
->
delete
();
$response
->
assertStatus
(
200
);
}
public
function
test_access_to_retailers_detail_by_common
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'common'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$retailer
=
Retailer
::
factory
()
->
create
();
$response
=
$this
->
get
(
'/nova/resources/retailers/'
.
$retailer
->
id
);
$user
->
delete
();
$retailer
->
delete
();
$response
->
assertStatus
(
403
);
}
public
function
test_access_to_retailers_detail_by_unauthorized
()
{
$retailer
=
Retailer
::
factory
()
->
create
();
$response
=
$this
->
get
(
'/nova/resources/retailers/'
.
$retailer
->
id
);
$retailer
->
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