Skip to content

Commit fedac13

Browse files
cjmaxikThorErik
authored andcommitted
[BREAKING CHANGES] Library Revamp (#7)
* Road to Caching, Requests was extracted to own class * Delete `examples` folder * Apply fixes from StyleCI * File caching * Style Fixes * Style Fixes * APIClient Style Fixes * Get rid of caching, make some examples instead * Fixes * Update composer.json * Revert name
1 parent 45fea1c commit fedac13

24 files changed

+1028
-861
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
### Composer ###
22
composer.phar
33
/vendor/
4+
/.idea/
5+
/Tests/cache/
46

57

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ cache:
99
php:
1010
- 5.6
1111
- 7.0
12+
- 7.1
1213
- hhvm
1314

1415
before_install:

Tests/ClientTest.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,46 @@
44

55
use Carbon\Carbon;
66
use TruckersMP\API\APIClient;
7-
8-
use GuzzleHttp\Client as GuzzleClient;
9-
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
10-
11-
use TruckersMP\Types\Version;
127
use TruckersMP\Types\Ban;
138
use TruckersMP\Types\Bans;
149
use TruckersMP\Types\Player;
15-
use TruckersMP\Types\Servers;
16-
use TruckersMP\Types\Server;
1710

1811
class ClientTest extends \PHPUnit_Framework_TestCase
1912
{
20-
2113
private $testAccount = 585204;
2214

2315
private $client;
2416

17+
/**
18+
* ClientTest constructor.
19+
*
20+
*/
2521
public function __construct()
2622
{
2723
parent::__construct();
2824

29-
$config = [
30-
31-
];
32-
$guzzle = new GuzzleClient($config);
33-
$adapter = new GuzzleAdapter($guzzle);
34-
35-
$this->client = new APIClient($adapter);
25+
$this->client = new APIClient();
3626
}
3727

28+
/**
29+
* @throws \Exception
30+
* @throws \Http\Client\Exception
31+
*/
3832
public function testPlayer()
3933
{
40-
$player = $this->client->player($this->testAccount); // Special test account that *should* remain static
34+
$player = $this->client->player($this->testAccount);
4135

4236
$this->assertEquals($player->name, 'tuxytestaccount');
43-
4437
$this->assertEquals($player->groupID, 1);
4538
$this->assertEquals($player->groupName, 'Player');
4639

4740
$this->assertInstanceOf(Player::class, $player);
4841
}
4942

43+
/**
44+
* @throws \Exception
45+
* @throws \Http\Client\Exception
46+
*/
5047
public function testPlayerBans()
5148
{
5249
$bans = $this->client->bans($this->testAccount);
@@ -57,15 +54,23 @@ public function testPlayerBans()
5754

5855
$this->assertInstanceOf(Bans::class, $bans);
5956
$this->assertInstanceOf(Ban::class, $bans[0]);
60-
6157
}
6258

59+
/**
60+
* @throws \Exception
61+
* @throws \Http\Client\Exception
62+
*/
6363
public function testServers()
6464
{
6565
$servers = $this->client->servers();
66+
6667
$this->assertEquals($servers[0]->name, 'Europe 1');
6768
}
6869

70+
/**
71+
* @throws \Exception
72+
* @throws \Http\Client\Exception
73+
*/
6974
public function testVersion()
7075
{
7176
$version = $this->client->version();

composer.json

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,57 @@
11
{
2-
"name": "truckersmp/api-client",
3-
"description": "TruckersMP API Library helps connecting to and using the TruckersMP API.",
4-
"homepage": "https://truckersmp.com/",
5-
"license": "MIT",
6-
"authors": [
7-
{
8-
"name": "HumaneWolf",
9-
"email": "[email protected]",
10-
"homepage": "https://humanewolf.com/",
11-
"role": "CM/Dev"
12-
},
13-
{
14-
"name": "Thor Erik (Tuxy Fluffyclaws) Lie",
15-
"email": "[email protected]",
16-
"homepage": "https://truckersmp.com/",
17-
"role": "Dev"
18-
}
19-
],
20-
"require": {
21-
"php": ">=5.6.0",
22-
"nesbot/carbon": "^1.21",
23-
"php-http/client-implementation": "^1.0",
24-
"php-http/message": "^1.2",
25-
"guzzlehttp/psr7": "^1.3"
2+
"name": "truckersmp/api-client",
3+
"description": "TruckersMP API Library helps connecting to and using the TruckersMP API.",
4+
"homepage": "https://truckersmp.com/",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "HumaneWolf",
9+
"email": "[email protected]",
10+
"homepage": "https://humanewolf.com/",
11+
"role": "CM/Dev"
2612
},
27-
"require-dev": {
28-
"phpunit/phpunit": "^5.3",
29-
"squizlabs/php_codesniffer": "^2.6",
30-
"php-http/guzzle6-adapter": "^1.0"
13+
{
14+
"name": "Thor Erik (Tuxy Fluffyclaws) Lie",
15+
"email": "[email protected]",
16+
"homepage": "https://truckersmp.com/",
17+
"role": "Dev"
3118
},
32-
"autoload": {
33-
"psr-4": {
34-
"TruckersMP\\": "src/"
35-
},
36-
"classmap": [
37-
"src/"
38-
]
19+
{
20+
"name": "CJMAXiK",
21+
"email": "[email protected]",
22+
"homepage": "https://cjmaxik.ru",
23+
"role": "IGA/Dev"
24+
}
25+
],
26+
"require": {
27+
"php": ">=5.6.0",
28+
"nesbot/carbon": "^1.21",
29+
"php-http/message": "^1.2",
30+
"guzzlehttp/psr7": "^1.3"
31+
},
32+
"require-dev": {
33+
"phpunit/phpunit": "^5.3",
34+
"squizlabs/php_codesniffer": "^2.6",
35+
"php-http/guzzle6-adapter": "^1.0"
36+
},
37+
"autoload": {
38+
"psr-4": {
39+
"TruckersMP\\": "src/"
3940
},
40-
"autoload-dev": {
41-
"psr-4": {
42-
"TruckersMP\\Tests\\API\\": "tests/"
43-
}
44-
},
45-
"scripts": {
46-
"test": [
47-
"./vendor/bin/phpunit",
48-
"./vendor/bin/phpcs src --standard=PSR2",
49-
"./vendor/bin/phpcs Tests --standard=PSR2"
50-
]
51-
}
41+
"classmap": [
42+
"src/"
43+
]
44+
},
45+
"autoload-dev": {
46+
"psr-4": {
47+
"TruckersMP\\Tests\\API\\": "tests/"
48+
}
49+
},
50+
"scripts": {
51+
"test": [
52+
"./vendor/bin/phpunit",
53+
"./vendor/bin/phpcs src --standard=PSR2",
54+
"./vendor/bin/phpcs Tests --standard=PSR2"
55+
]
56+
}
5257
}

0 commit comments

Comments
 (0)