Skip to content

Commit e3a92ec

Browse files
authored
Merge pull request #17 from aternosorg/fix-test-game-versions-test
Fix testGetGameVersions by searching for the latest release
2 parents 8717d11 + 6ad3912 commit e3a92ec

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

tests/Integration/Client/ClientTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Aternos\ModrinthApi\Client\Options\Facets\FacetType;
1313
use Aternos\ModrinthApi\Client\Options\ProjectSearchOptions;
1414
use Aternos\ModrinthApi\Client\SearchProject;
15+
use Aternos\ModrinthApi\Client\Tags\GameVersion;
1516
use PHPUnit\Framework\TestCase;
1617

1718
class 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

Comments
 (0)