1212use Aternos \ModrinthApi \Client \Options \Facets \FacetType ;
1313use Aternos \ModrinthApi \Client \Options \ProjectSearchOptions ;
1414use Aternos \ModrinthApi \Client \SearchProject ;
15+ use Aternos \ModrinthApi \Client \Tags \GameVersion ;
1516use PHPUnit \Framework \TestCase ;
1617
1718class ClientTest extends TestCase
@@ -116,7 +117,8 @@ public function testSearchProjectsByType(): void
116117 $ this ->assertFalse ($ projectList ->hasPreviousPage ());
117118 }
118119
119- public function testSearchProjectsByDownloadCount () {
120+ public function testSearchProjectsByDownloadCount ()
121+ {
120122 $ options = new ProjectSearchOptions ();
121123 $ options ->setFacets (new FacetANDGroup ([
122124 new FacetORGroup ([
@@ -381,14 +383,18 @@ public function testGetLoaders()
381383
382384 public function testGetGameVersions ()
383385 {
384- $ items = $ this ->apiClient ->getGameVersions ();
385- $ this ->assertNotEmpty ($ items );
386+ $ gameVersions = $ this ->apiClient ->getGameVersions ();
387+ $ this ->assertNotEmpty ($ gameVersions );
386388
387- foreach ($ items as $ item ) {
388- $ this ->assertNotNull ($ item );
389+ foreach ($ gameVersions as $ gameVersion ) {
390+ $ this ->assertNotNull ($ gameVersion );
389391 }
390392
391- $ projects = $ items [0 ]->searchProjects ();
393+ $ latestRelease = array_find ($ gameVersions , function (GameVersion $ gameVersion ) {
394+ return $ gameVersion ->getData ()->getVersionType () === "release " ;
395+ });
396+
397+ $ projects = $ latestRelease ->searchProjects ();
392398 $ this ->assertNotEmpty ($ projects );
393399 foreach ($ projects as $ project ) {
394400 $ this ->assertNotNull ($ project );
@@ -430,4 +436,4 @@ public function testGetReportTypes()
430436 $ this ->assertNotNull ($ item );
431437 }
432438 }
433- }
439+ }
0 commit comments