1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 18:04:08 +02:00

Add php-cs-fixer

This commit is contained in:
Robin Appelman 2017-07-30 14:51:54 +02:00
commit 309ae17036
54 changed files with 4900 additions and 4106 deletions

View file

@ -3,41 +3,41 @@
$_SERVER['SCRIPT_NAME'] = '';
if ($_SERVER["REQUEST_URI"] === '/upload') {
require __DIR__ . '/../src/public/upload.php';
} else if ($_SERVER["REQUEST_URI"] === '/reset') {
// allow the api tests to reset the database
/** @var \Demostf\API\Container $container */
$container = require __DIR__ . '/../src/init.php';
$connection = $container->getConnection();
require __DIR__ . '/../src/public/upload.php';
} elseif ($_SERVER["REQUEST_URI"] === '/reset') {
// allow the api tests to reset the database
/** @var \Demostf\API\Container $container */
$container = require __DIR__ . '/../src/init.php';
$connection = $container->getConnection();
clearDatabase($connection);
} else if ($_SERVER["REQUEST_URI"] === '/testuser') {
// allow the api tests to create a test user
/** @var \Demostf\API\Container $container */
$container = require __DIR__ . '/../src/init.php';
$connection = $container->getConnection();
clearDatabase($connection);
} elseif ($_SERVER["REQUEST_URI"] === '/testuser') {
// allow the api tests to create a test user
/** @var \Demostf\API\Container $container */
$container = require __DIR__ . '/../src/init.php';
$connection = $container->getConnection();
$query = $connection->createQueryBuilder();
$query->insert('users')
->values([
'steamid' => $query->createNamedParameter('steamid1'),
'name' => $query->createNamedParameter('nickname1'),
'avatar' => $query->createNamedParameter('avatar1'),
'token' => $query->createNamedParameter('key1')
])->add('orderBy', 'ON CONFLICT DO NOTHING')// hack to append arbitrary string to sql
->execute();
$query = $connection->createQueryBuilder();
$query->insert('users')
->values([
'steamid' => $query->createNamedParameter('steamid1'),
'name' => $query->createNamedParameter('nickname1'),
'avatar' => $query->createNamedParameter('avatar1'),
'token' => $query->createNamedParameter('key1')
])->add('orderBy', 'ON CONFLICT DO NOTHING')// hack to append arbitrary string to sql
->execute();
} else {
require __DIR__ . '/../src/public/index.php';
require __DIR__ . '/../src/public/index.php';
}
function clearDatabase(\Doctrine\DBAL\Connection $connection) {
$tables = $connection->getSchemaManager()->listTables();
foreach ($tables as $table) {
truncateTable($connection, $table->getName());
}
$tables = $connection->getSchemaManager()->listTables();
foreach ($tables as $table) {
truncateTable($connection, $table->getName());
}
}
function truncateTable(\Doctrine\DBAL\Connection $connection, string $tableName) {
$sql = sprintf('TRUNCATE TABLE %s;', $tableName);
$connection->query($sql);
$sql = sprintf('TRUNCATE TABLE %s;', $tableName);
$connection->query($sql);
}