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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### Composer ###
composer.phar
/vendor/
/.idea/
/Tests/cache/


1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cache:
php:
- 5.6
- 7.0
- 7.1
- hhvm

before_install:
Expand Down
41 changes: 23 additions & 18 deletions Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,46 @@

use Carbon\Carbon;
use TruckersMP\API\APIClient;

use GuzzleHttp\Client as GuzzleClient;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;

use TruckersMP\Types\Version;
use TruckersMP\Types\Ban;
use TruckersMP\Types\Bans;
use TruckersMP\Types\Player;
use TruckersMP\Types\Servers;
use TruckersMP\Types\Server;

class ClientTest extends \PHPUnit_Framework_TestCase
{

private $testAccount = 585204;

private $client;

/**
* ClientTest constructor.
*
*/
public function __construct()
{
parent::__construct();

$config = [

];
$guzzle = new GuzzleClient($config);
$adapter = new GuzzleAdapter($guzzle);

$this->client = new APIClient($adapter);
$this->client = new APIClient();
}

/**
* @throws \Exception
* @throws \Http\Client\Exception
*/
public function testPlayer()
{
$player = $this->client->player($this->testAccount); // Special test account that *should* remain static
$player = $this->client->player($this->testAccount);

$this->assertEquals($player->name, 'tuxytestaccount');

$this->assertEquals($player->groupID, 1);
$this->assertEquals($player->groupName, 'Player');

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

/**
* @throws \Exception
* @throws \Http\Client\Exception
*/
public function testPlayerBans()
{
$bans = $this->client->bans($this->testAccount);
Expand All @@ -57,15 +54,23 @@ public function testPlayerBans()

$this->assertInstanceOf(Bans::class, $bans);
$this->assertInstanceOf(Ban::class, $bans[0]);

}

/**
* @throws \Exception
* @throws \Http\Client\Exception
*/
public function testServers()
{
$servers = $this->client->servers();

$this->assertEquals($servers[0]->name, 'Europe 1');
}

/**
* @throws \Exception
* @throws \Http\Client\Exception
*/
public function testVersion()
{
$version = $this->client->version();
Expand Down
99 changes: 52 additions & 47 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,57 @@
{
"name": "truckersmp/api-client",
"description": "TruckersMP API Library helps connecting to and using the TruckersMP API.",
"homepage": "https://truckersmp.com/",
"license": "MIT",
"authors": [
{
"name": "HumaneWolf",
"email": "humanewolf@truckersmp.com",
"homepage": "https://humanewolf.com/",
"role": "CM/Dev"
},
{
"name": "Thor Erik (Tuxy Fluffyclaws) Lie",
"email": "tuxy@truckersmp.com",
"homepage": "https://truckersmp.com/",
"role": "Dev"
}
],
"require": {
"php": ">=5.6.0",
"nesbot/carbon": "^1.21",
"php-http/client-implementation": "^1.0",
"php-http/message": "^1.2",
"guzzlehttp/psr7": "^1.3"
"name": "truckersmp/api-client",
"description": "TruckersMP API Library helps connecting to and using the TruckersMP API.",
"homepage": "https://truckersmp.com/",
"license": "MIT",
"authors": [
{
"name": "HumaneWolf",
"email": "humanewolf@truckersmp.com",
"homepage": "https://humanewolf.com/",
"role": "CM/Dev"
},
"require-dev": {
"phpunit/phpunit": "^5.3",
"squizlabs/php_codesniffer": "^2.6",
"php-http/guzzle6-adapter": "^1.0"
{
"name": "Thor Erik (Tuxy Fluffyclaws) Lie",
"email": "tuxy@truckersmp.com",
"homepage": "https://truckersmp.com/",
"role": "Dev"
},
"autoload": {
"psr-4": {
"TruckersMP\\": "src/"
},
"classmap": [
"src/"
]
{
"name": "CJMAXiK",
"email": "me@cjmaxik.ru",
"homepage": "https://cjmaxik.ru",
"role": "IGA/Dev"
}
],
"require": {
"php": ">=5.6.0",
"nesbot/carbon": "^1.21",
"php-http/message": "^1.2",
"guzzlehttp/psr7": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "^5.3",
"squizlabs/php_codesniffer": "^2.6",
"php-http/guzzle6-adapter": "^1.0"
},
"autoload": {
"psr-4": {
"TruckersMP\\": "src/"
},
"autoload-dev": {
"psr-4": {
"TruckersMP\\Tests\\API\\": "tests/"
}
},
"scripts": {
"test": [
"./vendor/bin/phpunit",
"./vendor/bin/phpcs src --standard=PSR2",
"./vendor/bin/phpcs Tests --standard=PSR2"
]
}
"classmap": [
"src/"
]
},
"autoload-dev": {
"psr-4": {
"TruckersMP\\Tests\\API\\": "tests/"
}
},
"scripts": {
"test": [
"./vendor/bin/phpunit",
"./vendor/bin/phpcs src --standard=PSR2",
"./vendor/bin/phpcs Tests --standard=PSR2"
]
}
}
Loading