mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 09:54:17 +02:00
lint
This commit is contained in:
parent
68f20ac903
commit
c29fe61ad1
24 changed files with 1242 additions and 50 deletions
|
|
@ -52,7 +52,7 @@ abstract class ControllerTest extends TestCase {
|
|||
}
|
||||
|
||||
protected function assertResponseData($expected) {
|
||||
if (!is_string($expected)) {
|
||||
if (!\is_string($expected)) {
|
||||
$expected = json_encode($expected);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class DemoStoreTest extends TestCase {
|
|||
|
||||
$this->assertStringEqualsFile($storedDemo->getPath(), 'foobar');
|
||||
unlink($storedDemo->getPath());
|
||||
rmdir(dirname($storedDemo->getPath()));
|
||||
rmdir(dirname($storedDemo->getPath(), 2));
|
||||
rmdir(\dirname($storedDemo->getPath()));
|
||||
rmdir(\dirname($storedDemo->getPath(), 2));
|
||||
rmdir($targetDir);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class ParserTest extends TestCase {
|
|||
$expectedRaw = json_decode(file_get_contents(__DIR__ . '/../data/product-analyse.json'), true);
|
||||
|
||||
$expectedChat = $expectedRaw['chat'];
|
||||
$this->assertCount(count($expectedChat), $result->getChat());
|
||||
$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());
|
||||
|
|
@ -45,7 +45,7 @@ class ParserTest extends TestCase {
|
|||
$this->assertEquals($expectedRaw['score']['blue'], $result->getBlueScore());
|
||||
|
||||
$expectedPlayers = $expectedRaw['players'];
|
||||
$this->assertCount(count($expectedPlayers), $result->getPlayers());
|
||||
$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());
|
||||
|
|
@ -53,7 +53,7 @@ class ParserTest extends TestCase {
|
|||
$this->assertEquals(Parser::convertSteamIdToCommunityId($expectedPlayers[0]['steam_id']), $result->getPlayers()[0]->getSteamId());
|
||||
|
||||
$expectedKills = $expectedRaw['kills'];
|
||||
$this->assertCount(count($expectedKills), $result->getKills());
|
||||
$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());
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ class UploadProviderTest extends TestCase {
|
|||
$result = $this->uploadProvider->upload($token, 'RED', 'BLU', 'foodemo', $this->tmpDir . '/foo.dem');
|
||||
$this->assertStringStartsWith('STV available at: http://example.com/', $result);
|
||||
|
||||
$demoId = (int) substr($result, strlen('STV available at: http://example.com/'));
|
||||
$demoId = (int) substr($result, \strlen('STV available at: http://example.com/'));
|
||||
|
||||
$demo = $this->demoProvider->get($demoId, true);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
|
|||
'port' => getenv('DB_PORT'),
|
||||
'driver' => getenv('DB_TYPE'),
|
||||
];
|
||||
if ($connectionParams['driver'] === 'pgsql') {
|
||||
if ('pgsql' === $connectionParams['driver']) {
|
||||
$connectionParams['driver'] = 'pdo_pgsql';
|
||||
}
|
||||
$this->database = DriverManager::getConnection($connectionParams);
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@ declare(strict_types=1);
|
|||
|
||||
$_SERVER['SCRIPT_NAME'] = '';
|
||||
|
||||
if ($_SERVER['REQUEST_URI'] === '/upload') {
|
||||
if ('/upload' === $_SERVER['REQUEST_URI']) {
|
||||
require __DIR__ . '/../src/public/upload.php';
|
||||
} elseif ($_SERVER['REQUEST_URI'] === '/reset') {
|
||||
} elseif ('/reset' === $_SERVER['REQUEST_URI']) {
|
||||
// allow the api tests to reset the database
|
||||
/** @var \Demostf\API\Container $container */
|
||||
$container = require __DIR__ . '/../src/init.php';
|
||||
$connection = $container->getConnection();
|
||||
|
||||
clearDatabase($connection);
|
||||
} elseif ($_SERVER['REQUEST_URI'] === '/testuser') {
|
||||
} elseif ('/testuser' === $_SERVER['REQUEST_URI']) {
|
||||
// allow the api tests to create a test user
|
||||
/** @var \Demostf\API\Container $container */
|
||||
$container = require __DIR__ . '/../src/init.php';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue