1
0
mirror of https://github.com/Kovah/LinkAce.git synced 2025-04-21 07:22:20 +02:00

Add test cases to LinkApiTest using incorrect Content-Type, asserting 415

This commit is contained in:
Matty Jorgensen 2025-01-31 11:34:41 -06:00
parent 6ebc750252
commit dc85a2d911
No known key found for this signature in database

View File

@ -152,6 +152,27 @@ class LinkApiTest extends ApiTestCase
]);
}
public function test_create_invalid_content_type_request(): void
{
$list = LinkList::factory()->create(['name' => 'Test List 1']);
$tag = Tag::factory()->create(['name' => 'a test 1']);
$tag2 = Tag::factory()->create(['name' => 'tag #2']);
$this->postJsonAuthorized('api/v2/links', [
'url' => 'https://example.com',
'title' => 'Search the Web',
'description' => 'There could be a description here',
'lists' => [$list->id],
'tags' => [$tag->id, $tag2->id],
'visibility' => 1,
'check_disabled' => false,
], ['Content-Type' => 'application/xml'])
->assertUnsupportedMediaType()
->assertJson([
'error' => "Invalid Content-Type"
]);
}
public function test_create_request_with_list(): void
{
$list = LinkList::factory()->create(['name' => 'Test List 1']);
@ -448,6 +469,25 @@ class LinkApiTest extends ApiTestCase
])->assertForbidden();
}
public function test_update_invalid_content_type_request(): void
{
$list = LinkList::factory()->create();
$this->createTestLinks();
$this->patchJsonAuthorized('api/v2/links/1', [
'url' => 'https://new-public-link.com',
'title' => 'Custom Title',
'description' => 'Custom Description',
'lists' => [$list->id],
'is_private' => false,
'check_disabled' => false,
], ['Content-Type' => 'application/xml'])
->assertUnsupportedMediaType()
->assertJson([
'error' => 'Invalid Content-Type'
]);
}
public function test_invalid_update_request(): void
{
Link::factory()->create();