From 937e71ab9e5b2b2a5bc9dbf4da6bb14428e41f07 Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Fri, 26 Jul 2024 13:31:44 +0200 Subject: [PATCH] Use fixtures for results --- webapp/tests/Unit/Fixtures/results-full.tsv | 131 +++++++++++++ webapp/tests/Unit/Fixtures/results-wf.tsv | 131 +++++++++++++ .../Unit/Service/ImportExportServiceTest.php | 172 ++---------------- 3 files changed, 278 insertions(+), 156 deletions(-) create mode 100644 webapp/tests/Unit/Fixtures/results-full.tsv create mode 100644 webapp/tests/Unit/Fixtures/results-wf.tsv diff --git a/webapp/tests/Unit/Fixtures/results-full.tsv b/webapp/tests/Unit/Fixtures/results-full.tsv new file mode 100644 index 00000000000..102ab2f5052 --- /dev/null +++ b/webapp/tests/Unit/Fixtures/results-full.tsv @@ -0,0 +1,131 @@ +results 1 +870679 1 Gold Medal 9 995 216 Northern Eurasia +870257 2 Gold Medal 9 1068 227 Asia East +870678 3 Gold Medal 9 1143 206 +873624 4 Gold Medal 9 1304 292 Europe +870259 5 Silver Medal 9 1524 274 +870260 6 Silver Medal 8 1013 281 +928309 7 Silver Medal 8 1102 230 Asia Pacific +870037 8 Silver Medal 8 1120 268 North America +870583 9 Bronze Medal 8 1121 260 +870584 10 Bronze Medal 8 1424 291 +870051 11 Bronze Medal 7 842 279 +870647 12 Bronze Medal 7 940 259 +870670 13 Highest Honors 7 955 291 Latin America +870585 14 Highest Honors 7 962 290 +870649 14 Highest Honors 7 962 290 +870271 16 Highest Honors 7 980 283 +870642 17 Highest Honors 7 1021 256 +870045 18 Highest Honors 7 1076 271 +870582 19 Highest Honors 7 1128 278 +870654 20 Highest Honors 7 1130 284 +868994 21 Highest Honors 7 1381 296 +870644 22 High Honors 6 510 187 +870646 23 High Honors 6 642 216 +870680 24 High Honors 6 645 218 +881825 25 High Honors 6 680 237 +871349 26 High Honors 6 683 246 +870692 27 High Honors 6 708 243 +870041 28 High Honors 6 718 260 +870268 29 High Honors 6 765 292 +870681 30 High Honors 6 932 287 +870040 31 High Honors 6 968 238 +870044 32 High Honors 6 1010 275 +870658 33 High Honors 6 1046 293 +870038 34 High Honors 6 1103 282 +870696 35 High Honors 6 1189 290 +870650 36 Honors 5 398 137 +870672 37 Honors 5 489 158 +870656 38 Honors 5 496 116 +870043 39 Honors 5 522 160 +870648 40 Honors 5 573 168 +870652 41 Honors 5 578 143 +870627 42 Honors 5 579 180 Asia West +870639 43 Honors 5 582 213 +870273 44 Honors 5 592 199 +870653 45 Honors 5 630 292 +870659 46 Honors 5 644 154 +870683 47 Honors 5 653 207 +870874 48 Honors 5 660 221 +870052 49 Honors 5 662 181 +870270 50 Honors 5 683 239 +870046 51 Honors 5 737 227 +870050 52 Honors 5 739 260 +870637 53 Honors 5 742 255 +870048 54 Honors 5 743 271 +870630 55 Honors 5 747 247 +870272 56 Honors 5 747 284 +870667 57 Honors 5 770 216 +870686 58 Honors 5 795 219 +870578 59 Honors 5 807 257 +870579 60 Honors 5 822 205 +870267 61 Honors 5 833 257 +870674 62 Honors 5 837 226 +870691 63 Honors 5 839 243 +870264 64 Honors 5 850 209 +870635 65 Honors 5 862 275 +870590 66 Honors 5 867 245 +870269 67 Honors 5 878 267 +870668 68 Honors 5 889 257 +870263 69 Honors 5 891 220 +870065 70 Honors 5 908 238 Africa and Arab +870053 71 Honors 5 968 260 +870042 72 Honors 5 971 292 +870689 73 Honors 5 1008 298 +870685 74 Honors 5 1048 267 +870638 75 Honors 5 1164 294 +871379 76 Honors 5 1227 273 +870056 Honorable 2 465 299 +870055 Honorable 4 465 164 +870063 Honorable 1 348 288 +870066 Honorable 2 289 173 +870054 Honorable 4 693 255 +870067 Honorable 2 405 259 +870688 Honorable 4 632 198 +870690 Honorable 3 691 271 +870574 Honorable 4 339 128 +870640 Honorable 3 435 195 +870636 Honorable 3 333 130 +870061 Honorable 1 140 140 +871347 Honorable 3 599 287 +870577 Honorable 4 590 215 +870057 Honorable 2 367 253 +870641 Honorable 3 448 243 +870663 Honorable 0 0 0 +870662 Honorable 2 459 238 +870058 Honorable 2 312 196 +870629 Honorable 3 538 299 +870628 Honorable 4 712 298 +870631 Honorable 4 421 191 +870632 Honorable 4 603 266 +870633 Honorable 3 469 250 +870634 Honorable 1 96 96 +870694 Honorable 4 879 290 +870068 Honorable 1 74 74 +870693 Honorable 3 650 279 +870587 Honorable 4 447 228 +870588 Honorable 4 707 244 +873768 Honorable 4 651 210 +870687 Honorable 4 870 268 +870643 Honorable 4 379 192 +870581 Honorable 2 398 287 +870258 Honorable 4 448 141 +870062 Honorable 1 58 58 +869963 Honorable 4 920 274 +870675 Honorable 1 162 162 +870664 Honorable 2 255 226 +870660 Honorable 3 766 289 +870676 Honorable 2 279 150 +870673 Honorable 1 230 190 +870671 Honorable 3 333 196 +870661 Honorable 3 728 272 +870669 Honorable 4 654 210 +870666 Honorable 3 382 177 +870665 Honorable 3 568 224 +870657 Honorable 4 333 107 +870651 Honorable 4 474 160 +870645 Honorable 3 609 277 +870591 Honorable 1 86 66 +870589 Honorable 3 480 178 +870039 Honorable 3 596 252 +870697 Honorable 3 761 275 diff --git a/webapp/tests/Unit/Fixtures/results-wf.tsv b/webapp/tests/Unit/Fixtures/results-wf.tsv new file mode 100644 index 00000000000..6245dad638a --- /dev/null +++ b/webapp/tests/Unit/Fixtures/results-wf.tsv @@ -0,0 +1,131 @@ +results 1 +870679 1 Gold Medal 9 995 216 Northern Eurasia +870257 2 Gold Medal 9 1068 227 Asia East +870678 3 Gold Medal 9 1143 206 +873624 4 Gold Medal 9 1304 292 Europe +870259 5 Silver Medal 9 1524 274 +870260 6 Silver Medal 8 1013 281 +928309 7 Silver Medal 8 1102 230 Asia Pacific +870037 8 Silver Medal 8 1120 268 North America +870583 9 Bronze Medal 8 1121 260 +870584 10 Bronze Medal 8 1424 291 +870051 11 Bronze Medal 7 842 279 +870647 12 Bronze Medal 7 940 259 +870654 13 Highest Honors 7 1130 284 +870582 13 Highest Honors 7 1128 278 +870045 13 Highest Honors 7 1076 271 +870585 13 Highest Honors 7 962 290 +870670 13 Highest Honors 7 955 291 Latin America +870649 13 Highest Honors 7 962 290 +868994 13 Highest Honors 7 1381 296 +870642 13 Highest Honors 7 1021 256 +870271 13 Highest Honors 7 980 283 +870681 22 High Honors 6 932 287 +870038 22 High Honors 6 1103 282 +870044 22 High Honors 6 1010 275 +870268 22 High Honors 6 765 292 +870646 22 High Honors 6 642 216 +870644 22 High Honors 6 510 187 +870040 22 High Honors 6 968 238 +870692 22 High Honors 6 708 243 +870680 22 High Honors 6 645 218 +870658 22 High Honors 6 1046 293 +881825 22 High Honors 6 680 237 +870041 22 High Honors 6 718 260 +870696 22 High Honors 6 1189 290 +871349 22 High Honors 6 683 246 +870635 36 Honors 5 862 275 +870267 36 Honors 5 833 257 +870638 36 Honors 5 1164 294 +870264 36 Honors 5 850 209 +870648 36 Honors 5 573 168 +870674 36 Honors 5 837 226 +870656 36 Honors 5 496 116 +870065 36 Honors 5 908 238 Africa and Arab +870269 36 Honors 5 878 267 +870639 36 Honors 5 582 213 +870627 36 Honors 5 579 180 Asia West +870630 36 Honors 5 747 247 +870668 36 Honors 5 889 257 +870637 36 Honors 5 742 255 +870579 36 Honors 5 822 205 +870685 36 Honors 5 1048 267 +870650 36 Honors 5 398 137 +870689 36 Honors 5 1008 298 +870578 36 Honors 5 807 257 +870052 36 Honors 5 662 181 +870691 36 Honors 5 839 243 +870672 36 Honors 5 489 158 +870653 36 Honors 5 630 292 +870263 36 Honors 5 891 220 +870874 36 Honors 5 660 221 +870686 36 Honors 5 795 219 +870683 36 Honors 5 653 207 +870043 36 Honors 5 522 160 +870053 36 Honors 5 968 260 +870659 36 Honors 5 644 154 +870667 36 Honors 5 770 216 +871379 36 Honors 5 1227 273 +870042 36 Honors 5 971 292 +870050 36 Honors 5 739 260 +870048 36 Honors 5 743 271 +870272 36 Honors 5 747 284 +870270 36 Honors 5 683 239 +870652 36 Honors 5 578 143 +870273 36 Honors 5 592 199 +870590 36 Honors 5 867 245 +870046 36 Honors 5 737 227 +870056 Honorable 2 465 299 +870055 Honorable 4 465 164 +870063 Honorable 1 348 288 +870066 Honorable 2 289 173 +870054 Honorable 4 693 255 +870067 Honorable 2 405 259 +870688 Honorable 4 632 198 +870690 Honorable 3 691 271 +870574 Honorable 4 339 128 +870640 Honorable 3 435 195 +870636 Honorable 3 333 130 +870061 Honorable 1 140 140 +871347 Honorable 3 599 287 +870577 Honorable 4 590 215 +870057 Honorable 2 367 253 +870641 Honorable 3 448 243 +870663 Honorable 0 0 0 +870662 Honorable 2 459 238 +870058 Honorable 2 312 196 +870629 Honorable 3 538 299 +870628 Honorable 4 712 298 +870631 Honorable 4 421 191 +870632 Honorable 4 603 266 +870633 Honorable 3 469 250 +870634 Honorable 1 96 96 +870694 Honorable 4 879 290 +870068 Honorable 1 74 74 +870693 Honorable 3 650 279 +870587 Honorable 4 447 228 +870588 Honorable 4 707 244 +873768 Honorable 4 651 210 +870687 Honorable 4 870 268 +870643 Honorable 4 379 192 +870581 Honorable 2 398 287 +870258 Honorable 4 448 141 +870062 Honorable 1 58 58 +869963 Honorable 4 920 274 +870675 Honorable 1 162 162 +870664 Honorable 2 255 226 +870660 Honorable 3 766 289 +870676 Honorable 2 279 150 +870673 Honorable 1 230 190 +870671 Honorable 3 333 196 +870661 Honorable 3 728 272 +870669 Honorable 4 654 210 +870666 Honorable 3 382 177 +870665 Honorable 3 568 224 +870657 Honorable 4 333 107 +870651 Honorable 4 474 160 +870645 Honorable 3 609 277 +870591 Honorable 1 86 66 +870589 Honorable 3 480 178 +870039 Honorable 3 596 252 +870697 Honorable 3 761 275 diff --git a/webapp/tests/Unit/Service/ImportExportServiceTest.php b/webapp/tests/Unit/Service/ImportExportServiceTest.php index 85985e7441c..042be4a409c 100644 --- a/webapp/tests/Unit/Service/ImportExportServiceTest.php +++ b/webapp/tests/Unit/Service/ImportExportServiceTest.php @@ -18,6 +18,7 @@ use App\Service\ImportExportService; use App\Service\ScoreboardService; use App\Tests\Unit\BaseTestCase; +use App\Utils\Utils; use Collator; use DateInterval; use DateTime; @@ -31,6 +32,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; +use Symfony\Component\Serializer\Encoder\CsvEncoder; +use Symfony\Component\Serializer\SerializerInterface; class ImportExportServiceTest extends BaseTestCase { @@ -1164,7 +1167,7 @@ protected function getContest(int|string $cid): Contest /** * @dataProvider provideGetResultsData */ - public function testGetResultsData(bool $full): void + public function testGetResultsData(bool $full, string $expectedResultsFile): void { // Set up some results we can test with // This data is based on the ICPC World Finals 47 @@ -1292,167 +1295,24 @@ public function testGetResultsData(bool $full): void $requestStack->push($request); $results = $importExportService->getResultsData(37, $full); - $expectedResults = [ - new ResultRow('870679', 1, 'Gold Medal', 9, 995, 216, 'Northern Eurasia'), - new ResultRow('870257', 2, 'Gold Medal', 9, 1068, 227, 'Asia East'), - new ResultRow('870678', 3, 'Gold Medal', 9, 1143, 206), - new ResultRow('873624', 4, 'Gold Medal', 9, 1304, 292, 'Europe'), - new ResultRow('870259', 5, 'Silver Medal', 9, 1524, 274), - new ResultRow('870260', 6, 'Silver Medal', 8, 1013, 281), - new ResultRow('928309', 7, 'Silver Medal', 8, 1102, 230, 'Asia Pacific'), - new ResultRow('870037', 8, 'Silver Medal', 8, 1120, 268, 'North America'), - new ResultRow('870583', 9, 'Bronze Medal', 8, 1121, 260), - new ResultRow('870584', 10, 'Bronze Medal', 8, 1424, 291), - new ResultRow('870051', 11, 'Bronze Medal', 7, 842, 279), - new ResultRow('870647', 12, 'Bronze Medal', 7, 940, 259), - new ResultRow('870670', 13, 'Highest Honors', 7, 955, 291, 'Latin America'), - new ResultRow('870585', $full ? 14 : 13, 'Highest Honors', 7, 962, 290), - new ResultRow('870649', $full ? 14 : 13, 'Highest Honors', 7, 962, 290), - new ResultRow('870271', $full ? 16 : 13, 'Highest Honors', 7, 980, 283), - new ResultRow('870642', $full ? 17 : 13, 'Highest Honors', 7, 1021, 256), - new ResultRow('870045', $full ? 18 : 13, 'Highest Honors', 7, 1076, 271), - new ResultRow('870582', $full ? 19 : 13, 'Highest Honors', 7, 1128, 278), - new ResultRow('870654', $full ? 20 : 13, 'Highest Honors', 7, 1130, 284), - new ResultRow('868994', $full ? 21 : 13, 'Highest Honors', 7, 1381, 296), - new ResultRow('870644', 22, 'High Honors', 6, 510, 187), - new ResultRow('870646', $full ? 23 : 22, 'High Honors', 6, 642, 216), - new ResultRow('870680', $full ? 24 : 22, 'High Honors', 6, 645, 218), - new ResultRow('881825', $full ? 25 : 22, 'High Honors', 6, 680, 237), - new ResultRow('871349', $full ? 26 : 22, 'High Honors', 6, 683, 246), - new ResultRow('870692', $full ? 27 : 22, 'High Honors', 6, 708, 243), - new ResultRow('870041', $full ? 28 : 22, 'High Honors', 6, 718, 260), - new ResultRow('870268', $full ? 29 : 22, 'High Honors', 6, 765, 292), - new ResultRow('870681', $full ? 30 : 22, 'High Honors', 6, 932, 287), - new ResultRow('870040', $full ? 31 : 22, 'High Honors', 6, 968, 238), - new ResultRow('870044', $full ? 32 : 22, 'High Honors', 6, 1010, 275), - new ResultRow('870658', $full ? 33 : 22, 'High Honors', 6, 1046, 293), - new ResultRow('870038', $full ? 34 : 22, 'High Honors', 6, 1103, 282), - new ResultRow('870696', $full ? 35 : 22, 'High Honors', 6, 1189, 290), - new ResultRow('870650', 36, 'Honors', 5, 398, 137), - new ResultRow('870672', $full ? 37 : 36, 'Honors', 5, 489, 158), - new ResultRow('870656', $full ? 38 : 36, 'Honors', 5, 496, 116), - new ResultRow('870043', $full ? 39 : 36, 'Honors', 5, 522, 160), - new ResultRow('870648', $full ? 40 : 36, 'Honors', 5, 573, 168), - new ResultRow('870652', $full ? 41 : 36, 'Honors', 5, 578, 143), - new ResultRow('870627', $full ? 42 : 36, 'Honors', 5, 579, 180, 'Asia West'), - new ResultRow('870639', $full ? 43 : 36, 'Honors', 5, 582, 213), - new ResultRow('870273', $full ? 44 : 36, 'Honors', 5, 592, 199), - new ResultRow('870653', $full ? 45 : 36, 'Honors', 5, 630, 292), - new ResultRow('870659', $full ? 46 : 36, 'Honors', 5, 644, 154), - new ResultRow('870683', $full ? 47 : 36, 'Honors', 5, 653, 207), - new ResultRow('870874', $full ? 48 : 36, 'Honors', 5, 660, 221), - new ResultRow('870052', $full ? 49 : 36, 'Honors', 5, 662, 181), - new ResultRow('870270', $full ? 50 : 36, 'Honors', 5, 683, 239), - new ResultRow('870046', $full ? 51 : 36, 'Honors', 5, 737, 227), - new ResultRow('870050', $full ? 52 : 36, 'Honors', 5, 739, 260), - new ResultRow('870637', $full ? 53 : 36, 'Honors', 5, 742, 255), - new ResultRow('870048', $full ? 54 : 36, 'Honors', 5, 743, 271), - new ResultRow('870630', $full ? 55 : 36, 'Honors', 5, 747, 247), - new ResultRow('870272', $full ? 56 : 36, 'Honors', 5, 747, 284), - new ResultRow('870667', $full ? 57 : 36, 'Honors', 5, 770, 216), - new ResultRow('870686', $full ? 58 : 36, 'Honors', 5, 795, 219), - new ResultRow('870578', $full ? 59 : 36, 'Honors', 5, 807, 257), - new ResultRow('870579', $full ? 60 : 36, 'Honors', 5, 822, 205), - new ResultRow('870267', $full ? 61 : 36, 'Honors', 5, 833, 257), - new ResultRow('870674', $full ? 62 : 36, 'Honors', 5, 837, 226), - new ResultRow('870691', $full ? 63 : 36, 'Honors', 5, 839, 243), - new ResultRow('870264', $full ? 64 : 36, 'Honors', 5, 850, 209), - new ResultRow('870635', $full ? 65 : 36, 'Honors', 5, 862, 275), - new ResultRow('870590', $full ? 66 : 36, 'Honors', 5, 867, 245), - new ResultRow('870269', $full ? 67 : 36, 'Honors', 5, 878, 267), - new ResultRow('870668', $full ? 68 : 36, 'Honors', 5, 889, 257), - new ResultRow('870263', $full ? 69 : 36, 'Honors', 5, 891, 220), - new ResultRow('870065', $full ? 70 : 36, 'Honors', 5, 908, 238, 'Africa and Arab'), - new ResultRow('870053', $full ? 71 : 36, 'Honors', 5, 968, 260), - new ResultRow('870042', $full ? 72 : 36, 'Honors', 5, 971, 292), - new ResultRow('870689', $full ? 73 : 36, 'Honors', 5, 1008, 298), - new ResultRow('870685', $full ? 74 : 36, 'Honors', 5, 1048, 267), - new ResultRow('870638', $full ? 75 : 36, 'Honors', 5, 1164, 294), - new ResultRow('871379', $full ? 76 : 36, 'Honors', 5, 1227, 273), - new ResultRow('870056', null, 'Honorable', 2, 465, 299), - new ResultRow('870055', null, 'Honorable', 4, 465, 164), - new ResultRow('870063', null, 'Honorable', 1, 348, 288), - new ResultRow('870066', null, 'Honorable', 2, 289, 173), - new ResultRow('870054', null, 'Honorable', 4, 693, 255), - new ResultRow('870067', null, 'Honorable', 2, 405, 259), - new ResultRow('870688', null, 'Honorable', 4, 632, 198), - new ResultRow('870690', null, 'Honorable', 3, 691, 271), - new ResultRow('870574', null, 'Honorable', 4, 339, 128), - new ResultRow('870640', null, 'Honorable', 3, 435, 195), - new ResultRow('870636', null, 'Honorable', 3, 333, 130), - new ResultRow('870061', null, 'Honorable', 1, 140, 140), - new ResultRow('871347', null, 'Honorable', 3, 599, 287), - new ResultRow('870577', null, 'Honorable', 4, 590, 215), - new ResultRow('870057', null, 'Honorable', 2, 367, 253), - new ResultRow('870641', null, 'Honorable', 3, 448, 243), - new ResultRow('870663', null, 'Honorable', 0, 0, 0), - new ResultRow('870662', null, 'Honorable', 2, 459, 238), - new ResultRow('870058', null, 'Honorable', 2, 312, 196), - new ResultRow('870629', null, 'Honorable', 3, 538, 299), - new ResultRow('870628', null, 'Honorable', 4, 712, 298), - new ResultRow('870631', null, 'Honorable', 4, 421, 191), - new ResultRow('870632', null, 'Honorable', 4, 603, 266), - new ResultRow('870633', null, 'Honorable', 3, 469, 250), - new ResultRow('870634', null, 'Honorable', 1, 96, 96), - new ResultRow('870694', null, 'Honorable', 4, 879, 290), - new ResultRow('870068', null, 'Honorable', 1, 74, 74), - new ResultRow('870693', null, 'Honorable', 3, 650, 279), - new ResultRow('870587', null, 'Honorable', 4, 447, 228), - new ResultRow('870588', null, 'Honorable', 4, 707, 244), - new ResultRow('873768', null, 'Honorable', 4, 651, 210), - new ResultRow('870687', null, 'Honorable', 4, 870, 268), - new ResultRow('870643', null, 'Honorable', 4, 379, 192), - new ResultRow('870581', null, 'Honorable', 2, 398, 287), - new ResultRow('870258', null, 'Honorable', 4, 448, 141), - new ResultRow('870062', null, 'Honorable', 1, 58, 58), - new ResultRow('869963', null, 'Honorable', 4, 920, 274), - new ResultRow('870675', null, 'Honorable', 1, 162, 162), - new ResultRow('870664', null, 'Honorable', 2, 255, 226), - new ResultRow('870660', null, 'Honorable', 3, 766, 289), - new ResultRow('870676', null, 'Honorable', 2, 279, 150), - new ResultRow('870673', null, 'Honorable', 1, 230, 190), - new ResultRow('870671', null, 'Honorable', 3, 333, 196), - new ResultRow('870661', null, 'Honorable', 3, 728, 272), - new ResultRow('870669', null, 'Honorable', 4, 654, 210), - new ResultRow('870666', null, 'Honorable', 3, 382, 177), - new ResultRow('870665', null, 'Honorable', 3, 568, 224), - new ResultRow('870657', null, 'Honorable', 4, 333, 107), - new ResultRow('870651', null, 'Honorable', 4, 474, 160), - new ResultRow('870645', null, 'Honorable', 3, 609, 277), - new ResultRow('870591', null, 'Honorable', 1, 86, 66), - new ResultRow('870589', null, 'Honorable', 3, 480, 178), - new ResultRow('870039', null, 'Honorable', 3, 596, 252), - new ResultRow('870697', null, 'Honorable', 3, 761, 275), - ]; - if (!$full) { - // Sort by rank/name. - uasort($expectedResults, function (ResultRow $a, ResultRow $b) use ($teamsByIcpcId) { - if ($a->rank !== $b->rank) { - // Honorable mention has no rank. - if ($a->rank === null) { - return 1; - } elseif ($b->rank === null) { - return -1; - } - return $a->rank <=> $b->rank; - } - $teamA = $teamsByIcpcId[$a->teamId] ?? null; - $teamB = $teamsByIcpcId[$b->teamId] ?? null; - $nameA = $teamA?->getEffectiveName(); - $nameB = $teamB?->getEffectiveName(); - $collator = new Collator('en'); - return $collator->compare($nameA, $nameB); - }); - $expectedResults = array_values($expectedResults); - } + $resultsContents = file_get_contents(__DIR__ . '/../Fixtures/' . $expectedResultsFile); + $resultsContents = substr($resultsContents, strpos($resultsContents, "\n") + 1); + // Prefix file with a fake header, so we can deserialize them + $resultsContents = "team_id\trank\taward\tnum_solved\ttotal_time\ttime_of_last_submission\tgroup_winner\n" . $resultsContents; + + $serializer = static::getContainer()->get(SerializerInterface::class); + + $expectedResults = $serializer->deserialize($resultsContents, ResultRow::class . '[]', 'csv', [ + CsvEncoder::DELIMITER_KEY => "\t", + ]); self::assertEquals($expectedResults, $results); } public function provideGetResultsData(): Generator { - yield [true]; - yield [false]; + yield [true, 'results-full.tsv']; + yield [false, 'results-wf.tsv']; } }