8
8
* @author Blobfolio, LLC <[email protected] >
9
9
*/
10
10
11
+ use PHPUnit \Framework \Attributes \DataProvider ;
12
+ use PHPUnit \Framework \Attributes \Test ;
13
+ use PHPUnit \Framework \TestCase ;
11
14
use blobfolio \common \cast as v_cast ;
12
15
use blobfolio \common \ref \cast as r_cast ;
13
16
14
17
/**
15
18
* Test Suite
16
19
*/
17
- class cast_tests extends \ PHPUnit \ Framework \ TestCase {
20
+ class cast_tests extends TestCase {
18
21
// -----------------------------------------------------------------
19
22
// Tests
20
23
// -----------------------------------------------------------------
21
24
25
+ #[Test]
26
+ #[DataProvider('data_array ' )]
22
27
/**
23
28
* ::array()
24
29
*
25
- * @dataProvider data_array
26
- *
27
30
* @param mixed $value Value.
28
31
* @param array $expected Expected.
29
32
*/
30
- function test_array ($ value , $ expected ) {
33
+ public function test_array ($ value , $ expected ) {
31
34
$ this ->assertEquals ($ expected , v_cast::to_array ($ value ));
32
35
$ this ->assertEquals ('array ' , \gettype (v_cast::to_array ($ value )));
33
36
}
34
37
38
+ #[Test]
39
+ #[DataProvider('data_array ' )]
35
40
/**
36
41
* ::array() alias
37
42
*
38
- * @dataProvider data_array
39
- *
40
43
* @param mixed $value Value.
41
44
* @param array $expected Expected.
42
45
*/
43
- function test_array_alias ($ value , $ expected ) {
46
+ public function test_array_alias ($ value , $ expected ) {
44
47
if (\version_compare (\PHP_VERSION , '7.0.0 ' ) < 0 ) {
45
48
$ this ->markTestSkipped ('Aliases are only supported in PHP 7+. ' );
46
49
}
@@ -56,41 +59,41 @@ function test_array_alias($value, $expected) {
56
59
$ this ->assertEquals ($ expected , $ value );
57
60
}
58
61
62
+ #[Test]
63
+ #[DataProvider('data_array_type ' )]
59
64
/**
60
65
* ::array_type()
61
66
*
62
- * @dataProvider data_array_type
63
- *
64
67
* @param mixed $value Value.
65
68
* @param string $expected Expected.
66
69
*/
67
- function test_array_type ($ value , $ expected ) {
70
+ public function test_array_type ($ value , $ expected ) {
68
71
$ this ->assertEquals ($ expected , v_cast::array_type ($ value ));
69
72
}
70
73
74
+ #[Test]
75
+ #[DataProvider('data_bool ' )]
71
76
/**
72
77
* ::bool()
73
78
*
74
- * @dataProvider data_bool
75
- *
76
79
* @param mixed $value Value.
77
80
* @param bool $flatten Flatten.
78
81
* @param string $expected Expected.
79
82
*/
80
- function test_bool ($ value , $ flatten , $ expected ) {
83
+ public function test_bool ($ value , $ flatten , $ expected ) {
81
84
$ this ->assertSame ($ expected , v_cast::to_bool ($ value , $ flatten ));
82
85
}
83
86
87
+ #[Test]
88
+ #[DataProvider('data_bool ' )]
84
89
/**
85
90
* ::bool() alias
86
91
*
87
- * @dataProvider data_bool
88
- *
89
92
* @param mixed $value Value.
90
93
* @param bool $flatten Flatten.
91
94
* @param string $expected Expected.
92
95
*/
93
- function test_bool_alias ($ value , $ flatten , $ expected ) {
96
+ public function test_bool_alias ($ value , $ flatten , $ expected ) {
94
97
if (\version_compare (\PHP_VERSION , '7.0.0 ' ) < 0 ) {
95
98
$ this ->markTestSkipped ('Aliases are only supported in PHP 7+. ' );
96
99
}
@@ -107,29 +110,29 @@ function test_bool_alias($value, $flatten, $expected) {
107
110
$ this ->assertSame ($ expected , $ value2 );
108
111
}
109
112
113
+ #[Test]
114
+ #[DataProvider('data_float ' )]
110
115
/**
111
116
* ::float()
112
117
*
113
- * @dataProvider data_float
114
- *
115
118
* @param mixed $value Value.
116
119
* @param bool $flatten Flatten.
117
120
* @param string $expected Expected.
118
121
*/
119
- function test_float ($ value , $ flatten , $ expected ) {
122
+ public function test_float ($ value , $ flatten , $ expected ) {
120
123
$ this ->assertSame ($ expected , v_cast::to_float ($ value , $ flatten ));
121
124
}
122
125
126
+ #[Test]
127
+ #[DataProvider('data_float ' )]
123
128
/**
124
129
* ::float() alias
125
130
*
126
- * @dataProvider data_float
127
- *
128
131
* @param mixed $value Value.
129
132
* @param bool $flatten Flatten.
130
133
* @param string $expected Expected.
131
134
*/
132
- function test_float_alias ($ value , $ flatten , $ expected ) {
135
+ public function test_float_alias ($ value , $ flatten , $ expected ) {
133
136
if (\version_compare (\PHP_VERSION , '7.0.0 ' ) < 0 ) {
134
137
$ this ->markTestSkipped ('Aliases are only supported in PHP 7+. ' );
135
138
}
@@ -146,24 +149,24 @@ function test_float_alias($value, $flatten, $expected) {
146
149
$ this ->assertSame ($ expected , $ value2 );
147
150
}
148
151
152
+ #[Test]
153
+ #[DataProvider('data_int ' )]
149
154
/**
150
155
* ::int()
151
156
*
152
- * @dataProvider data_int
153
- *
154
157
* @param mixed $value Value.
155
158
* @param bool $flatten Flatten.
156
159
* @param string $expected Expected.
157
160
*/
158
- function test_int ($ value , $ flatten , $ expected ) {
161
+ public function test_int ($ value , $ flatten , $ expected ) {
159
162
$ this ->assertSame ($ expected , v_cast::to_int ($ value , $ flatten ));
160
163
}
161
164
165
+ #[Test]
166
+ #[DataProvider('data_int ' )]
162
167
/**
163
168
* ::int() alias
164
169
*
165
- * @dataProvider data_int
166
- *
167
170
* @param mixed $value Value.
168
171
* @param bool $flatten Flatten.
169
172
* @param string $expected Expected.
@@ -185,29 +188,29 @@ function test_int_alias($value, $flatten, $expected) {
185
188
$ this ->assertSame ($ expected , $ value2 );
186
189
}
187
190
191
+ #[Test]
192
+ #[DataProvider('data_string ' )]
188
193
/**
189
194
* ::string()
190
195
*
191
- * @dataProvider data_string
192
- *
193
196
* @param mixed $value Value.
194
197
* @param bool $flatten Flatten.
195
198
* @param string $expected Expected.
196
199
*/
197
- function test_string ($ value , $ flatten , $ expected ) {
200
+ public function test_string ($ value , $ flatten , $ expected ) {
198
201
$ this ->assertSame ($ expected , v_cast::to_string ($ value , $ flatten ));
199
202
}
200
203
204
+ #[Test]
205
+ #[DataProvider('data_string ' )]
201
206
/**
202
207
* ::string() alias
203
208
*
204
- * @dataProvider data_string
205
- *
206
209
* @param mixed $value Value.
207
210
* @param bool $flatten Flatten.
208
211
* @param string $expected Expected.
209
212
*/
210
- function test_string_alias ($ value , $ flatten , $ expected ) {
213
+ public function test_string_alias ($ value , $ flatten , $ expected ) {
211
214
if (\version_compare (\PHP_VERSION , '7.0.0 ' ) < 0 ) {
212
215
$ this ->markTestSkipped ('Aliases are only supported in PHP 7+. ' );
213
216
}
@@ -218,12 +221,11 @@ function test_string_alias($value, $flatten, $expected) {
218
221
$ this ->assertSame ($ expected , $ value );
219
222
}
220
223
221
-
224
+ #[Test]
225
+ #[DataProvider('data_to_type ' )]
222
226
/**
223
227
* ::to_type()
224
228
*
225
- * @dataProvider data_to_type
226
- *
227
229
* @param mixed $value Value.
228
230
* @param string $type Type.
229
231
* @param bool $flatten Flatten.
@@ -246,7 +248,7 @@ function test_to_type($value, $type, $flatten, $expected) {
246
248
*
247
249
* @return array Data.
248
250
*/
249
- function data_array () {
251
+ static function data_array () {
250
252
return array (
251
253
array (
252
254
'string ' ,
@@ -272,7 +274,7 @@ function data_array() {
272
274
*
273
275
* @return array Data.
274
276
*/
275
- function data_array_type () {
277
+ static function data_array_type () {
276
278
return array (
277
279
array (
278
280
'string ' ,
@@ -322,7 +324,7 @@ function data_array_type() {
322
324
*
323
325
* @return array Data.
324
326
*/
325
- function data_bool () {
327
+ static function data_bool () {
326
328
return array (
327
329
array (
328
330
'string ' ,
@@ -367,7 +369,7 @@ function data_bool() {
367
369
*
368
370
* @return array Data.
369
371
*/
370
- function data_float () {
372
+ static function data_float () {
371
373
return array (
372
374
array (
373
375
'string ' ,
@@ -422,7 +424,7 @@ function data_float() {
422
424
*
423
425
* @return array Data.
424
426
*/
425
- function data_int () {
427
+ static function data_int () {
426
428
return array (
427
429
array (
428
430
'string ' ,
@@ -472,7 +474,7 @@ function data_int() {
472
474
*
473
475
* @return array Data.
474
476
*/
475
- function data_string () {
477
+ static function data_string () {
476
478
return array (
477
479
array (
478
480
"Hello \nWorld " ,
@@ -517,7 +519,7 @@ function data_string() {
517
519
*
518
520
* @return array Data.
519
521
*/
520
- function data_to_type () {
522
+ static function data_to_type () {
521
523
return array (
522
524
array (
523
525
null ,
0 commit comments