@@ -16,44 +16,32 @@ class PublicationFieldValidationRulesTest extends TestCase
16
16
{
17
17
public function testGetRulesForArray ()
18
18
{
19
- $ rules = (new PublicationField ('array ' , 'myArray ' , ' 4 ' , ' 8 ' ))->getValidationRules ();
19
+ $ rules = (new PublicationField ('array ' , 'myArray ' ))->getValidationRules ();
20
20
$ this ->assertSame (['array ' ], $ rules ->toArray ());
21
21
}
22
22
23
23
public function testValidateArrayPasses ()
24
24
{
25
- $ validated = (new PublicationField ('array ' , 'myArray ' , ' 4 ' , ' 8 ' ))->validate (['foo ' , 'bar ' , 'baz ' ]);
25
+ $ validated = (new PublicationField ('array ' , 'myArray ' ))->validate (['foo ' , 'bar ' , 'baz ' ]);
26
26
$ this ->assertSame (['my-array ' => ['foo ' , 'bar ' , 'baz ' ]], $ validated );
27
27
}
28
28
29
29
public function testValidateArrayFails ()
30
30
{
31
31
$ this ->expectValidationException ('The my-array must be an array. ' );
32
- (new PublicationField ('array ' , 'myArray ' , ' 4 ' , ' 8 ' ))->validate ('foo ' );
32
+ (new PublicationField ('array ' , 'myArray ' ))->validate ('foo ' );
33
33
}
34
34
35
35
public function testGetRulesForDatetime ()
36
36
{
37
- $ rules = (new PublicationField ('datetime ' , 'myDatetime ' , '2021-01-01 ' , '2022-01-01 ' ))->getValidationRules ();
38
- $ this ->assertSame (['date ' , 'after:2021-01-01 00:00:00 ' , 'before:2022-01-01 00:00:00 ' ], $ rules ->toArray ());
39
-
40
- $ rules = (new PublicationField ('datetime ' , 'myDatetime ' , '2021-01-01 ' ))->getValidationRules ();
41
- $ this ->assertSame (['date ' , 'after:2021-01-01 00:00:00 ' ], $ rules ->toArray ());
42
-
43
- $ rules = (new PublicationField ('datetime ' , 'myDatetime ' , null , '2022-01-01 ' ))->getValidationRules ();
44
- $ this ->assertSame (['date ' , 'before:2022-01-01 00:00:00 ' ], $ rules ->toArray ());
37
+ $ rules = (new PublicationField ('datetime ' , 'myDatetime ' ))->getValidationRules ();
38
+ $ this ->assertSame (['date ' ], $ rules ->toArray ());
45
39
}
46
40
47
41
public function testValidateDatetimePasses ()
48
42
{
49
43
$ validated = (new PublicationField ('datetime ' , 'myDatetime ' ))->validate ('2021-01-01 ' );
50
44
$ this ->assertSame (['my-datetime ' => '2021-01-01 ' ], $ validated );
51
-
52
- $ validated = (new PublicationField ('datetime ' , 'myDatetime ' , '2021-01-01 ' ))->validate ('2021-01-02 ' );
53
- $ this ->assertSame (['my-datetime ' => '2021-01-02 ' ], $ validated );
54
-
55
- $ validated = (new PublicationField ('datetime ' , 'myDatetime ' , null , '2021-01-02 ' ))->validate ('2021-01-01 ' );
56
- $ this ->assertSame (['my-datetime ' => '2021-01-01 ' ], $ validated );
57
45
}
58
46
59
47
public function testValidateDatetimeFailsForInvalidType ()
@@ -62,61 +50,48 @@ public function testValidateDatetimeFailsForInvalidType()
62
50
(new PublicationField ('datetime ' , 'myDatetime ' ))->validate ('string ' );
63
51
}
64
52
65
- public function testValidateDatetimeFailsForInvalidMinValue ()
66
- {
67
- $ this ->expectValidationException ('The my-datetime must be a date after 2021-01-01 00:00:00. ' );
68
- (new PublicationField ('datetime ' , 'myDatetime ' , '2021-01-01 ' ))->validate ('2020-12-31 ' );
69
- }
70
-
71
- public function testValidateDatetimeFailsForInvalidMaxValue ()
72
- {
73
- $ this ->expectValidationException ('The my-datetime must be a date before 2021-01-02 00:00:00. ' );
74
- (new PublicationField ('datetime ' , 'myDatetime ' , null , '2021-01-02 ' ))->validate ('2021-01-03 ' );
75
- }
76
-
77
53
public function testGetRulesForFloat ()
78
54
{
79
- $ rules = (new PublicationField ('float ' , 'myFloat ' , '4 ' , '8 ' ))->getValidationRules ();
80
- $ this ->assertSame (['between:4,8 ' ], $ rules ->toArray ());
81
- $ this ->assertSame (['numeric ' , 'between:4,8 ' ], $ rules ->toArray ());
55
+ $ rules = (new PublicationField ('float ' , 'myFloat ' ))->getValidationRules ();
56
+ $ this ->assertSame (['numeric ' ], $ rules ->toArray ());
82
57
}
83
58
84
59
public function testGetRulesForInteger ()
85
60
{
86
- $ rules = (new PublicationField ('integer ' , 'myInteger ' , ' 4 ' , ' 8 ' ))->getValidationRules ();
87
- $ this ->assertSame ([' between:4,8 ' ], $ rules ->toArray ());
61
+ $ rules = (new PublicationField ('integer ' , 'myInteger ' ))->getValidationRules ();
62
+ $ this ->assertSame ([], $ rules ->toArray ());
88
63
}
89
64
90
65
public function testGetRulesForString ()
91
66
{
92
- $ rules = (new PublicationField ('string ' , 'myString ' , ' 4 ' , ' 8 ' ))->getValidationRules ();
93
- $ this ->assertSame ([' between:4,8 ' ], $ rules ->toArray ());
67
+ $ rules = (new PublicationField ('string ' , 'myString ' ))->getValidationRules ();
68
+ $ this ->assertSame ([], $ rules ->toArray ());
94
69
}
95
70
96
71
public function testGetRulesForText ()
97
72
{
98
- $ rules = (new PublicationField ('text ' , 'myText ' , ' 4 ' , ' 8 ' ))->getValidationRules ();
99
- $ this ->assertSame ([' between:4,8 ' ], $ rules ->toArray ());
73
+ $ rules = (new PublicationField ('text ' , 'myText ' ))->getValidationRules ();
74
+ $ this ->assertSame ([], $ rules ->toArray ());
100
75
}
101
76
102
77
public function testGetRulesForImage ()
103
78
{
104
79
$ this ->directory ('_media/foo ' );
105
80
$ this ->file ('_media/foo/bar.jpg ' );
106
81
$ this ->file ('_media/foo/baz.png ' );
107
- $ rules = (new PublicationField ('image ' , 'myImage ' , ' 4 ' , ' 8 ' , publicationType: new PublicationType ('foo ' )))->getValidationRules ();
82
+ $ rules = (new PublicationField ('image ' , 'myImage ' , publicationType: new PublicationType ('foo ' )))->getValidationRules ();
108
83
$ this ->assertSame (['in:_media/foo/bar.jpg,_media/foo/baz.png ' ], $ rules ->toArray ());
109
84
}
110
85
111
86
public function testGetRulesForTag ()
112
87
{
113
- $ rules = (new PublicationField ('tag ' , 'myTag ' , ' 4 ' , ' 8 ' , 'foo ' ))->getValidationRules ();
88
+ $ rules = (new PublicationField ('tag ' , 'myTag ' , tagGroup: 'foo ' ))->getValidationRules ();
114
89
$ this ->assertSame (['in: ' ], $ rules ->toArray ());
115
90
}
116
91
117
92
public function testGetRulesForUrl ()
118
93
{
119
- $ rules = (new PublicationField ('url ' , 'myUrl ' , ' 4 ' , ' 8 ' ))->getValidationRules ();
94
+ $ rules = (new PublicationField ('url ' , 'myUrl ' ))->getValidationRules ();
120
95
$ this ->assertSame (['url ' ], $ rules ->toArray ());
121
96
}
122
97
0 commit comments