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
caef0b52
Commit
caef0b52
authored
2 years ago
by
Shizuco
Browse files
Options
Downloads
Patches
Plain Diff
feat: delete product test
parent
9169f2f4
No related branches found
Branches containing commit
No related tags found
1 merge request
!3
Dctn 494/fix
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/Feature/ProductDeleteTest.php
+69
-0
69 additions, 0 deletions
tests/Feature/ProductDeleteTest.php
tests/Feature/ProductUpdateTest.php
+22
-0
22 additions, 0 deletions
tests/Feature/ProductUpdateTest.php
with
91 additions
and
0 deletions
tests/Feature/ProductDeleteTest.php
0 → 100644
+
69
−
0
View file @
caef0b52
<?php
namespace
Tests\Feature
;
use
App\Models\Product
;
use
App\Models\User
;
use
Hash
;
use
Laravel\Sanctum\Sanctum
;
use
Tests\TestCase
;
class
ProductDeleteTest
extends
TestCase
{
public
function
test_success_delete_retailer_by_admin
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'admin'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
$product
=
Product
::
factory
()
->
create
();
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$response
=
$this
->
delete
(
'nova-api/products?filters=W10%3D&resources[]='
.
$product
->
id
);
$user
->
delete
();
$response
->
assertStatus
(
200
);
}
public
function
test_success_delete_retailer_by_analyst
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'analyst'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
$product
=
Product
::
factory
()
->
create
();
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$response
=
$this
->
delete
(
'nova-api/products?filters=W10%3D&resources[]='
.
$product
->
id
);
$user
->
delete
();
$response
->
assertStatus
(
200
);
}
public
function
test_delete_retailer_by_common
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'common'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$product
=
Product
::
factory
()
->
create
();
$response
=
$this
->
delete
(
'nova-api/products?filters=W10%3D&resources[]='
.
$product
->
id
);
$product
->
delete
();
$user
->
delete
();
$response
->
assertStatus
(
403
);
}
public
function
test_delete_retailer_by_unauthenticate_user
()
{
$product
=
Product
::
factory
()
->
create
();
$response
=
$this
->
delete
(
'nova-api/products?filters=W10%3D&resources[]='
.
$product
->
id
);
$product
->
delete
();
$response
->
assertStatus
(
401
);
}
}
This diff is collapsed.
Click to expand it.
tests/Feature/ProductUpdateTest.php
0 → 100644
+
22
−
0
View file @
caef0b52
<?php
namespace
Tests\Feature
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
use
Illuminate\Foundation\Testing\WithFaker
;
use
Tests\TestCase
;
class
ProductUpdateTest
extends
TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public
function
test_example
()
{
$response
=
$this
->
get
(
'/'
);
$response
->
assertStatus
(
200
);
}
}
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