mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
upload and tests
This commit is contained in:
parent
05f48fd0a0
commit
03d3acebf5
21 changed files with 1026 additions and 152 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Demostf\API\Test\Providers;
|
||||
namespace Demostf\API\Test\Demo;
|
||||
|
||||
use Demostf\API\Demo\Parser;
|
||||
use Demostf\API\Demo\RawParser;
|
||||
|
|
@ -30,9 +30,31 @@ class ParserTest extends TestCase {
|
|||
|
||||
$result = $parser->analyse(__DIR__ . '/../data/product.dem');
|
||||
|
||||
$expected = json_decode(file_get_contents(__DIR__ . '/../data/product-analyse.json'), true);
|
||||
$expectedRaw = json_decode(file_get_contents(__DIR__ . '/../data/product-analyse.json'), true);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
$expectedChat = $expectedRaw['chat'];
|
||||
$this->assertCount(count($expectedChat), $result->getChat());
|
||||
$this->assertEquals($expectedChat[0]['text'], $result->getChat()[0]->getMessage());
|
||||
$this->assertEquals($expectedChat[0]['time'], $result->getChat()[0]->getTime());
|
||||
$this->assertEquals($expectedChat[0]['from'], $result->getChat()[0]->getUser());
|
||||
|
||||
$this->assertEquals($expectedRaw['score']['red'], $result->getRedScore());
|
||||
$this->assertEquals($expectedRaw['score']['blue'], $result->getBlueScore());
|
||||
|
||||
$expectedPlayers = $expectedRaw['players'];
|
||||
$this->assertCount(count($expectedPlayers), $result->getPlayers());
|
||||
$this->assertEquals($expectedPlayers[0]['name'], $result->getPlayers()[0]->getName());
|
||||
$this->assertEquals($expectedPlayers[0]['demo_user_id'], $result->getPlayers()[0]->getDemoUserId());
|
||||
$this->assertEquals($expectedPlayers[0]['team'], $result->getPlayers()[0]->getTeam());
|
||||
$this->assertEquals($expectedPlayers[0]['class'], $result->getPlayers()[0]->getClass());
|
||||
$this->assertEquals($parser->convertSteamIdToCommunityId($expectedPlayers[0]['steam_id']), $result->getPlayers()[0]->getSteamId());
|
||||
|
||||
$expectedKills = $expectedRaw['kills'];
|
||||
$this->assertCount(count($expectedKills), $result->getKills());
|
||||
$this->assertEquals((int)$expectedKills[0]['killer'], $result->getKills()[0]->getAttackerDemoId());
|
||||
$this->assertEquals((int)$expectedKills[0]['assister'], $result->getKills()[0]->getAssisterDemoId());
|
||||
$this->assertEquals((int)$expectedKills[0]['victim'], $result->getKills()[0]->getVictimDemoId());
|
||||
$this->assertEquals($expectedKills[0]['weapon'], $result->getKills()[0]->getWeapon());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -52,4 +74,20 @@ class ParserTest extends TestCase {
|
|||
|
||||
$parser->analyse('foo');
|
||||
}
|
||||
|
||||
public function testConvertSteamIdToCommunityId() {
|
||||
$parser = new Parser($this->rawParser);
|
||||
|
||||
$steamId64 = $parser->convertSteamIdToCommunityId('STEAM_0:0:12345');
|
||||
$this->assertEquals('76561197960290418', $steamId64);
|
||||
}
|
||||
|
||||
public function testConvertUIdToCommunityId() {
|
||||
$parser = new Parser($this->rawParser);
|
||||
|
||||
$steamId64 = $parser->convertSteamIdToCommunityId('[U:1:12345]');
|
||||
$this->assertEquals('76561197960278073', $steamId64);
|
||||
$steamId64 = $parser->convertSteamIdToCommunityId('[U:1:39743963]');
|
||||
$this->assertEquals('76561198000009691', $steamId64);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue