@@ -13,13 +13,15 @@ class EventsFilterTest extends AbstractApiTestCase
1313 protected static string $ requestPath = '/api/v2/events ' ;
1414
1515 #[DataProvider('getEventsProvider ' )]
16- public function testGetEvents (array $ query , int $ expectedCount ): void
16+ public function testGetEvents (array $ query , int $ expectedCount, ? string $ message = null ): void
1717 {
18+ $ message ??= '' ;
19+
1820 $ response = $ this ->get ($ query );
1921
2022 $ data = $ response ->toArray ();
21- $ this ->assertArrayHasKey ('hydra:member ' , $ data );
22- $ this ->assertCount ($ expectedCount , $ data ['hydra:member ' ]);
23+ $ this ->assertArrayHasKey ('hydra:member ' , $ data, $ message );
24+ $ this ->assertCount ($ expectedCount , $ data ['hydra:member ' ], $ message );
2325 }
2426
2527 public static function getEventsProvider (): iterable
@@ -29,6 +31,7 @@ public static function getEventsProvider(): iterable
2931 3 ,
3032 ];
3133
34+ // Test BooleanFilter.
3235 yield [
3336 ['publicAccess ' => 'true ' ],
3437 2 ,
@@ -38,5 +41,89 @@ public static function getEventsProvider(): iterable
3841 ['publicAccess ' => 'false ' ],
3942 1 ,
4043 ];
44+
45+ // Test DateRangeFilter.
46+ yield [
47+ ['occurrences.start[between] ' => implode ('.. ' , [
48+ (new \DateTimeImmutable ('2001-01-01 ' ))->format (\DateTimeImmutable::ATOM ),
49+ (new \DateTimeImmutable ('2100-01-01 ' ))->format (\DateTimeImmutable::ATOM ),
50+ ])],
51+ 3 ,
52+ 'Events in 21st century ' ,
53+ ];
54+
55+ yield [
56+ ['occurrences.start[between] ' => implode ('.. ' , [
57+ (new \DateTimeImmutable ('2001-01-01 ' ))->format (\DateTimeImmutable::ATOM ),
58+ (new \DateTimeImmutable ('2100-01-01 ' ))->format (\DateTimeImmutable::ATOM ),
59+ ])],
60+ 3 ,
61+ 'Events in 21st century ' ,
62+ ];
63+
64+ yield [
65+ ['occurrences.start[between] ' => static ::formatDateTime ('2026-01-01 ' ).'.. ' .static ::formatDateTime ('2026-12-31 ' )],
66+ 1 ,
67+ 'Events in 2026 ' ,
68+ ];
69+
70+ // Test IdFilter.
71+ yield [
72+ ['organizer.entityId ' => 9 ],
73+ 2 ,
74+ ];
75+
76+ yield [
77+ ['organizer.entityId ' => 11 ],
78+ 1 ,
79+ ];
80+
81+ // Test MatchFilter.
82+ yield [
83+ ['location.name ' => 'somewhere ' ],
84+ 1 ,
85+ 'An event somewhere ' ,
86+ ];
87+
88+ yield [
89+ ['location.name ' => 'Another place ' ],
90+ 0 ,
91+ ];
92+
93+ // Test TagFilter.
94+ yield [
95+ ['tags ' => 'itkdev ' ],
96+ 2 ,
97+ 'Events tagged with "itkdev" ' ,
98+ ];
99+
100+ yield [
101+ ['tags ' => 'itkdevelopment ' ],
102+ 0 ,
103+ 'Events tagged with "itkdevelopment" ' ,
104+ ];
105+
106+ // @todo Does tags filtering use the tag slug or name?
107+ // yield [
108+ // ['tags' => 'for børn'],
109+ // 0,
110+ // 'Events tagged with "for børn"',
111+ // ];
112+ //
113+ // yield [
114+ // ['tags' => 'for-boern'],
115+ // 1,
116+ // 'Events tagged with "for-boern"',
117+ // ];
118+
119+ // Combined filters.
120+ yield [
121+ [
122+ 'occurrences.start[between] ' => static ::formatDateTime ('2026-01-01 ' ).'.. ' .static ::formatDateTime ('2026-12-31 ' ),
123+ 'tags ' => 'itkdev ' ,
124+ ],
125+ 1 ,
126+ 'Events in 2026 tagged with "itkdev" ' ,
127+ ];
41128 }
42129}
0 commit comments