-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCase.php
More file actions
104 lines (88 loc) · 3.95 KB
/
TestCase.php
File metadata and controls
104 lines (88 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
namespace Aternos\SpigotApi\Tests;
use Aternos\SpigotApi\Client\List\PaginatedList;
use Aternos\SpigotApi\Client\Project;
use Aternos\SpigotApi\Client\SpigotAPIClient;
use Aternos\SpigotApi\Client\Version;
use Aternos\SpigotApi\Model\Author;
use Aternos\SpigotApi\Model\ResourceAuthor;
use Aternos\SpigotApi\Model\ResourceCategory;
use Aternos\SpigotApi\Model\ResourceStats;
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
class TestCase extends PHPUnitTestCase
{
protected ?SpigotAPIClient $apiClient = null;
/**
* Setup before running each test case
*/
public function setUp(): void
{
$this->apiClient = new SpigotAPIClient();
$this->apiClient->setUserAgent("aternos/php-spigot-api@1.0.0 (contact@aternos.org)");
}
protected function assertValidStats(ResourceStats $stats): void
{
$this->assertNotNull($stats->getDownloads());
$this->assertNotNull($stats->getUpdates());
$this->assertNotNull($stats->getReviews());
$this->assertNotNull($stats->getRating());
}
protected function assertValidAuthor(Author $author): void
{
$this->assertNotNull($author->getId());
$this->assertNotNull($author->getUsername());
$this->assertNotNull($author->getResourceCount());
$this->assertNotNull($author->getIdentities());
$this->assertNotNull($author->getAvatar());
$this->assertNotNull($author->getLastActivity());
}
protected function assertValidResourceAuthor(ResourceAuthor $author): void
{
$this->assertNotNull($author->getId());
$this->assertNotNull($author->getUsername());
}
protected function assertValidCategory(ResourceCategory $category): void
{
$this->assertNotNull($category->getId());
$this->assertNotNull($category->getTitle());
$this->assertNotNull($category->getDescription());
}
protected function assertValidProject(Project $project): void
{
$this->assertNotNull($project->getData());
$this->assertNotNull($project->getData()->getStats());
$this->assertValidStats($project->getData()->getStats());
$this->assertNotNull($project->getData()->getAuthor());
$this->assertValidResourceAuthor($project->getData()->getAuthor());
$this->assertNotNull($project->getData()->getId());
$this->assertNotNull($project->getData()->getTitle());
$this->assertNotNull($project->getData()->getTag());
$this->assertNotNull($project->getData()->getCurrentVersion());
// $project->getData()->getNativeMinecraftVersion() can be null
// $this->assertNotNull($project->getData()->getSupportedMinecraftVersions()) can be null or empty
$this->assertNotNull($project->getData()->getIconLink());
$this->assertNotNull($project->getData()->getExternalDownloadUrl());
$this->assertNotNull($project->getData()->getDescription());
$this->assertNotNull($project->getData()->getFirstRelease());
$this->assertNotNull($project->getData()->getLastUpdate());
$this->assertNotNull($project->getData()->getSourceCodeUrl());
$this->assertNotNull($project->getData()->getDonateUrl());
}
protected function assertValidVersion(Version $version): void
{
$this->assertNotNull($version->getId());
$this->assertNotNull($version->getProjectId());
$this->assertNotNull($version->getData()->getId());
$this->assertNotNull($version->getData()->getResourceId());
$this->assertNotNull($version->getData()->getDownloadCount());
$this->assertNotNull($version->getData()->getTitle());
$this->assertNotNull($version->getData()->getMessage());
$this->assertNotNull($version->getData()->getPostDate());
}
protected function assertValidPaginatedList(PaginatedList $list): void
{
$this->assertNotEmpty($list);
$this->assertNotNull($list->getResults());
$this->assertNotEmpty($list->getResults());
}
}