mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 09:54:17 +02:00
fmt, typings, typos
This commit is contained in:
parent
eb997b5ba2
commit
7de4c35ab4
34 changed files with 644 additions and 1048 deletions
|
|
@ -4,8 +4,9 @@ $finder = PhpCsFixer\Finder::create()
|
|||
->exclude('vendor')
|
||||
->in(__DIR__);
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules([
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PSR2' => true,
|
||||
'@Symfony' => true,
|
||||
'@Symfony:risky' => true,
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
{
|
||||
"require": {
|
||||
"mikecao/flight": "1.3.8",
|
||||
"vlucas/phpdotenv": "^1.1",
|
||||
"ircmaxell/random-lib": "^1.1",
|
||||
"vlucas/phpdotenv": "^v5.4.1",
|
||||
"ircmaxell/random-lib": "^v1.2.0",
|
||||
"ehesp/steam-login": "^1.2",
|
||||
"koraktor/steam-condenser": "dev-master#92dde9e3b462e93cc498fe795a712c61eec7051e",
|
||||
"guzzlehttp/guzzle": "^6.5",
|
||||
"doctrine/dbal": "^3.0",
|
||||
"doctrine/dbal": "^3.3.6",
|
||||
"ext-pdo": "*",
|
||||
"ext-json": "*",
|
||||
"ext-apcu": "*"
|
||||
|
|
@ -24,9 +23,9 @@
|
|||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9",
|
||||
"friendsofphp/php-cs-fixer": "^2.16",
|
||||
"phpstan/phpstan": "^0.12.57"
|
||||
"phpunit/phpunit": "^9.5.20",
|
||||
"friendsofphp/php-cs-fixer": "^v3.3.0",
|
||||
"phpstan/phpstan": "^1.6.8"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
|
|
|
|||
1607
composer.lock
generated
1607
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -34,13 +34,8 @@ class BaseController {
|
|||
return $this->request->data[$name] ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function json(
|
||||
$data,
|
||||
mixed $data,
|
||||
int $code = 200,
|
||||
bool $encode = true,
|
||||
string $charset = 'utf-8',
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ class DemoController extends BaseController {
|
|||
|
||||
public function get(string $id): void {
|
||||
$demo = $this->demoProvider->get(\intval($id, 10));
|
||||
if ($demo === null) {
|
||||
throw new NotFoundException("requested demo not found");
|
||||
if (null === $demo) {
|
||||
throw new NotFoundException('requested demo not found');
|
||||
} else {
|
||||
$this->json($demo);
|
||||
}
|
||||
|
|
@ -146,7 +146,7 @@ class DemoController extends BaseController {
|
|||
|
||||
$demo = $this->demoProvider->get((int) $id);
|
||||
if (!$demo) {
|
||||
throw new NotFoundException("Demo not found");
|
||||
throw new NotFoundException('Demo not found');
|
||||
}
|
||||
|
||||
$existingHash = $demo->getHash();
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ class DemoPlayer implements JsonSerializable {
|
|||
/**
|
||||
* @return array{'id': int, 'user_id': int, 'name': string, 'team': string, 'class': string, 'steamid': string, 'kills': int, 'assists': int, 'deaths': int}
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class SteamUser implements JsonSerializable {
|
|||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{'id': int, 'name': string, 'steamid': string}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ class User implements JsonSerializable {
|
|||
public function getToken(): string {
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{'id': int, 'name': string, 'steamid': string}
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'steamid' => $this->getSteamId(),
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ class ChatMessage implements JsonSerializable {
|
|||
/**
|
||||
* @return array{'user': string, 'time': int, 'message': string}
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'user' => $this->user,
|
||||
'time' => $this->time,
|
||||
|
|
@ -44,8 +43,11 @@ class ChatMessage implements JsonSerializable {
|
|||
];
|
||||
}
|
||||
|
||||
public static function fromRow(array $row): ChatMessage {
|
||||
return new ChatMessage(
|
||||
/**
|
||||
* @param array{'from': string, 'time': string, 'text': string} $row
|
||||
*/
|
||||
public static function fromRow(array $row): self {
|
||||
return new self(
|
||||
$row['from'],
|
||||
(int) $row['time'],
|
||||
$row['text']
|
||||
|
|
|
|||
|
|
@ -136,7 +136,25 @@ class Demo implements JsonSerializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $row
|
||||
* @param array{
|
||||
* 'id': string,
|
||||
* 'url': string,
|
||||
* 'name': string,
|
||||
* 'server': string,
|
||||
* 'duration': string,
|
||||
* 'nick': string,
|
||||
* 'map': string,
|
||||
* 'created_at': string,
|
||||
* 'red': string,
|
||||
* 'blu': string,
|
||||
* 'scoreRed': string,
|
||||
* 'scoreBlue': string,
|
||||
* 'playerCount': string,
|
||||
* 'uploader': string,
|
||||
* 'hash': string,
|
||||
* 'backend': string,
|
||||
* 'path': string,
|
||||
* } $row
|
||||
*
|
||||
* @return Demo
|
||||
*/
|
||||
|
|
@ -190,15 +208,27 @@ class Demo implements JsonSerializable {
|
|||
|
||||
/**
|
||||
* @return array{
|
||||
* 'id': int, 'url': string, 'name': string,
|
||||
* 'server': string, 'duration': float, 'nick': string,
|
||||
* 'map': string, 'time': int, 'red': string, 'blue': string,
|
||||
* 'redScore': int, 'blueScore': int, 'playerCount': int,
|
||||
* 'uploader': array, 'hash': string, 'backend': string, 'path': string
|
||||
* 'id': int,
|
||||
* 'url': string,
|
||||
* 'name': string,
|
||||
* 'server': string,
|
||||
* 'duration': float,
|
||||
* 'nick': string,
|
||||
* 'map': string,
|
||||
* 'time': int,
|
||||
* 'red': string,
|
||||
* 'blue': string,
|
||||
* 'redScore': int,
|
||||
* 'blueScore': int,
|
||||
* 'playerCount': int,
|
||||
* 'uploader': User|int,
|
||||
* 'hash': string,
|
||||
* 'backend': string,
|
||||
* 'path': string,
|
||||
* 'players': ?DemoPlayer
|
||||
* }
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): array {
|
||||
$data = [
|
||||
'id' => $this->getId(),
|
||||
'url' => $this->getUrl(),
|
||||
|
|
@ -218,7 +248,7 @@ class Demo implements JsonSerializable {
|
|||
'backend' => $this->getBackend(),
|
||||
'path' => $this->getPath(),
|
||||
];
|
||||
if (is_array($this->players)) {
|
||||
if (\is_array($this->players)) {
|
||||
$data['players'] = $this->getPlayers();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,13 +71,13 @@ class DemoSaver {
|
|||
|
||||
foreach ($demo->getKills() as $kill) {
|
||||
if ($kill->getAttackerDemoId()) {
|
||||
$kills[$kill->getAttackerDemoId()]++;
|
||||
++$kills[$kill->getAttackerDemoId()];
|
||||
}
|
||||
if ($kill->getAssisterDemoId()) {
|
||||
$assists[$kill->getAssisterDemoId()]++;
|
||||
++$assists[$kill->getAssisterDemoId()];
|
||||
}
|
||||
if ($kill->getVictimDemoId()) {
|
||||
$deaths[$kill->getVictimDemoId()]++;
|
||||
++$deaths[$kill->getVictimDemoId()];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class Header {
|
|||
protected float $duration;
|
||||
protected int $ticks;
|
||||
protected int $frames;
|
||||
protected int $sigon;
|
||||
protected int $singOn;
|
||||
|
||||
public function __construct(
|
||||
string $type,
|
||||
|
|
@ -43,7 +43,7 @@ class Header {
|
|||
$this->duration = $duration;
|
||||
$this->ticks = $ticks;
|
||||
$this->frames = $frames;
|
||||
$this->sigon = $sigon;
|
||||
$this->singOn = $sigon;
|
||||
}
|
||||
|
||||
public function getDuration(): float {
|
||||
|
|
@ -74,8 +74,8 @@ class Header {
|
|||
return $this->server;
|
||||
}
|
||||
|
||||
public function getSigon(): int {
|
||||
return $this->sigon;
|
||||
public function getSingOn(): int {
|
||||
return $this->singOn;
|
||||
}
|
||||
|
||||
public function getTicks(): int {
|
||||
|
|
@ -91,7 +91,19 @@ class Header {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $info
|
||||
* @param array{
|
||||
* 'type': string,
|
||||
* 'version': int,
|
||||
* 'protocol': int,
|
||||
* 'server': string,
|
||||
* 'nick': string,
|
||||
* 'map': string,
|
||||
* 'game': string,
|
||||
* 'duration': float,
|
||||
* 'ticks': int,
|
||||
* 'frames': int,
|
||||
* 'singon': int,
|
||||
* } $info
|
||||
*
|
||||
* @return Header
|
||||
*/
|
||||
|
|
@ -107,7 +119,7 @@ class Header {
|
|||
$info['duration'],
|
||||
$info['ticks'],
|
||||
$info['frames'],
|
||||
$info['sigon']
|
||||
$info['singon']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class HeaderParser {
|
|||
*/
|
||||
public function parseString(string $head): Header {
|
||||
$info = @unpack(
|
||||
'A8type/Iversion/Iprotocol/A260server/A260nick/A260map/A260game/fduration/Vticks/Vframes/Vsigon',
|
||||
'A8type/Iversion/Iprotocol/A260server/A260nick/A260map/A260game/fduration/Vticks/Vframes/Vsingon',
|
||||
$head
|
||||
);
|
||||
if (!isset($info['type']) || 'HL2DEMO' !== $info['type']) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use InvalidArgumentException;
|
|||
* Processes the raw demo.js output to something more suitable for our purpose
|
||||
*/
|
||||
class Parser {
|
||||
const CLASSES = [
|
||||
public const CLASSES = [
|
||||
1 => 'scout',
|
||||
2 => 'sniper',
|
||||
3 => 'soldier',
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Demostf\API\Demo;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Wrapper around demo.js parser.
|
||||
|
|
@ -28,13 +28,13 @@ class RawParser {
|
|||
try {
|
||||
$command = $this->parserPath . ' ' . escapeshellarg($path);
|
||||
$output = shell_exec($command);
|
||||
$result = \GuzzleHttp\json_decode($output, true);
|
||||
$result = json_decode($output, true, 512, \JSON_THROW_ON_ERROR);
|
||||
if (null === $result) {
|
||||
throw new Exception('Failed to parse demo, unexpected result from parser');
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
} catch (RequestException $e) {
|
||||
} catch (JsonException $e) {
|
||||
throw new Exception('Failed to parse demo, ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -18,7 +17,6 @@ declare(strict_types=1);
|
|||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Demostf\API\Error;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class DemoListProvider extends BaseProvider {
|
|||
$query->select('p.demo_id')
|
||||
->from('players', 'p');
|
||||
|
||||
if (\count($userIds) != count($players)) {
|
||||
if (\count($userIds) != \count($players)) {
|
||||
// one of more user ids don't have any demos
|
||||
return [];
|
||||
} elseif (\count($userIds) > 1) {
|
||||
|
|
@ -117,11 +117,11 @@ class DemoListProvider extends BaseProvider {
|
|||
}
|
||||
if (isset($where['before'])) {
|
||||
$query->andWhere($query->expr()->lt('created_at',
|
||||
$query->createNamedParameter($where['before']->format(DATE_ATOM))));
|
||||
$query->createNamedParameter($where['before']->format(\DATE_ATOM))));
|
||||
}
|
||||
if (isset($where['after'])) {
|
||||
$query->andWhere($query->expr()->gt('created_at',
|
||||
$query->createNamedParameter($where['after']->format(DATE_ATOM))));
|
||||
$query->createNamedParameter($where['after']->format(\DATE_ATOM))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ class DemoListProvider extends BaseProvider {
|
|||
* @return Demo[]
|
||||
*/
|
||||
public function listDemos(int $page, array $where = [], string $order = 'DESC'): array {
|
||||
if (isset($where['players']) and \is_array($where['players']) and \count($where['players']) > 0) {
|
||||
if (isset($where['players']) && \is_array($where['players']) && \count($where['players']) > 0) {
|
||||
return $this->listProfile($page, $where);
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +155,25 @@ class DemoListProvider extends BaseProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array[] $rows
|
||||
* @param array{
|
||||
* 'id': string,
|
||||
* 'url': string,
|
||||
* 'name': string,
|
||||
* 'server': string,
|
||||
* 'duration': string,
|
||||
* 'nick': string,
|
||||
* 'map': string,
|
||||
* 'created_at': string,
|
||||
* 'red': string,
|
||||
* 'blu': string,
|
||||
* 'scoreRed': string,
|
||||
* 'scoreBlue': string,
|
||||
* 'playerCount': string,
|
||||
* 'uploader': string,
|
||||
* 'hash': string,
|
||||
* 'backend': string,
|
||||
* 'path': string,
|
||||
* }[] $rows
|
||||
*
|
||||
* @return Demo[]
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use Doctrine\DBAL\Connection;
|
|||
use PDO;
|
||||
|
||||
class DemoProvider extends BaseProvider {
|
||||
const VERSION = 4;
|
||||
public const VERSION = 4;
|
||||
|
||||
private UserProvider $userProvider;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Demostf\API\Providers;
|
||||
|
||||
use PDO;
|
||||
|
||||
class InfoProvider extends BaseProvider {
|
||||
/**
|
||||
* @return string[]
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class UserProvider extends BaseProvider {
|
|||
}
|
||||
|
||||
public function getById(int $userId): ?User {
|
||||
if ($userId > pow(2, 31)) {
|
||||
if ($userId > 2 ** 31) {
|
||||
return null;
|
||||
}
|
||||
// first search in the view which contains the most used name for the users
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Demostf\API;
|
||||
|
||||
use Demostf\API\Error\InvalidHashException;
|
||||
use Demostf\API\Error\InvalidKeyException;
|
||||
use Flight;
|
||||
use flight\net\Response;
|
||||
|
||||
|
|
@ -75,7 +73,7 @@ Flight::map('error', function (\Throwable $ex) {
|
|||
$code = $ex->getCode();
|
||||
}
|
||||
$response = Flight::response();
|
||||
if (array_key_exists($code, Response::$codes)) {
|
||||
if (\array_key_exists($code, Response::$codes)) {
|
||||
$response->status($code);
|
||||
} else {
|
||||
$response->status(500);
|
||||
|
|
|
|||
32
src/init.php
32
src/init.php
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
use Demostf\API\Container;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Dotenv\Dotenv;
|
||||
|
||||
function get_magic_quotes_gpc(): bool {
|
||||
return false;
|
||||
|
|
@ -12,20 +13,29 @@ function get_magic_quotes_gpc(): bool {
|
|||
$autoloader = require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
if (!getenv('DB_TYPE')) {
|
||||
Dotenv::load(__DIR__ . '/../');
|
||||
Dotenv::createImmutable(__DIR__ . '/../')->safeLoad();
|
||||
}
|
||||
|
||||
$connectionParams = [
|
||||
'dbname' => getenv('DB_DATABASE'),
|
||||
'user' => getenv('DB_USERNAME'),
|
||||
'password' => getenv('DB_PASSWORD'),
|
||||
'host' => getenv('DB_HOST'),
|
||||
'port' => getenv('DB_PORT'),
|
||||
'driver' => getenv('DB_TYPE'),
|
||||
];
|
||||
if ('pgsql' === $connectionParams['driver']) {
|
||||
$connectionParams['driver'] = 'pdo_pgsql';
|
||||
$driver = getenv('DB_TYPE') ?: '';
|
||||
if ($driver === 'pgsql') {
|
||||
$driver = 'pdo_pgsql';
|
||||
}
|
||||
|
||||
$availableDrivers = DriverManager::getAvailableDrivers();
|
||||
if (!in_array($driver, $availableDrivers)) {
|
||||
throw new \Exception("Unsupported driver " . $driver);
|
||||
}
|
||||
/** @var key-of<DriverManager::DRIVER_MAP> $driver */
|
||||
|
||||
$connectionParams = [
|
||||
'dbname' => getenv('DB_DATABASE') ?: '',
|
||||
'user' => getenv('DB_USERNAME') ?: '',
|
||||
'password' => getenv('DB_PASSWORD') ?: '',
|
||||
'host' => getenv('DB_HOST') ?: '',
|
||||
'port' => (int) getenv('DB_PORT'),
|
||||
'driver' => $driver,
|
||||
];
|
||||
|
||||
$db = DriverManager::getConnection($connectionParams);
|
||||
$host = getenv('BASE_HOST') ?: '';
|
||||
$storeRoot = getenv('DEMO_ROOT') ?: '';
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ Flight::map('error', function (\Throwable $ex) {
|
|||
}
|
||||
/** @var Response $response */
|
||||
$response = Flight::response();
|
||||
if (array_key_exists($code, Response::$codes)) {
|
||||
if (\array_key_exists($code, Response::$codes)) {
|
||||
$response->status($code);
|
||||
} else {
|
||||
$response->status(500);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class DemoControllerTest extends ControllerTest {
|
|||
/** @var DemoListProvider|MockObject */
|
||||
private $demoListProvider;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->demoStore = $this->createMock(DemoStore::class);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class HeaderParserTest extends TestCase {
|
|||
$this->assertEquals($expected->getMap(), $parsed->getMap());
|
||||
$this->assertEquals($expected->getNick(), $parsed->getNick());
|
||||
$this->assertEquals($expected->getProtocol(), $parsed->getProtocol());
|
||||
$this->assertEquals($expected->getSigon(), $parsed->getSigon());
|
||||
$this->assertEquals($expected->getSingOn(), $parsed->getSingOn());
|
||||
$this->assertEquals($expected->getType(), $parsed->getType());
|
||||
$this->assertEquals($expected->getVersion(), $parsed->getVersion());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class ParserTest extends TestCase {
|
|||
/** @var RawParser|MockObject */
|
||||
private $rawParser;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->rawParser = $this->getMockBuilder(RawParser::class)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ChatProviderTest extends TestCase {
|
|||
/** @var ChatProvider */
|
||||
private $provider;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->provider = new ChatProvider($this->getDatabaseConnection());
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class DemoListProviderTest extends TestCase {
|
|||
/** @var UserProvider */
|
||||
private $userProvider;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->demoListProvider = new DemoListProvider($this->getDatabaseConnection());
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class DemoProviderTest extends TestCase {
|
|||
/** @var PlayerProvider */
|
||||
private $playerProvider;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->userProvider = new UserProvider($this->getDatabaseConnection(), $this->getRandomGenerator());
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class UploadProviderTest extends TestCase {
|
|||
/**
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->rawParser = $this->getMockBuilder(RawParser::class)
|
||||
|
|
@ -111,7 +111,7 @@ class UploadProviderTest extends TestCase {
|
|||
rmdir($dir);
|
||||
}
|
||||
|
||||
public function tearDown(): void {
|
||||
protected function tearDown(): void {
|
||||
$this->rmdirr($this->tmpDir);
|
||||
|
||||
parent::tearDown();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class UserProviderTest extends TestCase {
|
|||
/** @var SteamId */
|
||||
private $steamId;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->steamId = $this->getSteamId('76561198024494988', 'Icewind');
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
|
|||
return $this->database;
|
||||
}
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown(): void {
|
||||
protected function tearDown(): void {
|
||||
$this->clearDatabase();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ if ('/upload' === $_SERVER['REQUEST_URI']) {
|
|||
require __DIR__ . '/../src/public/index.php';
|
||||
}
|
||||
|
||||
function clearDatabase(\Doctrine\DBAL\Connection $connection) {
|
||||
function clearDatabase(Doctrine\DBAL\Connection $connection) {
|
||||
$tables = $connection->getSchemaManager()->listTables();
|
||||
foreach ($tables as $table) {
|
||||
truncateTable($connection, $table->getName());
|
||||
}
|
||||
}
|
||||
|
||||
function truncateTable(\Doctrine\DBAL\Connection $connection, string $tableName) {
|
||||
function truncateTable(Doctrine\DBAL\Connection $connection, string $tableName) {
|
||||
$sql = sprintf('TRUNCATE TABLE %s;', $tableName);
|
||||
$connection->query($sql);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue