NOW MANAGED ON CODEBERG
Added missing validation.file message
Dan Brown1df7497c094e
diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.phpindex 1963b0df2..2a676c7c4 100644--- a/resources/lang/en/validation.php+++ b/resources/lang/en/validation.php@@ -32,6 +32,7 @@ return ['digits_between' => 'The :attribute must be between :min and :max digits.','email' => 'The :attribute must be a valid email address.','ends_with' => 'The :attribute must end with one of the following: :values',+ 'file' => 'The :attribute must be provided as a valid file.','filled' => 'The :attribute field is required.','gt' => ['numeric' => 'The :attribute must be greater than :value.',diff --git a/tests/Api/AttachmentsApiTest.php b/tests/Api/AttachmentsApiTest.phpindex 79b4ae98c..d7625c938 100644--- a/tests/Api/AttachmentsApiTest.php+++ b/tests/Api/AttachmentsApiTest.php@@ -122,7 +122,7 @@ class AttachmentsApiTest extends TestCase$resp = $this->call('POST', $this->baseEndpoint, $details, [], ['file' => $file]);$resp->assertStatus(422);$resp->assertJson($this->validationResponse([- "file" => ["The file may not be greater than 1000 kilobytes."]+ 'file' => ['The file may not be greater than 1000 kilobytes.'],]));}@@ -139,15 +139,7 @@ class AttachmentsApiTest extends TestCase$resp = $this->postJson($this->baseEndpoint, $details);$resp->assertStatus(422);- $resp->assertJson([- 'error' => [- 'message' => 'The given data was invalid.',- 'validation' => [- 'name' => ['The name field is required.'],- ],- 'code' => 422,- ],- ]);+ $resp->assertJson($this->validationResponse(['name' => ['The name field is required.']]));}public function test_link_or_file_needed_to_create()@@ -163,16 +155,27 @@ class AttachmentsApiTest extends TestCase$resp = $this->postJson($this->baseEndpoint, $details);$resp->assertStatus(422);- $resp->assertJson([- 'error' => [- 'message' => 'The given data was invalid.',- 'validation' => [- 'file' => ['The file field is required when link is not present.'],- 'link' => ['The link field is required when file is not present.'],- ],- 'code' => 422,- ],- ]);+ $resp->assertJson($this->validationResponse([+ 'file' => ['The file field is required when link is not present.'],+ 'link' => ['The link field is required when file is not present.'],+ ]));+ }++ public function test_message_shown_if_file_is_not_a_valid_file()+ {+ $this->actingAsApiAdmin();+ /** @var Page $page */+ $page = Page::query()->first();++ $details = [+ 'name' => 'my attachment',+ 'uploaded_to' => $page->id,+ 'file' => 'cat',+ ];++ $resp = $this->postJson($this->baseEndpoint, $details);+ $resp->assertStatus(422);+ $resp->assertJson($this->validationResponse(['file' => ['The file must be provided as a valid file.']]));}public function test_read_endpoint_for_link_attachment()diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.phpindex cf1ecd84d..20cde049a 100644--- a/tests/Entity/PageContentTest.php+++ b/tests/Entity/PageContentTest.php@@ -659,14 +659,14 @@ class PageContentTest extends TestCasepublic function test_markdown_base64_extract_not_limited_by_pcre_limits(){- $pcreBacktrackLimit = ini_get("pcre.backtrack_limit");- $pcreRecursionLimit = ini_get("pcre.recursion_limit");+ $pcreBacktrackLimit = ini_get('pcre.backtrack_limit');+ $pcreRecursionLimit = ini_get('pcre.recursion_limit');$this->asEditor();$page = Page::query()->first();- ini_set("pcre.backtrack_limit", "500");- ini_set("pcre.recursion_limit", "500");+ ini_set('pcre.backtrack_limit', '500');+ ini_set('pcre.recursion_limit', '500');$content = str_repeat('a', 5000);$base64Content = base64_encode($content);@@ -686,8 +686,8 @@ class PageContentTest extends TestCase$this->assertEquals($content, file_get_contents($imageFile));$this->deleteImage($imagePath);- ini_set("pcre.backtrack_limit", $pcreBacktrackLimit);- ini_set("pcre.recursion_limit", $pcreRecursionLimit);+ ini_set('pcre.backtrack_limit', $pcreBacktrackLimit);+ ini_set('pcre.recursion_limit', $pcreRecursionLimit);}public function test_base64_images_within_markdown_blanked_if_not_supported_extension_for_extract()