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
21308c9c
Commit
21308c9c
authored
2 years ago
by
Shizuco
Browse files
Options
Downloads
Patches
Plain Diff
feat: category delete tests
parent
1b450bcf
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/CategoryDeleteTest.php
+70
-0
70 additions, 0 deletions
tests/Feature/CategoryDeleteTest.php
tests/Feature/UserLogOutTest.php
+29
-0
29 additions, 0 deletions
tests/Feature/UserLogOutTest.php
with
99 additions
and
0 deletions
tests/Feature/CategoryDeleteTest.php
0 → 100644
+
70
−
0
View file @
21308c9c
<?php
namespace
Tests\Feature
;
use
Illuminate\Support\Str
;
use
Laravel\Sanctum\Sanctum
;
use
Tests\TestCase
;
use
App\Models\User
;
use
App\Models\Category
;
use
Hash
;
class
CategoryDeleteTest
extends
TestCase
{
public
function
test_success_delete_category_by_admin
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'admin'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
$category
=
Category
::
factory
()
->
create
();
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$response
=
$this
->
delete
(
'nova-api/categories?filters=W10%3D&resources[]='
.
$category
->
id
);
$user
->
delete
();
$response
->
assertStatus
(
200
);
}
public
function
test_success_delete_category_by_analyst
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'analyst'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
$category
=
Category
::
factory
()
->
create
();
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$response
=
$this
->
delete
(
'nova-api/categories?filters=W10%3D&resources[]='
.
$category
->
id
);
$user
->
delete
();
$response
->
assertStatus
(
200
);
}
public
function
test_delete_category_by_common
()
{
$user
=
User
::
factory
()
->
create
([
'role'
=>
'common'
,
'password'
=>
Hash
::
make
(
'123123123'
),
]);
Sanctum
::
actingAs
(
$user
,
[
'*'
]
);
$category
=
Category
::
factory
()
->
create
();
$response
=
$this
->
delete
(
'nova-api/categories?filters=W10%3D&resources[]='
.
$category
->
id
);
$category
->
delete
();
$user
->
delete
();
$response
->
assertStatus
(
403
);
}
public
function
test_update_category_by_unauthenticate_user
()
{
$category
=
Category
::
factory
()
->
create
();
$response
=
$this
->
delete
(
'nova-api/categories?filters=W10%3D&resources[]='
.
$category
->
id
);
$category
->
delete
();
$response
->
assertStatus
(
401
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/Feature/UserLogOutTest.php
0 → 100644
+
29
−
0
View file @
21308c9c
<?php
namespace
Tests\Feature
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
use
Illuminate\Foundation\Testing\WithFaker
;
use
App\Models\User
;
use
Tests\TestCase
;
use
Laravel\Sanctum\Sanctum
;
use
Hash
,
Auth
;
class
UserLogOutTest
extends
TestCase
{
/*public function test_success_log_out_by_admin()
{
$user = User::factory()->create([
'role' => 'admin'
]);
Sanctum::actingAs(
$user,
['*']
);
$response = $this->post('/nova/logout', [
]);
$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