-
Notifications
You must be signed in to change notification settings - Fork 15
Pretty substantial re-write / re-structure #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b83603d
2ff6d7d
e084a49
5e77325
5e5753d
866c135
f051502
928b862
5fc3668
7f53799
eeec4cd
f9d4199
ec26cc5
10fdccd
0e10d77
e891fb9
9e14c06
f9c6183
d60deba
d13fc7a
48e88e1
195f0d5
baeb46d
059bb93
f33eb63
48596e0
ba042f5
0d4e08a
805f7b9
864f382
b97a76e
238f852
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| ### Composer ### | ||
| # Composer | ||
| composer.phar | ||
| /vendor/ | ||
|
|
||
| # PHPStorm | ||
| /.idea/ | ||
|
|
||
| # Unit Tests | ||
| /Tests/cache/ | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,6 @@ cache: | |
| - $HOME/.composer/cache | ||
|
|
||
| php: | ||
| - 5.6 | ||
| - 7.0 | ||
| - 7.1 | ||
| - hhvm | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,97 +3,128 @@ | |
| namespace TruckersMP\Tests\API; | ||
|
|
||
| use Carbon\Carbon; | ||
| use TruckersMP\API\APIClient; | ||
| use TruckersMP\Types\Ban; | ||
| use TruckersMP\Types\Bans; | ||
| use TruckersMP\Types\Player; | ||
|
|
||
| class ClientTest extends \PHPUnit_Framework_TestCase | ||
| use PHPUnit\Framework\TestCase; | ||
| use TruckersMP\Client; | ||
| use TruckersMP\Models\BanModel; | ||
| use TruckersMP\Models\BansModel; | ||
| use TruckersMP\Models\GameTimeModel; | ||
| use TruckersMP\Models\PlayerModel; | ||
| use TruckersMP\Models\RulesModel; | ||
|
|
||
| class ClientTest extends TestCase | ||
| { | ||
| private $testAccount = 585204; | ||
| const TEST_ACCOUNT = 585204; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add a proper test account for production (maybe even several accounts for checking private states) |
||
|
|
||
| private $client; | ||
| /** | ||
| * @var Client | ||
| */ | ||
| protected $client; | ||
|
|
||
| /** | ||
| * ClientTest constructor. | ||
| * | ||
| */ | ||
| public function __construct() | ||
| { | ||
| parent::__construct(); | ||
|
|
||
| $this->client = new APIClient(); | ||
| $this->client = new Client(); | ||
| } | ||
|
|
||
| /** | ||
| * @throws \Exception | ||
| * @throws \Http\Client\Exception | ||
| */ | ||
| public function testPlayer() | ||
| public function testPlayer(): void | ||
| { | ||
| $player = $this->client->player($this->testAccount); | ||
| $player = $this->client->player(self::TEST_ACCOUNT); | ||
|
|
||
| $this->assertEquals($player->name, 'tuxytestaccount'); | ||
| $this->assertEquals($player->groupID, 1); | ||
| $this->assertEquals($player->groupName, 'Player'); | ||
| $this->assertEquals($player->getName(), 'tuxytestaccount'); | ||
| $this->assertEquals($player->getGroupID(), 1); | ||
| $this->assertEquals($player->getGroupName(), 'Player'); | ||
|
|
||
| $this->assertInstanceOf(Player::class, $player); | ||
| $this->assertInstanceOf(PlayerModel::class, $player); | ||
| } | ||
|
|
||
| /** | ||
| * @throws \Exception | ||
| * @throws \Http\Client\Exception | ||
| */ | ||
| public function testPlayerBans() | ||
| public function testPlayerBans(): void | ||
| { | ||
| $bans = $this->client->bans($this->testAccount); | ||
| $bans = $this->client->bans(self::TEST_ACCOUNT); | ||
|
|
||
| $this->assertEquals($bans[0]->expires, '2016-06-19 13:00:00'); | ||
| $this->assertEquals($bans[0]->created, '2016-06-19 10:08:26'); | ||
| $this->assertEquals($bans[0]->reason, 'Test ban'); | ||
| if (count($bans->getBans()) > 0) { | ||
| $this->assertTrue(is_string($bans->getBans()[0]->getCreated())); | ||
| $this->assertTrue(is_string($bans->getBans()[0]->getExpires())); | ||
| $this->assertTrue(is_string($bans->getBans()[0]->getReason())); | ||
|
|
||
| $this->assertInstanceOf(Bans::class, $bans); | ||
| $this->assertInstanceOf(Ban::class, $bans[0]); | ||
| $this->assertInstanceOf(BanModel::class, $bans[0]); | ||
| } else { | ||
| $this->assertEquals($bans->getBans(), []); | ||
| } | ||
|
|
||
| $this->assertInstanceOf(BansModel::class, $bans); | ||
| } | ||
|
|
||
| /** | ||
| * @throws \Exception | ||
| * @throws \Http\Client\Exception | ||
| */ | ||
| public function testServers() | ||
| public function testServers(): void | ||
| { | ||
| $servers = $this->client->servers(); | ||
|
|
||
| $this->assertEquals($servers[0]->name, 'Europe 1'); | ||
| $this->assertEquals($servers->getServers()[0]->getName(), 'Europe 1 [Simulation]'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be streamlined for the cases if we will change server names. |
||
| } | ||
|
|
||
| /** | ||
| * @throws \Exception | ||
| * @throws \Http\Client\Exception | ||
| */ | ||
| public function testVersion() | ||
| public function testVersion(): void | ||
| { | ||
| $version = $this->client->version(); | ||
|
|
||
| $this->assertNotEmpty($version->version->human); | ||
| $this->assertNotEmpty($version->version->stage); | ||
| $this->assertNotEmpty($version->version->nummeric); | ||
| $this->assertNotEmpty($version->getVersion()->human); | ||
| $this->assertNotEmpty($version->getVersion()->stage); | ||
| $this->assertNotEmpty($version->getVersion()->nummeric); | ||
|
|
||
| $this->assertNotEmpty($version->checksum->atsmp->dll); | ||
| $this->assertNotEmpty($version->checksum->atsmp->adb); | ||
| $this->assertNotEmpty($version->checksum->ets2mp->dll); | ||
| $this->assertNotEmpty($version->checksum->ets2mp->adb); | ||
| $this->assertNotEmpty($version->getChecksum()->atsmp->dll); | ||
| $this->assertNotEmpty($version->getChecksum()->atsmp->adb); | ||
| $this->assertNotEmpty($version->getChecksum()->ets2mp->dll); | ||
| $this->assertNotEmpty($version->getChecksum()->ets2mp->adb); | ||
|
|
||
| $this->assertInstanceOf(Carbon::class, $version->released); | ||
| $this->assertInstanceOf(Carbon::class, $version->getReleased()); | ||
|
|
||
| $this->assertNotEmpty($version->support->ets2); | ||
| $this->assertNotEmpty($version->support->ats); | ||
| $this->assertNotEmpty($version->getSupport()->ets2); | ||
| $this->assertNotEmpty($version->getSupport()->ats); | ||
| } | ||
|
|
||
| public function testGameTime() | ||
| /** | ||
| * @throws \Http\Client\Exception | ||
| */ | ||
| public function testGameTime(): void | ||
| { | ||
| $time = $this->client->gameTime(); | ||
|
|
||
| $this->assertNotEmpty($time); | ||
|
|
||
| $this->assertInstanceOf(Carbon::class, $time->getTime()); | ||
|
|
||
| $this->assertInstanceOf(GameTimeModel::class, $time); | ||
| } | ||
|
|
||
| /** | ||
| * @throws \Http\Client\Exception | ||
| * @throws \TruckersMP\Exceptions\APIErrorException | ||
| */ | ||
| public function testRules(): void | ||
| { | ||
| $rules = $this->client->rules(); | ||
|
|
||
| $this->assertTrue(is_string($rules->getRules())); | ||
| $this->assertTrue(is_int($rules->getRevision())); | ||
|
|
||
| $this->assertInstanceOf(RulesModel::class, $rules); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add 7.2 and (maybe) 7.3, remove hhvm