Skip to content

Commit 216a37b

Browse files
committed
refactor: code
refs: #49
1 parent 6067363 commit 216a37b

File tree

4 files changed

+21
-121
lines changed

4 files changed

+21
-121
lines changed

tests/Support/Translation/TranslationMockTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait TranslationMockTrait
1111

1212
public function mockFilesystem(): void
1313
{
14-
$fileSystemMock = new FileSystemMock;
14+
$fileSystemMock = new FileSystemMock();
1515

1616
$fileSystemMock->translations = [];
1717

@@ -22,7 +22,7 @@ public function mockFilesystemForAppend(): void
2222
{
2323
$validation = file_get_contents(getcwd() . '/tests/Support/Translation/validation_without_exceptions.php');
2424

25-
$fileSystemMock = new FileSystemMock;
25+
$fileSystemMock = new FileSystemMock();
2626

2727
$fileSystemMock->translations = ['validation.php' => $validation];
2828

Lines changed: 1 addition & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,3 @@
11
<?php
22

3-
return [
4-
5-
/*
6-
|--------------------------------------------------------------------------
7-
| Validation Language Lines
8-
|--------------------------------------------------------------------------
9-
|
10-
| The following language lines contain the default error messages used by
11-
| the validator class. Some of these rules have multiple versions such
12-
| as the size rules. Feel free to tweak each of these messages here.
13-
|
14-
*/
15-
16-
'accepted' => 'The :attribute must be accepted.',
17-
'active_url' => 'The :attribute is not a valid URL.',
18-
'after' => 'The :attribute must be a date after :date.',
19-
'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
20-
'alpha' => 'The :attribute may only contain letters.',
21-
'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
22-
'alpha_num' => 'The :attribute may only contain letters and numbers.',
23-
'array' => 'The :attribute must be an array.',
24-
'before' => 'The :attribute must be a date before :date.',
25-
'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
26-
'between' => [
27-
'numeric' => 'The :attribute must be between :min and :max.',
28-
'file' => 'The :attribute must be between :min and :max kilobytes.',
29-
'string' => 'The :attribute must be between :min and :max characters.',
30-
'array' => 'The :attribute must have between :min and :max items.',
31-
],
32-
'boolean' => 'The :attribute field must be true or false.',
33-
'confirmed' => 'The :attribute confirmation does not match.',
34-
'date' => 'The :attribute is not a valid date.',
35-
'date_format' => 'The :attribute does not match the format :format.',
36-
'different' => 'The :attribute and :other must be different.',
37-
'digits' => 'The :attribute must be :digits digits.',
38-
'digits_between' => 'The :attribute must be between :min and :max digits.',
39-
'dimensions' => 'The :attribute has invalid image dimensions.',
40-
'distinct' => 'The :attribute field has a duplicate value.',
41-
'email' => 'The :attribute must be a valid email address.',
42-
'exists' => 'The selected :attribute is invalid.',
43-
'file' => 'The :attribute must be a file.',
44-
'filled' => 'The :attribute field must have a value.',
45-
'image' => 'The :attribute must be an image.',
46-
'in' => 'The selected :attribute is invalid.',
47-
'in_array' => 'The :attribute field does not exist in :other.',
48-
'integer' => 'The :attribute must be an integer.',
49-
'ip' => 'The :attribute must be a valid IP address.',
50-
'ipv4' => 'The :attribute must be a valid IPv4 address.',
51-
'ipv6' => 'The :attribute must be a valid IPv6 address.',
52-
'json' => 'The :attribute must be a valid JSON string.',
53-
'max' => [
54-
'numeric' => 'The :attribute may not be greater than :max.',
55-
'file' => 'The :attribute may not be greater than :max kilobytes.',
56-
'string' => 'The :attribute may not be greater than :max characters.',
57-
'array' => 'The :attribute may not have more than :max items.',
58-
],
59-
'mimes' => 'The :attribute must be a file of type: :values.',
60-
'mimetypes' => 'The :attribute must be a file of type: :values.',
61-
'min' => [
62-
'numeric' => 'The :attribute must be at least :min.',
63-
'file' => 'The :attribute must be at least :min kilobytes.',
64-
'string' => 'The :attribute must be at least :min characters.',
65-
'array' => 'The :attribute must have at least :min items.',
66-
],
67-
'not_in' => 'The selected :attribute is invalid.',
68-
'numeric' => 'The :attribute must be a number.',
69-
'present' => 'The :attribute field must be present.',
70-
'regex' => 'The :attribute format is invalid.',
71-
'required' => 'The :attribute field is required.',
72-
'required_if' => 'The :attribute field is required when :other is :value.',
73-
'required_unless' => 'The :attribute field is required unless :other is in :values.',
74-
'required_with' => 'The :attribute field is required when :values is present.',
75-
'required_with_all' => 'The :attribute field is required when :values is present.',
76-
'required_without' => 'The :attribute field is required when :values is not present.',
77-
'required_without_all' => 'The :attribute field is required when none of :values are present.',
78-
'same' => 'The :attribute and :other must match.',
79-
'size' => [
80-
'numeric' => 'The :attribute must be :size.',
81-
'file' => 'The :attribute must be :size kilobytes.',
82-
'string' => 'The :attribute must be :size characters.',
83-
'array' => 'The :attribute must contain :size items.',
84-
],
85-
'string' => 'The :attribute must be a string.',
86-
'timezone' => 'The :attribute must be a valid zone.',
87-
'unique' => 'The :attribute has already been taken.',
88-
'uploaded' => 'The :attribute failed to upload.',
89-
'url' => 'The :attribute format is invalid.',
90-
91-
/*
92-
|--------------------------------------------------------------------------
93-
| Custom Validation Language Lines
94-
|--------------------------------------------------------------------------
95-
|
96-
| Here you may specify custom validation messages for attributes using the
97-
| convention "attribute.rule" to name the lines. This makes it quick to
98-
| specify a specific custom language line for a given attribute rule.
99-
|
100-
*/
101-
102-
'custom' => [
103-
'attribute-name' => [
104-
'rule-name' => 'custom-message',
105-
],
106-
],
107-
108-
/*
109-
|--------------------------------------------------------------------------
110-
| Custom Validation Attributes
111-
|--------------------------------------------------------------------------
112-
|
113-
| The following language lines are used to swap attribute place-holders
114-
| with something more reader friendly such as E-Mail Address instead
115-
| of "email". This simply helps us make messages a little cleaner.
116-
|
117-
*/
118-
119-
'attributes' => [],
120-
];
3+
return [];

tests/TranslationGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testAppendNotFoundException()
5757
->setModel('Post')
5858
->generate();
5959

60-
$this->assertGeneratedFileEquals('validation.php', 'resources/lang/en/validation.php');
60+
$this->assertGeneratedFileEquals('validation_append_not_found_exception.php', 'resources/lang/en/validation.php');
6161

6262
Event::assertNothingDispatched();
6363
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Custom Validation Attributes
7+
|--------------------------------------------------------------------------
8+
|
9+
| The following language lines are used to swap http error messages.
10+
|
11+
*/
12+
13+
'exceptions' => [
14+
'not_found' => ':Entity does not exist',
15+
],
16+
17+
];

0 commit comments

Comments
 (0)