@@ -39,18 +39,23 @@ public function testCorsReports(): void
3939 $ this ->assertEquals ($ response ->headers ->get ('access-control-allow-origin ' ), '* ' );
4040 }
4141
42- public function testReports (): void
42+ /**
43+ * @dataProvider dataProviderReportFilters
44+ *
45+ * @param array<string, string> $query
46+ */
47+ public function testReportsFilters (array $ query , int $ count ): void
4348 {
4449 $ client = static ::createClient ();
45- $ client ->request ('GET ' , '/reports ' );
50+ $ client ->request ('GET ' , '/reports ' . ( $ query ? ' ? ' . http_build_query ( $ query ) : '' ) );
4651 $ response = $ client ->getResponse ();
4752
4853 $ this ->assertTrue ($ response ->isSuccessful ());
4954 $ this ->assertTrue ($ response ->headers ->has ('content-type ' ));
5055 $ this ->assertEquals ('application/json ' , $ response ->headers ->get ('content-type ' ));
5156
5257 $ content = json_decode ($ response ->getContent (), true );
53- $ this ->assertGreaterThan ( 0 , count ($ content ));
58+ $ this ->assertEquals ( $ count , count ($ content ));
5459 $ datePrevious = null ;
5560 foreach ($ content as $ item ) {
5661 if ($ datePrevious ) {
@@ -61,16 +66,28 @@ public function testReports(): void
6166 $ this ->assertIsInt ($ item ['id ' ]);
6267 $ this ->assertArrayHasKey ('date ' , $ item );
6368 $ this ->assertArrayHasKey ('version ' , $ item );
69+ if (isset ($ query ['filter_version ' ])) {
70+ $ this ->assertEquals ($ item ['version ' ], $ query ['filter_version ' ]);
71+ }
6472 $ this ->assertArrayHasKey ('campaign ' , $ item );
6573 $ this ->assertContains ($ item ['campaign ' ], array_merge (
6674 ReportMochaImporter::FILTER_CAMPAIGNS ,
6775 ReportPlaywrightImporter::FILTER_CAMPAIGNS
6876 ));
77+ if (isset ($ query ['filter_campaign[0] ' ])) {
78+ $ this ->assertEquals ($ item ['campaign ' ], $ query ['filter_campaign[0] ' ]);
79+ }
6980 $ this ->assertArrayHasKey ('browser ' , $ item );
7081 $ this ->assertContains ($ item ['browser ' ], ReportMochaImporter::FILTER_PLATFORMS );
7182 $ this ->assertArrayHasKey ('platform ' , $ item );
7283 $ this ->assertContains ($ item ['platform ' ], ReportMochaImporter::FILTER_PLATFORMS );
7384 $ this ->assertEquals ($ item ['browser ' ], $ item ['platform ' ]);
85+ if (isset ($ query ['filter_platform ' ])) {
86+ $ this ->assertEquals ($ item ['platform ' ], $ query ['filter_platform ' ]);
87+ }
88+ if (isset ($ query ['filter_browser ' ])) {
89+ $ this ->assertEquals ($ item ['platform ' ], $ query ['filter_browser ' ]);
90+ }
7491 $ this ->assertArrayHasKey ('start_date ' , $ item );
7592 $ this ->assertArrayHasKey ('end_date ' , $ item );
7693 $ this ->assertArrayHasKey ('duration ' , $ item );
@@ -91,6 +108,20 @@ public function testReports(): void
91108 }
92109 }
93110
111+ /**
112+ * @return array<array<array<string, string>|int>>
113+ */
114+ public static function dataProviderReportFilters (): array
115+ {
116+ return [
117+ [[], 6 ],
118+ [['filter_campaign[0] ' => 'functional ' ], 2 ],
119+ [['filter_platform ' => 'chromium ' ], 3 ],
120+ [['filter_browser ' => 'chromium ' ], 3 ],
121+ [['filter_version ' => 'develop ' ], 6 ],
122+ ];
123+ }
124+
94125 public function testReportNotFound (): void
95126 {
96127 $ client = static ::createClient ();
@@ -368,7 +399,7 @@ private function partialCompareTest(array $expected, array $actual): void
368399 /**
369400 * @param array<string, string> $item
370401 */
371- private function partialTestSuite (int $ executionId , int $ id , array $ item , int $ idParent = null , bool $ hasChildrenData = null ): void
402+ private function partialTestSuite (int $ executionId , int $ id , array $ item , ? int $ idParent = null , ? bool $ hasChildrenData = null ): void
372403 {
373404 $ this ->assertIsInt ($ id );
374405
0 commit comments