@@ -34,12 +34,12 @@ public function setup()
34
34
}
35
35
36
36
/**
37
- * @covers ::filterInstance
37
+ * @covers ::allowInstance
38
38
*/
39
39
public function testMultiValueFilterArrayAccess ()
40
40
{
41
41
// Allow images
42
- $ this ->multiValue ->filterInstance (Image::class);
42
+ $ this ->multiValue ->allowInstance (Image::class);
43
43
44
44
$ this ->assertCount (2 , $ this ->multiValue );
45
45
$ this ->assertInstanceOf (Image::class, $ this ->multiValue [0 ]);
@@ -48,7 +48,7 @@ public function testMultiValueFilterArrayAccess()
48
48
$ this ->assertEquals ('image/png ' , $ this ->multiValue [1 ]->getMimeType ());
49
49
50
50
// Allow MultiValue.
51
- $ this ->multiValue ->filterInstance (MultiValue::class);
51
+ $ this ->multiValue ->allowInstance (MultiValue::class);
52
52
53
53
$ this ->assertCount (3 , $ this ->multiValue );
54
54
$ this ->assertInstanceOf (MultiValue::class, $ this ->multiValue [2 ]);
@@ -59,12 +59,12 @@ public function testMultiValueFilterArrayAccess()
59
59
}
60
60
61
61
/**
62
- * @covers ::filterInstance
62
+ * @covers ::allowInstance
63
63
*/
64
64
public function testMultiValueFilterIterator ()
65
65
{
66
66
// Allow images
67
- $ this ->multiValue ->filterInstance (Image::class);
67
+ $ this ->multiValue ->allowInstance (Image::class);
68
68
69
69
foreach ($ this ->multiValue as $ item ) {
70
70
$ this ->assertInstanceOf (Image::class, $ item );
@@ -73,14 +73,13 @@ public function testMultiValueFilterIterator()
73
73
74
74
/**
75
75
* @covers ::filterType
76
- * @covers ::filterInstance
76
+ * @covers ::allowInstance
77
77
*/
78
78
public function testMultiValueFilterMultipleTypes ()
79
79
{
80
- // Allow images and strings;
81
80
$ this ->multiValue
82
- ->filterInstance (Image::class)
83
- ->filterType ('string ' );
81
+ ->allowInstance (Image::class)
82
+ ->allowType ('string ' );
84
83
85
84
$ this ->assertCount (5 , $ this ->multiValue );
86
85
$ this ->assertEquals ('string 1 ' , $ this ->multiValue [0 ]);
@@ -96,12 +95,12 @@ public function testMultiValueFilterMultipleTypes()
96
95
*/
97
96
public function testMultiValueCustomFilters ()
98
97
{
99
- // Allow images
98
+ // Custom filter to allow images.
100
99
$ this ->multiValue ->filter (function ($ item ) {
101
100
return $ item instanceof Image;
102
101
});
103
102
104
- // Allow strings
103
+ // Custom filter to allow strings.
105
104
$ this ->multiValue ->filter (function ($ item ) {
106
105
return gettype ($ item ) === 'string ' ;
107
106
});
@@ -113,62 +112,6 @@ public function testMultiValueCustomFilters()
113
112
$ this ->assertEquals ('image/jpeg ' , $ this ->multiValue [2 ]->getMimeType ());
114
113
$ this ->assertInstanceOf (Image::class, $ this ->multiValue [3 ]);
115
114
$ this ->assertEquals ('image/png ' , $ this ->multiValue [3 ]->getMimeType ());
116
-
117
- // Filter long strings.
118
- $ this ->multiValue ->resetFilters ();
119
- $ this ->multiValue ->filter (function ($ item ) {
120
- return gettype ($ item ) === 'string ' && strlen ($ item ) > 8 ;
121
- });
122
- $ this ->assertCount (1 , $ this ->multiValue );
123
- $ this ->assertEquals ('longer string 5 ' , $ this ->multiValue [0 ]);
124
- }
125
-
126
- /**
127
- * @covers ::resetFilters
128
- */
129
- public function testMultiValueResetFilters ()
130
- {
131
- $ this ->assertCount (8 , $ this ->multiValue );
132
-
133
- // Allow images
134
- $ this ->multiValue ->filter (function ($ item ) {
135
- return $ item instanceof Image;
136
- });
137
-
138
- // Allow strings
139
- $ this ->multiValue ->filter (function ($ item ) {
140
- return gettype ($ item ) === 'string ' ;
141
- });
142
-
143
- $ this ->assertCount (5 , $ this ->multiValue );
144
-
145
- // Reset filters.
146
- $ this ->multiValue ->resetFilters ();
147
- $ this ->assertCount (8 , $ this ->multiValue );
148
-
149
- // Allow MultiValue.
150
- $ this ->multiValue ->filter (function ($ item ) {
151
- return $ item instanceof MultiValue;
152
- });
153
-
154
- // Allow images
155
- $ this ->multiValue ->filter (function ($ item ) {
156
- return $ item instanceof Image;
157
- });
158
-
159
- $ this ->assertInstanceOf (MultiValue::class, $ this ->multiValue [2 ]);
160
- $ this ->assertCount (1 , $ this ->multiValue [2 ]);
161
-
162
- // Check nested image.
163
- $ this ->assertCount (1 , $ this ->multiValue [2 ]);
164
- $ this ->assertInstanceOf (Image::class, $ this ->multiValue [2 ][0 ]);
165
-
166
- // Reset filters.
167
- $ this ->multiValue ->resetFilters ();
168
-
169
- // Check nested image.
170
- $ this ->assertCount (3 , $ this ->multiValue [6 ]);
171
- $ this ->assertInstanceOf (Image::class, $ this ->multiValue [6 ][2 ]);
172
115
}
173
116
174
117
/**
@@ -187,51 +130,26 @@ public function testImmutableFilter()
187
130
188
131
/**
189
132
* @covers ::immutable
190
- * @covers ::filterType
133
+ * @covers ::allowType
191
134
*
192
135
* @expectedException \LogicException
193
136
* @expectedExceptionMessage Attempting to filter immutable array
194
137
*/
195
- public function testImmutableFilterType ()
138
+ public function testImmutableAllowType ()
196
139
{
197
- $ this ->multiValue ->immutable ()->filterType ('string ' );
140
+ $ this ->multiValue ->immutable ()->allowType ('string ' );
198
141
}
199
142
200
143
/**
201
144
* @covers ::immutable
202
- * @covers ::filterInstance
145
+ * @covers ::allowInstance
203
146
*
204
147
* @expectedException \LogicException
205
148
* @expectedExceptionMessage Attempting to filter immutable array
206
149
*/
207
- public function testImmutableFilterInstance ()
150
+ public function testImmutableAllowInstance ()
208
151
{
209
- $ this ->multiValue ->immutable ()->filterInstance (Image::class);
210
- }
211
-
212
- /**
213
- * @covers ::immutable
214
- * @covers ::resetFilters
215
- *
216
- * @expectedException \LogicException
217
- * @expectedExceptionMessage Attempting to reset filters on immutable array
218
- */
219
- public function testImmutableResetFilters ()
220
- {
221
- // Apply image filter.
222
- $ this ->multiValue
223
- ->filterInstance (Image::class);
224
- $ this ->assertCount (2 , $ this ->multiValue );
225
-
226
- // Reset filters.
227
- $ this ->multiValue ->resetFilters ();
228
- $ this ->assertCount (8 , $ this ->multiValue );
229
-
230
- // Make immutable.
231
- $ this ->multiValue ->immutable ();
232
-
233
- // Filters cannot be reset.
234
- $ this ->multiValue ->resetFilters ();
152
+ $ this ->multiValue ->immutable ()->allowInstance (Image::class);
235
153
}
236
154
237
155
/**
0 commit comments