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
12 changes: 11 additions & 1 deletion src/Client/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ public function getId(): int
return intval($this->data->getId());
}

/**
* Get the category of the project.
*
* @return Category
*/
public function getCategory(): Category
{
return Category::from($this->getData()->getCategory()->getId());
}

/**
* Get the author of the project.
*
Expand All @@ -50,4 +60,4 @@ public function getVersions(): PaginatedVersionList
{
return $this->client->getProjectVersions($this->getId());
}
}
}
14 changes: 13 additions & 1 deletion tests/Integration/Client/ProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Aternos\SpigotApi\Tests\Integration\Client;

use Aternos\SpigotApi\ApiException;
use Aternos\SpigotApi\Client\Category;
use Aternos\SpigotApi\Client\Project;
use Aternos\SpigotApi\Tests\TestCase;

Expand All @@ -20,6 +21,17 @@ public function setUp(): void
$this->project = $this->apiClient->getProject(57242);
}

public function testGetCategory(): void
{
$resourceCategory = $this->project->getData()->getCategory();
$this->assertEquals(15, $resourceCategory->getId());
$this->assertEquals("Tools and Utilities", $resourceCategory->getTitle());
$this->assertEquals("", $resourceCategory->getDescription());

$category = $this->project->getCategory();
$this->assertEquals(Category::SPIGOT_TOOLS_AND_UTILITIES, $category);
}

/**
* @throws ApiException
*/
Expand Down Expand Up @@ -53,4 +65,4 @@ public function testGetVersions(): void
}
}

}
}