6
6
7
7
require ('vendor/autoload.php ' );
8
8
9
+ use PHPUnit \Framework \Attributes \DataProvider ;
9
10
use PHPUnit \Framework \TestCase ;
10
11
use Macocci7 \PhpCombination \Util ;
11
12
use Macocci7 \PhpCombination \Combination ;
@@ -32,9 +33,7 @@ public static function provide_all_can_return_all_combinations_correctly(): arra
32
33
];
33
34
}
34
35
35
- /**
36
- * @dataProvider provide_all_can_return_all_combinations_correctly
37
- */
36
+ #[DataProvider('provide_all_can_return_all_combinations_correctly ' )]
38
37
public function test_all_can_return_all_combinations_correctly (array $ items , array $ expect ): void
39
38
{
40
39
$ c = new Combination ();
@@ -50,9 +49,7 @@ public static function provide_all_can_sort_correctly(): array
50
49
];
51
50
}
52
51
53
- /**
54
- * @dataProvider provide_all_can_sort_correctly
55
- */
52
+ #[DataProvider('provide_all_can_sort_correctly ' )]
56
53
public function test_all_can_sort_correctly (array $ items , array $ expect ): void
57
54
{
58
55
$ c = new Combination ();
@@ -66,9 +63,7 @@ public static function provide_pairs_can_throw_exception_with_invalid_param(): a
66
63
];
67
64
}
68
65
69
- /**
70
- * @dataProvider provide_pairs_can_throw_exception_with_invalid_param
71
- */
66
+ #[DataProvider('provide_pairs_can_throw_exception_with_invalid_param ' )]
72
67
public function test_pairs_can_throw_exception_with_invalid_param (array $ items ): void
73
68
{
74
69
$ c = new Combination ();
@@ -86,9 +81,7 @@ public static function provide_pairs_can_return_all_pairs_correctly(): array
86
81
];
87
82
}
88
83
89
- /**
90
- * @dataProvider provide_pairs_can_return_all_pairs_correctly
91
- */
84
+ #[DataProvider('provide_pairs_can_return_all_pairs_correctly ' )]
92
85
public function test_pairs_can_return_all_pairs_correctly (array $ items , array $ expect ): void
93
86
{
94
87
$ c = new Combination ();
@@ -111,9 +104,7 @@ public static function provide_ofN_can_throw_exception_with_invalid_param(): arr
111
104
];
112
105
}
113
106
114
- /**
115
- * @dataProvider provide_ofN_can_throw_exception_with_invalid_param
116
- */
107
+ #[DataProvider('provide_ofN_can_throw_exception_with_invalid_param ' )]
117
108
public function test_ofN_can_throw_exception_with_invalid_param (array $ items , int $ n ): void
118
109
{
119
110
$ c = new Combination ();
@@ -134,9 +125,7 @@ public static function provide_ofN_can_return_all_combinations_of_n_elements_cor
134
125
];
135
126
}
136
127
137
- /**
138
- * @dataProvider provide_ofN_can_return_all_combinations_of_n_elements_correctly
139
- */
128
+ #[DataProvider('provide_ofN_can_return_all_combinations_of_n_elements_correctly ' )]
140
129
public function test_ofN_can_return_all_combinations_of_n_elements_correctly (array $ items , int $ n , array $ expect ): void
141
130
{
142
131
$ c = new Combination ();
@@ -159,9 +148,7 @@ public static function provide_ofA2B_can_throw_exception_with_invalid_param(): a
159
148
];
160
149
}
161
150
162
- /**
163
- * @dataProvider provide_ofA2B_can_throw_exception_with_invalid_param
164
- */
151
+ #[DataProvider('provide_ofA2B_can_throw_exception_with_invalid_param ' )]
165
152
public function test_ofA2B_can_throw_exception_with_invalid_param (array $ items , int $ a , int $ b , string $ message ): void
166
153
{
167
154
$ c = new Combination ();
@@ -179,9 +166,7 @@ public static function provide_ofA2B_can_return_all_combinations_of_A_2_B_elemen
179
166
];
180
167
}
181
168
182
- /**
183
- * @dataProvider provide_ofA2B_can_return_all_combinations_of_A_2_B_elements
184
- */
169
+ #[DataProvider('provide_ofA2B_can_return_all_combinations_of_A_2_B_elements ' )]
185
170
public function test_ofA2B_can_return_all_combinations_of_A_2_B_elements (array $ items , int $ a , int $ b , array $ expect ): void
186
171
{
187
172
$ c = new Combination ();
@@ -193,15 +178,13 @@ public static function provide_fromArrays_can_return_combinations_correctly(): a
193
178
return [
194
179
"1 element " => ['arrays ' => [[1 ]], 'expect ' => [[1 ]], ],
195
180
"1 element, 1 element " => ['arrays ' => [[1 ], [2 ], ], 'expect ' => [[1 , 2 , ]], ],
196
- "1 element, 2 elements " => ['array ' => [[1 ], [2 , 3 , ], ], 'expect ' => [[1 , 2 , ], [1 , 3 , ], ], ],
197
- "2 elements, 2 elements " => ['array ' => [[1 , 2 , ], [3 , 4 , ], ], 'expect ' => [[1 , 3 , ], [1 , 4 , ], [2 , 3 , ], [2 , 4 , ], ], ],
198
- "2 elements, 2 elements, 2 elements " => ['array ' => [[1 , 2 , ], [3 , 4 , ], [5 , 6 , ], ], 'expect ' => [[1 , 3 , 5 , ], [1 , 3 , 6 , ], [1 , 4 , 5 , ], [1 , 4 , 6 , ], [2 , 3 , 5 , ], [2 , 3 , 6 , ], [2 , 4 , 5 , ], [2 , 4 , 6 , ], ], ],
181
+ "1 element, 2 elements " => ['arrays ' => [[1 ], [2 , 3 , ], ], 'expect ' => [[1 , 2 , ], [1 , 3 , ], ], ],
182
+ "2 elements, 2 elements " => ['arrays ' => [[1 , 2 , ], [3 , 4 , ], ], 'expect ' => [[1 , 3 , ], [1 , 4 , ], [2 , 3 , ], [2 , 4 , ], ], ],
183
+ "2 elements, 2 elements, 2 elements " => ['arrays ' => [[1 , 2 , ], [3 , 4 , ], [5 , 6 , ], ], 'expect ' => [[1 , 3 , 5 , ], [1 , 3 , 6 , ], [1 , 4 , 5 , ], [1 , 4 , 6 , ], [2 , 3 , 5 , ], [2 , 3 , 6 , ], [2 , 4 , 5 , ], [2 , 4 , 6 , ], ], ],
199
184
];
200
185
}
201
186
202
- /**
203
- * @dataProvider provide_fromArrays_can_return_combinations_correctly
204
- */
187
+ #[DataProvider('provide_fromArrays_can_return_combinations_correctly ' )]
205
188
public function test_fromArrays_can_return_combinations_correctly (array $ arrays , array $ expect ): void
206
189
{
207
190
$ c = new Combination ();
0 commit comments