Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
anilkumarthakur60 committed Apr 8, 2024
1 parent fb1149a commit 4d17fbb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private function postRoutes(Router $router):void
->name('posts.changeStatusOtherColumn');
$router->put('posts/{id}/status-change', [PostController::class, 'changeStatus'])
->name('posts.changeStatus');
$router->put('posts/{id}/restore-trash', [PostController::class, 'restoreTrashed'])
$router->put('posts/{id}/restore-trashed', [PostController::class, 'restoreTrashed'])
->name('posts.restoreTrashed');
$router->delete('posts/{id}', [PostController::class, 'destroy'])
->name('posts.destroy');
Expand All @@ -169,7 +169,7 @@ private function tagRoutes(Router $router): void
->name('tags.changeStatusOtherColumn');
$router->put('tags/{id}/status-change', [TagController::class, 'changeStatus'])
->name('tags.changeStatus');
$router->put('tags/{id}/restore-trash', [TagController::class, 'restoreTrashed'])
$router->put('tags/{id}/restore-trashed', [TagController::class, 'restoreTrashed'])
->name('tags.restoreTrashed');
$router->delete('tags/{id}', [TagController::class, 'destroy'])
->name('tags.destroy');
Expand All @@ -195,7 +195,7 @@ private function userRoutes(Router $router):void
->name('users.changeStatusOtherColumn');
$router->put('users/{id}/status-change', [UserController::class, 'changeStatus'])
->name('users.changeStatus');
$router->put('users/{id}/restore-trash', [UserController::class, 'restoreTrashed'])
$router->put('users/{id}/restore-trashed', [UserController::class, 'restoreTrashed'])
->name('users.restoreTrashed');
$router->delete('users/{id}', [UserController::class, 'destroy'])
->name('users.destroy');
Expand Down
32 changes: 32 additions & 0 deletions tests/TestCases/TagModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,36 @@
$this->assertDatabaseMissing('tags', ['id' => 1]);
$this->assertSame(0, TagModel::query()->count());
});
it(description: 'can_restore_trashed_tag_in_api', closure: function () {
$tag = TagModel::factory()
->trashed()
->create();
$this->putJson(uri: "tags/{$tag->id}/restore-trashed")
->assertOk();
$this->assertDatabaseHas('tags', ['id' => $tag->id, 'deleted_at' => null]);
});
it(description: 'can_status_change_tag_in_api', closure: function () {
$tag = TagModel::factory()
->create([
'status'=>1
]);
$this->putJson(uri: "tags/{$tag->id}/status-change")
->assertOk();
$this->assertDatabaseHas('tags', ['id' => $tag->id, 'status' => 0]);
$this->putJson(uri: "tags/{$tag->id}/status-change")
->assertOk();
$this->assertDatabaseHas('tags', ['id' => $tag->id, 'status' => 1]);
});
it(description: 'can_status_change_other_column_tag_in_api', closure: function () {
$tag = TagModel::factory()
->create([
'active'=>1
]);
$this->putJson(uri: "tags/{$tag->id}/status-change/active")
->assertOk();
$this->assertDatabaseHas('tags', ['id' => $tag->id, 'active' => 0]);
$this->putJson(uri: "tags/{$tag->id}/status-change/active")
->assertOk();
$this->assertDatabaseHas('tags', ['id' => $tag->id, 'active' => 1]);
});
});

0 comments on commit 4d17fbb

Please sign in to comment.