Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions tests/Unit/Client/Fixtures/get_forge_updates_response.json

This file was deleted.

6 changes: 0 additions & 6 deletions tests/Unit/Client/Fixtures/get_statistics_response.json

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Unit/Client/List/PaginatedProjectSearchListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PaginatedProjectSearchListTest extends ClientTestCase
*/
protected function searchPage(int $offset, int $limit = self::LIMIT, int $totalHits = self::TOTAL_HITS): Response
{
$template = $this->fixtureData("search_projects_response")["hits"][0];
$template = $this->fixtureData("searchProjects")["hits"][0];

$hits = [];
for ($i = $offset; $i < min($offset + $limit, $totalHits); $i++) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Client/Models/NotificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public function testFetchUserReturnsCorrectUser(): void
{
// Here we must mock the client, because it requests the user from the API to get all details
$handler = new MockHandler([
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/get_user_response.json")),
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/get_user_response.json"))
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/getUser.json")),
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/getUser.json"))
]);
$client = new ModrinthAPIClient(null, null, new Client(['handler' => HandlerStack::create($handler)]));

Expand All @@ -29,7 +29,7 @@ public function testFetchUserReturnsCorrectUser(): void

protected function getExampleNotificationModel(): \Aternos\ModrinthApi\Model\Notification
{
$json = json_decode(file_get_contents(__DIR__ . "/../Fixtures/get_notification_response.json"), true);
$json = json_decode(file_get_contents(__DIR__ . "/../Fixtures/getNotification.json"), true);
return new \Aternos\ModrinthApi\Model\Notification($json);
}
}
4 changes: 2 additions & 2 deletions tests/Unit/Client/Models/ProjectDependenciesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ProjectDependenciesTest extends TestCase
public function testGetUserReturnsCorrectUser(): void
{
$handler = new MockHandler([
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/get_project_dependencies_response.json"))
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/getDependencies.json"))
]);
$client = new ModrinthAPIClient(null, null, new Client(['handler' => HandlerStack::create($handler)]));

Expand Down Expand Up @@ -56,7 +56,7 @@ public function testGetDataReturnsCorrectProjectModel(): void

protected function getExampleProjectDependencyListModel(): \Aternos\ModrinthApi\Model\ProjectDependencyList
{
$json = json_decode(file_get_contents(__DIR__ . "/../Fixtures/get_project_dependencies_response.json"), true);
$json = json_decode(file_get_contents(__DIR__ . "/../Fixtures/getDependencies.json"), true);
$projects = array_map(fn($element) => new \Aternos\ModrinthApi\Model\Project($element), $json["projects"]);
$versions = array_map(fn($element) => new \Aternos\ModrinthApi\Model\Version($element), $json["versions"]);
return (new \Aternos\ModrinthApi\Model\ProjectDependencyList())
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Client/Models/ProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ProjectTest extends ClientTestCase
{
protected function getExampleProjectModel(): ProjectModel
{
return $this->fixtureModel("get_project_response", ProjectModel::class);
return $this->fixtureModel("getProject", ProjectModel::class);
}

public function testConstructorCopiesTheModelData(): void
Expand All @@ -33,7 +33,7 @@ public function testConstructorCopiesTheModelData(): void

public function testFetchDependencies(): void
{
$client = $this->createClient([$this->fixtureResponse("get_project_dependencies_response")]);
$client = $this->createClient([$this->fixtureResponse("getDependencies")]);
$project = new Project($client, $this->getExampleProjectModel());

$dependencies = $project->fetchDependencies();
Expand All @@ -46,7 +46,7 @@ public function testFetchDependencies(): void
public function testFetchProjectVersions(): void
{
$client = $this->createClient([
$this->jsonResponse([$this->fixtureData("get_version_response")]),
$this->jsonResponse([$this->fixtureData("getVersion")]),
]);
$project = new Project($client, $this->getExampleProjectModel());

Expand All @@ -61,7 +61,7 @@ public function testFetchProjectVersions(): void
public function testFetchProjectVersionsPassesFilters(): void
{
$client = $this->createClient([
$this->jsonResponse([$this->fixtureData("get_version_response")]),
$this->jsonResponse([$this->fixtureData("getVersion")]),
]);
$project = new Project($client, $this->getExampleProjectModel());

Expand All @@ -76,7 +76,7 @@ public function testFetchProjectVersionsPassesFilters(): void

public function testFetchThread(): void
{
$client = $this->createAuthenticatedClient([$this->fixtureResponse("get_thread_response")]);
$client = $this->createAuthenticatedClient([$this->fixtureResponse("getThread")]);
$project = new Project($client, $this->getExampleProjectModel());

$thread = $project->fetchThread();
Expand All @@ -88,7 +88,7 @@ public function testFetchThread(): void

public function testFetchMembers(): void
{
$client = $this->createClient([$this->fixtureResponse("get_team_members_response")]);
$client = $this->createClient([$this->fixtureResponse("getTeamMembers")]);
$project = new Project($client, $this->getExampleProjectModel());

$members = $project->fetchMembers();
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Client/Models/SearchProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testFetchFullProjectReturnsInstanceOfProject(): void
$projectResultModel = $this->getExampleProjectResultModel();
// Here we must mock the client, because it requests the user from the API to get all details
$handler = new MockHandler([
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/get_project_response.json"))
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/getProject.json"))
]);
$client = new ModrinthAPIClient(null, null, new Client(['handler' => HandlerStack::create($handler)]));

Expand All @@ -32,7 +32,7 @@ public function testFetchFullProjectReturnsInstanceOfProject(): void
public function testFetchFullProjectRequestsTheProjectId(): void
{
$handler = new MockHandler([
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/get_project_response.json"))
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/getProject.json"))
]);
$requests = [];
$stack = HandlerStack::create($handler);
Expand All @@ -49,7 +49,7 @@ public function testFetchFullProjectRequestsTheProjectId(): void
public function testFetchDependenciesUsesTheProjectId(): void
{
$handler = new MockHandler([
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/get_project_dependencies_response.json"))
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/getDependencies.json"))
]);
$requests = [];
$stack = HandlerStack::create($handler);
Expand All @@ -65,7 +65,7 @@ public function testFetchDependenciesUsesTheProjectId(): void
public function testFetchAuthor(): void
{
$handler = new MockHandler([
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/get_user_response.json"))
new Response(200, [], file_get_contents(__DIR__ . "/../Fixtures/getUser.json"))
]);
$requests = [];
$stack = HandlerStack::create($handler);
Expand Down Expand Up @@ -105,7 +105,7 @@ public function testGetAuthorStillReturnsTheUsername(): void

protected function getExampleProjectResultModel(): ProjectResult
{
$json = json_decode(file_get_contents(__DIR__ . "/../Fixtures/search_projects_response.json"), true);
$json = json_decode(file_get_contents(__DIR__ . "/../Fixtures/searchProjects.json"), true);
$modelJson = $json["hits"][0];
return new ProjectResult($modelJson);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Client/Models/TeamMemberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TeamMemberTest extends ClientTestCase
{
protected function getExampleTeamMemberModel(): TeamMemberModel
{
return $this->fixtureModel("get_team_members_response", TeamMemberModel::class . "[]")[0];
return $this->fixtureModel("getTeamMembers", TeamMemberModel::class . "[]")[0];
}

public function testConstructorCopiesTheModelData(): void
Expand All @@ -38,7 +38,7 @@ public function testGetUserReturnsAClientUserWithoutRequest(): void

public function testFetchTeamMembers(): void
{
$client = $this->createClient([$this->fixtureResponse("get_team_members_response")]);
$client = $this->createClient([$this->fixtureResponse("getTeamMembers")]);
$member = new TeamMember($client, $this->getExampleTeamMemberModel());

$members = $member->fetchTeamMembers();
Expand All @@ -51,7 +51,7 @@ public function testFetchTeamMembers(): void
public function testGetUserCanFetchTheUsersProjects(): void
{
$client = $this->createClient([
$this->jsonResponse([$this->fixtureData("get_project_response")]),
$this->jsonResponse([$this->fixtureData("getProject")]),
]);
$member = new TeamMember($client, $this->getExampleTeamMemberModel());

Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Client/Models/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UserTest extends ClientTestCase
{
protected function getExampleUserModel(): UserModel
{
return $this->fixtureModel("get_user_response", UserModel::class);
return $this->fixtureModel("getUser", UserModel::class);
}

public function testConstructorCopiesTheModelData(): void
Expand All @@ -28,7 +28,7 @@ public function testConstructorCopiesTheModelData(): void
public function testFetchProjects(): void
{
$client = $this->createClient([
$this->jsonResponse([$this->fixtureData("get_project_response")]),
$this->jsonResponse([$this->fixtureData("getProject")]),
]);
$user = new User($client, $this->getExampleUserModel());

Expand All @@ -41,7 +41,7 @@ public function testFetchProjects(): void
public function testFetchNotifications(): void
{
$client = $this->createAuthenticatedClient([
$this->jsonResponse([$this->fixtureData("get_notification_response")]),
$this->jsonResponse([$this->fixtureData("getNotification")]),
]);
$user = new User($client, $this->getExampleUserModel());

Expand All @@ -55,7 +55,7 @@ public function testFetchNotifications(): void
public function testFetchFollowedProjects(): void
{
$client = $this->createAuthenticatedClient([
$this->jsonResponse([$this->fixtureData("get_project_response")]),
$this->jsonResponse([$this->fixtureData("getProject")]),
]);
$user = new User($client, $this->getExampleUserModel());

Expand All @@ -68,7 +68,7 @@ public function testFetchFollowedProjects(): void

public function testFetchPayoutHistory(): void
{
$client = $this->createAuthenticatedClient([$this->fixtureResponse("get_payout_history_response")]);
$client = $this->createAuthenticatedClient([$this->fixtureResponse("getPayoutHistory")]);
$user = new User($client, $this->getExampleUserModel());

$history = $user->fetchPayoutHistory();
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Client/Models/VersionDependencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class VersionDependencyTest extends ClientTestCase
*/
protected function getExampleDependencyModel(int $index = 0): VersionDependencyModel
{
return $this->fixtureModel("get_version_response", VersionModel::class)->getDependencies()[$index];
return $this->fixtureModel("getVersion", VersionModel::class)->getDependencies()[$index];
}

public function testFetchProject(): void
{
$client = $this->createClient([$this->fixtureResponse("get_project_response")]);
$client = $this->createClient([$this->fixtureResponse("getProject")]);
$dependency = new VersionDependency($client, $this->getExampleDependencyModel());

$project = $dependency->fetchProject();
Expand All @@ -41,7 +41,7 @@ public function testFetchProjectReturnsNullWithoutProjectId(): void

public function testFetchVersion(): void
{
$client = $this->createClient([$this->fixtureResponse("get_version_response")]);
$client = $this->createClient([$this->fixtureResponse("getVersion")]);
$dependency = new VersionDependency($client, $this->getExampleDependencyModel());

$version = $dependency->fetchVersion();
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Client/Models/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class VersionTest extends ClientTestCase
{
protected function getExampleVersionModel(string $fixture = "get_version_response"): VersionModel
protected function getExampleVersionModel(string $fixture = "getVersion"): VersionModel
{
return $this->fixtureModel($fixture, VersionModel::class);
}
Expand All @@ -27,7 +27,7 @@ public function testConstructorCopiesTheModelData(): void

public function testFetchProject(): void
{
$client = $this->createClient([$this->fixtureResponse("get_project_response")]);
$client = $this->createClient([$this->fixtureResponse("getProject")]);
$version = new Version($client, $this->getExampleVersionModel());

$project = $version->fetchProject();
Expand All @@ -38,7 +38,7 @@ public function testFetchProject(): void

public function testFetchAuthor(): void
{
$client = $this->createClient([$this->fixtureResponse("get_user_response")]);
$client = $this->createClient([$this->fixtureResponse("getUser")]);
$version = new Version($client, $this->getExampleVersionModel());

$author = $version->fetchAuthor();
Expand Down Expand Up @@ -67,7 +67,7 @@ public function testGetDependenciesReturnsEmptyArrayWhenNull(): void
{
$version = new Version(
$this->createClient(),
$this->getExampleVersionModel("get_version_without_dependencies_response")
$this->getExampleVersionModel("getVersionWithoutDependencies")
);

$this->assertSame([], $version->getDependencies());
Expand Down
Loading
Loading