-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Policies; | ||
|
||
use App\Models\Tag; | ||
use App\Models\User; | ||
use Illuminate\Auth\Access\Response; | ||
|
||
class TagPolicy | ||
{ | ||
|
||
/** | ||
* Determine if the user can delete the tag | ||
* | ||
* @param ?User $user | ||
* @param Tag $tag | ||
* @return bool|Response | ||
*/ | ||
public function delete(?User $user, Tag $tag) | ||
{ | ||
return Response::denyAsNotFound('not found message'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 Cloud Creativity Limited | ||
* | ||
* Use of this source code is governed by an MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Api\V1\Tags; | ||
|
||
use App\Models\Tag; | ||
use App\Models\User; | ||
use App\Tests\Api\V1\TestCase; | ||
|
||
class DeleteTest extends TestCase | ||
{ | ||
public function test(): void | ||
{ | ||
$tag = Tag::factory()->createOne(); | ||
|
||
$response = $this | ||
->actingAs(User::factory()->createOne()) | ||
->jsonApi('users') | ||
->delete(url('/api/v1/tags', $tag)); | ||
|
||
$response->assertNotFound()->assertErrorStatus([ | ||
'detail' => 'not found message', | ||
'status' => '404', | ||
'title' => 'Not Found', | ||
]); | ||
} | ||
|
||
public function testUnauthenticated(): void | ||
{ | ||
$tag = Tag::factory()->createOne(); | ||
|
||
$response = $this | ||
->jsonApi('users') | ||
->delete(url('/api/v1/tags', $tag)); | ||
|
||
$response->assertNotFound()->assertErrorStatus([ | ||
'detail' => 'not found message', | ||
'status' => '404', | ||
'title' => 'Not Found', | ||
]); | ||
} | ||
} |